@protobase/ui 0.37.2 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.js +1 -1
- package/dist/shell/assets/{app-C1zG0oRE.js → app-BCgljtR4.js} +4 -4
- package/dist/shell/assets/{index-B7G87PyV.js → index-Dfo0EmgH.js} +2 -2
- package/dist/shell/assets/{records-map-85gFdOGo.js → records-map-DE5BswCb.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui-Bj9-LpID.js → shared-protobase-ui-D3HUwrUp.js} +2 -2
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +1 -1
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/{app-C1zG0oRE.js.map → app-BCgljtR4.js.map} +1 -1
- package/dist/shell-source-maps/assets/{index-B7G87PyV.js.map → index-Dfo0EmgH.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-85gFdOGo.js.map → records-map-DE5BswCb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{shared-protobase-ui-Bj9-LpID.js.map → shared-protobase-ui-D3HUwrUp.js.map} +1 -1
- package/package.json +4 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-content-CtGUP4W6.js","assets/rolldown-runtime-hePW80VL.js","assets/react-Cvdyeg_0.js","assets/cn-Bi0ZEjD9.js","assets/jsx-runtime-NZYk81nU.js","assets/records-map-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-content-CtGUP4W6.js","assets/rolldown-runtime-hePW80VL.js","assets/react-Cvdyeg_0.js","assets/cn-Bi0ZEjD9.js","assets/jsx-runtime-NZYk81nU.js","assets/records-map-DE5BswCb.js","assets/maplibre-DUTS_eJM.js","assets/react-dom-B-VxWsjA.js","assets/preload-helper-BZ3hrQDD.js","assets/maplibre-DBE96hFo.css","assets/record-map-DFy7sJEU.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{t as r}from"./react-Cvdyeg_0.js";import{t as i}from"./react-dom-B-VxWsjA.js";import{a,d as o,f as s,i as c,l,n as u,o as d,r as f,s as p,t as m,u as h}from"./preload-helper-BZ3hrQDD.js";import{t as g}from"./cn-Bi0ZEjD9.js";import{t as _}from"./jsx-runtime-NZYk81nU.js";var v=(e,t,n,r)=>({code:e,message:t,hint:n,span:r}),y=(e,t)=>{let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++){let o=e[r-1]===t[a-1]?0:1;i[a]=Math.min(n[a]+1,i[a-1]+1,n[a-1]+o)}n=i}return n[t.length]},b=(e,t)=>{let n=e.toLowerCase(),r=t.map(e=>({candidate:e,score:y(n,e.toLowerCase())})).sort((e,t)=>e.score-t.score)[0];return r&&r.score<=Math.max(2,Math.floor(e.length/3))?r.candidate:void 0},x=(e,t)=>({start:e.start,end:t.end}),S=(e,t)=>t===2?e%4==0&&(e%100!=0||e%400==0)?29:28:[4,6,9,11].includes(t)?30:31,C=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return r>=1&&r<=12&&i>=1&&i<=S(n,r)},w=e=>{let t=/^(\d{4}-\d{2}-\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|[+-](\d{2}):(\d{2}))$/.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[2]),Number(t[3]),Number(t[4])],[a,o]=[Number(t[5]??0),Number(t[6]??0)];return C(t[1])&&n<=23&&r<=59&&i<=59&&a<=23&&o<=59},T={s:1,m:60,h:3600,d:86400,w:604800},E=e=>w(e)?Date.parse(e.toUpperCase()):void 0,D=/^(\d+(?:\.\d+)?)(s|m|h|d|w)$/,O=e=>{let t=D.exec(e);return t?Number(t[1])*T[t[2]]:void 0},k=/\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})/y,A=/\d{4}-\d{2}-\d{2}/y,j=/[TtZz0-9:.+-]*/y,M=/0[xX][0-9a-fA-F]+/y,N=/\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/y,P=(e,t,n)=>(e.lastIndex=n,e.exec(t)?.[0]),ee=(e,t,n,r)=>{let i=P(k,e,t);if(i&&w(i))return{kind:`timestamp`,end:t+i.length};if(i||P(A,e,t)){let n=t+(P(j,e,t)??``).length;return{kind:`error`,end:n,error:v(`invalid-timestamp`,`"${e.slice(t,n)}" is not a valid RFC-3339 timestamp`,`Use a full timestamp like 2012-04-21T11:30:00Z, or quote a plain date: "2012-04-21"`,{start:t,end:n})}}let a=P(M,e,t);if(a)return n(e[t+a.length])?{kind:`number`,end:t+a.length}:void 0;let o=t+P(N,e,t).length;return(r.durationUnits?`smhdw`:`s`).includes(e[o]??` `)&&n(e[o+1])?{kind:`duration`,end:o+1}:n(e[o])?{kind:`number`,end:o}:void 0},te={a:`\x07`,b:`\b`,f:`\f`,n:`
|
|
3
3
|
`,r:`\r`,t:` `,v:`\v`,"'":`'`,'"':`"`,"\\":`\\`,"?":`?`,"`":"`"},ne=(e,t,n)=>{let r=e.slice(t,t+n);return r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):void 0},re=(e,t)=>{let n=e[t+1];if(n===void 0)return{error:`a backslash at the end`,end:t+1};if(Object.hasOwn(te,n))return{text:te[n],end:t+2};let r={x:2,u:4,U:8};if(Object.hasOwn(r,n)){let i=ne(e,t+2,r[n]),a=t+2+r[n];return i!==void 0&&i<=1114111&&!(i>=55296&&i<=57343)?{text:String.fromCodePoint(i),end:a}:{error:`\\${n} needs ${r[n]} hex digits naming a Unicode scalar value`,end:t+2}}let i=/^[0-3][0-7]{2}/.exec(e.slice(t+1,t+4));return i?{text:String.fromCharCode(parseInt(i[0],8)),end:t+4}:{error:`the escape "\\${n}"`,end:t+2}},ie=(e,t)=>{let n=e[t],r=[],i=``,a=t+1;for(;a<e.length;){let t=e[a];if(t===n)return{end:a+1,value:i,errors:r};if(t!==`\\`){i+=t,a++;continue}let o=re(e,a);`text`in o?i+=o.text:r.push(v(`invalid-escape`,`Invalid escape: ${o.error}`,`Valid escapes: \\a \\b \\f \\n \\r \\t \\v \\' \\" \\\\ \\? \\\` \\xHH \\uXXXX \\UXXXXXXXX \\ooo`,{start:a,end:o.end})),a=o.end}return r.push(v(`unterminated-string`,`String is missing its closing quote`,`Add a closing ${n}`,{start:t,end:e.length})),{end:e.length,value:void 0,errors:r}},ae={"(":`lparen`,")":`rparen`,",":`comma`,".":`dot`,":":`has`,"=":`eq`,"<":`lt`,">":`gt`,"-":`minus`},oe={AND:`and`,OR:`or`,NOT:`not`},se=e=>{let[t,n,r]=[e.at(-1),e.at(-2),e.at(-3)];return t?.kind===`rparen`&&n?.kind===`lparen`&&r?.text===`now`},ce=(e,t={})=>{let n=[],r=[],i=e=>e!==void 0&&(e in ae||e===`!`||t.arithmetic===!0&&e===`+`),a=e=>e===void 0||/\s/.test(e)||i(e)||e===`"`||e===`'`,o=(t,r,i,a=e.slice(r,i))=>n.push({kind:t,text:e.slice(r,i),value:a,span:{start:r,end:i}}),s=e.isWellFormed()?-1:e.search(/[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/);s>=0&&r.push(v(`invalid-unicode`,`The filter contains an unpaired surrogate`,`Use well-formed UTF-16 text`,{start:s,end:s+1}));let c=0;for(;c<e.length;){let i=e[c];if(/\s/.test(i)){c++;continue}if(i===`"`||i===`'`){let t=ie(e,c);r.push(...t.errors),t.value!==void 0&&o(`string`,c,t.end,t.value),c=t.end;continue}if(/[0-9]/.test(i)){let n=ee(e,c,a,t);if(n?.kind===`error`?r.push(n.error):n&&o(n.kind,c,n.end),n){c=n.end;continue}}if(i===`!`||i===`<`||i===`>`){let t=e[c+1]===`=`;if(i===`!`&&!t){r.push(v(`unexpected-character`,`Unexpected character "!"`,`Use != for "not equal" or NOT / - for negation`,{start:c,end:c+1})),c++;continue}o(i===`!`?`ne`:i===`<`?t?`le`:`lt`:t?`ge`:`gt`,c,c+(t?2:1)),c+=t?2:1;continue}if(Object.hasOwn(ae,i)){o(ae[i],c,c+1),c++;continue}let s=t.arithmetic===`now-offset`&&se(n);if(i===`+`&&(t.arithmetic===!0||s)){o(`plus`,c,c+1),c++;continue}let l=c+1;for(;!a(e[l]);)l++;let u=e.slice(c,l);o(Object.hasOwn(oe,u)?oe[u]:`text`,c,l),c=l}return o(`eof`,e.length,e.length),{tokens:n,errors:r}},le=class extends Error{error;constructor(e){super(e.message),this.error=e}},ue=(e,t,n,r)=>{throw new le(v(e,t,n,r))},F=(e,t=0)=>e.tokens[Math.min(e.pos+t,e.tokens.length-1)],de=e=>{let t=F(e);return t.kind!==`eof`&&e.pos++,t},fe=(e,t)=>F(e).kind===t?de(e):void 0,pe=e=>e.kind===`eof`?`end of input`:`"${e.text}"`,me=(e,t,n,r)=>fe(e,t)??ue(`expected-token`,`Expected ${n} but found ${pe(F(e))}`,r,F(e).span),I=(e,t,n)=>{e.depth>=e.maxDepth&&ue(`too-deep`,`The filter is nested too deeply`,`Nest at most ${e.maxDepth} levels`,t),e.depth++;try{return n()}finally{e.depth--}},he=[`text`,`and`,`or`,`not`],ge=e=>{let t=me(e,`text`,`a field name or value`,`Text may not contain spaces or the characters ( ) - . = : < > ! ,`),n=[t.text],r=t.span;for(;F(e).kind===`dot`;){let t=F(e,1),i=t.kind===`number`&&/^\d+(\.\d+)?$/.test(t.text);!he.includes(t.kind)&&!i&&ue(`expected-token`,`Expected a field name after "." but found ${pe(t)}`,`Write traversals like customer.country`,t.span),de(e),de(e),n.push(...i?t.text.split(`.`):[t.text]),r=x(r,t.span)}return{kind:`member`,path:n,span:r}},_e=e=>({kind:`duration`,amount:Number(e.text.slice(0,-1)),unit:e.text.slice(-1),span:e.span}),ve=[`member`,`string`,`number`,`boolean`,`duration`,`timestamp`,`call`,`binary`],ye=e=>ve.includes(e.kind),be=(e,t,n)=>I(e,n,()=>{de(e);let r=[];if(F(e).kind!==`rparen`)do r.push(Te(e));while(fe(e,`comma`));return{kind:`call`,name:t,args:r,span:x(n,me(e,`rparen`,`")"`,`Close the call to ${t}() with ")"`).span)}}),xe=e=>{let t=F(e);switch(t.kind){case`string`:return de(e),{kind:`string`,value:t.value,span:t.span};case`number`:return de(e),{kind:`number`,value:Number(t.text),raw:t.text,span:t.span};case`duration`:return de(e),_e(t);case`timestamp`:return de(e),{kind:`timestamp`,value:t.text,span:t.span};case`minus`:{let n=F(e,1);(n.kind!==`number`||n.span.start!==t.span.end)&&ue(`unexpected-token`,`Expected a number after "-" but found ${pe(n)}`,`Write negative numbers as -5, without a space`,n.span),de(e),de(e);let r=`-${n.text}`;return{kind:`number`,value:-Number(n.text),raw:r,span:x(t.span,n.span)}}case`text`:{if((t.text===`true`||t.text===`false`)&&F(e,1).kind!==`dot`&&(F(e,1).kind!==`lparen`||F(e,1).span.start!==t.span.end))return de(e),{kind:`boolean`,value:t.text===`true`,span:t.span};let n=ge(e);return F(e).kind===`lparen`&&F(e).span.start===n.span.end?be(e,n.path.join(`.`),n.span):n}default:return ue(`unexpected-token`,`Expected a value but found ${pe(t)}`,`Values are text, "strings", numbers, true/false, durations, timestamps or function calls`,t.span)}},Se=e=>{let t=de(e);return I(e,t.span,()=>{let n=e.expression(e);return me(e,`rparen`,`")"`,`Close the group opened here`),n?n.kind===`global`?n.value:n:ue(`unexpected-token`,`Empty group`,`Put an expression inside the parentheses`,t.span)})},Ce=e=>F(e).kind===`lparen`?Se(e):xe(e),we=e=>[`text`,`string`,`number`,`duration`,`timestamp`,`lparen`,`minus`].includes(F(e,1).kind),Te=e=>{let t=Ce(e);if(!e.extensions.arithmetic||!ye(t))return t;let n=t,r=e.extensions.arithmetic===`now-offset`,i=()=>n.kind===`call`&&n.name===`now`&&n.args.length===0,a=()=>!r||i()&&F(e,1).kind===`duration`;if(r&&i()&&(F(e).kind===`plus`||F(e).kind===`minus`)&&F(e,1).kind!==`duration`)return ue(`expected-token`,`Expected a duration after "${F(e).text}" but found ${pe(F(e,1))}`,`Durations need a unit, for example now() - 30d`,F(e,1).span);for(;(F(e).kind===`plus`||F(e).kind===`minus`)&&we(e)&&a();){let t=de(e).kind===`plus`?`+`:`-`,r=Ce(e);if(!ye(r))return ue(`unexpected-token`,`Arithmetic needs values, not conditions`,`Use values on both sides of + and -`,r.span);n={kind:`binary`,op:t,left:n,right:r,span:x(n.span,r.span)}}return n},Ee=e=>{let t=F(e),n=Te(e);return ye(n)||ue(`unexpected-token`,`A comparison needs a value on the right`,`Write field = value`,t.span),n},De={eq:`=`,ne:`!=`,lt:`<`,le:`<=`,gt:`>`,ge:`>=`},Oe=[`text`,`string`,`number`,`duration`,`timestamp`,`not`,`minus`,`lparen`],ke=(e,t)=>{let n=t.filter(e=>e!==void 0);return n.length<=1?n[0]:{kind:e,args:n,span:x(n[0].span,n[n.length-1].span)}},Ae=e=>{let t=0;for(;;){let{kind:n}=F(e);if(n===`eof`||t===0&&(n===`and`||n===`or`||n===`rparen`))return;n===`lparen`&&t++,n===`rparen`&&t--,de(e)}},je=e=>{let t=xe(e),n=F(e);if(n.kind===`has`){de(e);let n=F(e);if(n.kind===`text`&&n.text===`*`)return de(e),{kind:`present`,left:t,span:x(t.span,n.span)};let r=Ee(e);return{kind:`has`,left:t,right:r,span:x(t.span,r.span)}}let r=De[n.kind];if(r){de(e);let n=Ee(e);return{kind:`compare`,op:r,left:t,right:n,span:x(t.span,n.span)}}return t.kind===`call`?t:{kind:`global`,value:t,span:t.span}},Me=e=>{let t=F(e);return t.kind===`lparen`?(de(e),I(e,t.span,()=>{let n=Le(e);return fe(e,`rparen`)||e.errors.push(v(`expected-token`,`Expected ")" but found ${pe(F(e))}`,`Close the group opened here`,t.span)),n})):je(e)},Ne=e=>{let t=F(e);if(t.kind!==`not`&&t.kind!==`minus`)return Oe.includes(t.kind)?I(e,t.span,()=>Me(e)):ue(`unexpected-token`,`Unexpected ${pe(t)}`,`Expected a field, a value or "("`,t.span);de(e);let n=F(e),r=n.kind===`minus`&&F(e,1).kind===`number`&&F(e,1).span.start===n.span.end;(n.kind===`not`||n.kind===`minus`&&!r)&&ue(`unexpected-token`,`Negations cannot be stacked`,`Group the inner one: NOT (NOT a)`,n.span);let i=I(e,t.span,()=>Me(e));if(!i)return;let a=x(t.span,i.span);if(t.kind===`minus`&&i.kind===`global`&&i.value.kind===`number`&&!i.value.raw.startsWith(`-`)){let{raw:e,value:t}=i.value;return{kind:`global`,value:{kind:`number`,value:-t,raw:`-${e}`,span:a},span:a}}return{kind:`not`,arg:i,span:a}},Pe=e=>{try{return Ne(e)}catch(t){if(!(t instanceof le))throw t;e.errors.push(t.error),Ae(e);return}},Fe=e=>{let t=[Pe(e)];for(;fe(e,`or`);)t.push(Pe(e));return ke(`or`,t)},Ie=e=>{let t=[Fe(e)];for(;Oe.includes(F(e).kind);)t.push(Fe(e));return ke(`sequence`,t)},Le=e=>{let t=[Ie(e)];for(;fe(e,`and`);)t.push(Ie(e));return ke(`and`,t)},Re=(e,t={})=>{let n=t.maxLength??1e4;if(e.length>n)return{ok:!1,ast:void 0,errors:[v(`too-long`,`The filter is longer than ${n} characters`,`Shorten the filter`,{start:n,end:e.length})]};let r=t.extensions??{},i=ce(e,r),a={tokens:i.tokens,pos:0,errors:i.errors,depth:0,maxDepth:t.maxDepth??64,extensions:r,expression:Le},o=[];for(;F(a).kind!==`eof`;){if(F(a).kind===`rparen`){let e=de(a);a.errors.push(v(`unexpected-token`,`Unmatched ")"`,`Remove it or add a matching "("`,e.span));continue}o.push(Le(a))}let s=o.filter(e=>e!==void 0),c=s.length<=1?s[0]:{kind:`and`,args:s,span:{start:s[0].span.start,end:s[s.length-1].span.end}},l=[...a.errors].sort((e,t)=>e.span.start-t.span.start);return l.length===0?{ok:!0,ast:c,errors:[]}:{ok:!1,ast:c,errors:l}},ze=(e,t)=>{if(Object.hasOwn(e,t))return{name:t,spec:e[t]};let n=Object.entries(e).find(([,e])=>e.aliases?.includes(t));return n&&{name:n[0],spec:n[1]}},Be=(e,t)=>{let n=t.path[0],r=ze(e.schema.fields,n);if(!r){let r=Object.entries(e.schema.fields).filter(([,e])=>e.filterable!==!1).map(([e])=>e),i=b(n,r);e.errors.push(v(`unknown-field`,`Unknown field "${n}"`,i?`Did you mean "${i}"?`:`Available fields: ${r.join(`, `)}`,t.span));return}let i=[r.name],a=r.spec,o=a.filterable!==!1;for(let n of t.path.slice(1)){let r=a.type===`message`?a.fields?.[n]:a.type===`map`?a.value:a.type===`any`?a:void 0;if(!r||a.type===`message`&&!Object.hasOwn(a.fields??{},n)){e.errors.push(v(`invalid-traversal`,`Cannot traverse into "${n}" of "${i.join(`.`)}"`,a.type===`message`?`Available fields: ${Object.keys(a.fields??{}).join(`, `)}`:`Only message, map and any fields can be traversed`,t.span));return}i.push(n),a=r,o&&=a.filterable!==!1}if(!o){e.errors.push(v(`not-filterable`,`Field "${i.join(`.`)}" cannot be filtered on`,`Mark it filterable in the schema`,t.span));return}return{...t,path:i,field:{name:i.join(`.`),spec:a}}},Ve=(e,t)=>({message:e,hint:t}),He=(e,t)=>Ve(`Expected ${e}`,t),Ue=e=>e.kind===`string`?e.value:e.kind===`member`?e.path.join(`.`):void 0,We={integer:/^-?(\d+|0[xX][0-9a-fA-F]+)$/,number:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$|^-?0[xX][0-9a-fA-F]+$/},Ge=(e,t)=>e===t||e===`any`||t===`any`||[`integer`,`number`].includes(e)&&[`integer`,`number`].includes(t),Ke=(e,t,n)=>{let r=Ue(n);switch(e){case`any`:return;case`string`:return r===void 0?He(`a string`,`Quote text values: "..."`):void 0;case`enum`:return r!==void 0&&t?.values?.includes(r)?void 0:Ve(`Invalid enum value`,`Allowed values: ${(t?.values??[]).join(`, `)}`);case`integer`:case`number`:{let t=n.kind===`number`?n.raw:r;return t!==void 0&&We[e].test(t)?void 0:He(e===`integer`?`an integer`:`a number`,`Write 42, -1.5 or 2.5e3, or quote a numeric string`)}case`boolean`:return n.kind===`boolean`||r===`true`||r===`false`?void 0:He(`true or false`,`Write true or false`);case`timestamp`:return n.kind===`timestamp`||r!==void 0&&w(r)?void 0:He(`an RFC-3339 timestamp`,`Use "2012-04-21T11:30:00Z"`);case`duration`:return n.kind===`duration`||r!==void 0&&O(r)!==void 0?void 0:He(`a duration`,`Use a number with a unit, for example 20s or 1.5s`);case`map`:case`message`:return Ve(`${e} fields cannot be compared`,`Compare a nested field, or use field:key`)}},eee=e=>[`member`,`string`,`number`,`boolean`,`duration`,`timestamp`,`call`,`binary`].includes(e.kind),tee=(e,t,n,r)=>{if(!eee(n)){e.errors.push(v(`wrong-argument`,`Argument "${t.name}" must be a value`,`Pass a field, literal or function call`,n.span));return}if(t.type===`field`){if(n.kind!==`member`){e.errors.push(v(`wrong-argument`,`Argument "${t.name}" must be a field`,`Pass a field name without quotes`,n.span));return}let r=Be(e,n);if(r&&t.of&&!t.of.includes(r.field.spec.type)){e.errors.push(v(`wrong-argument`,`Argument "${t.name}" cannot be a ${r.field.spec.type} field`,`Accepted field types: ${t.of.join(`, `)}`,n.span));return}return r}let i=r(e,n);if(!i)return;if(t.type===`any`)return i.node;let a=i.type&&(n.kind===`call`||n.kind===`binary`)?Ge(t.type,i.type)?void 0:{message:`Expected ${t.type}`,hint:`Argument "${t.name}" is ${i.type}`}:Ke(t.type,void 0,i.node);return a&&e.errors.push(v(`wrong-argument`,a.message,a.hint,n.span)),a?void 0:i.node},qe=(e,t,n)=>{let r=e.schema.functions??{};if(!Object.hasOwn(r,t.name)){let n=b(t.name,Object.keys(r));e.errors.push(v(`unknown-function`,`Unknown function "${t.name}"`,n?`Did you mean "${n}"?`:`Available functions: ${Object.keys(r).join(`, `)||`none`}`,t.span));return}let i=r[t.name],a=i.params.length;if(t.args.length<a||!i.rest&&t.args.length>a){let n=i.rest?`at least ${a}`:String(a);e.errors.push(v(`wrong-arity`,`${t.name}() takes ${n} argument(s) but got ${t.args.length}`,`Usage: ${t.name}(${[...i.params,...i.rest?[i.rest]:[]].map(e=>e.name).join(`, `)})`,t.span));return}let o=t.args.map((t,r)=>tee(e,i.params[r]??i.rest,t,n));if(!o.some(e=>e===void 0))return{call:{...t,args:o},returns:i.returns??`boolean`}},nee=(e,t,n)=>{if(e===`timestamp`&&t===`duration`)return`timestamp`;if(e===`timestamp`&&t===`timestamp`&&n===`-`||e===`duration`&&t===`duration`)return`duration`;if((e===`integer`||e===`number`)&&(t===`integer`||t===`number`))return e===`integer`&&t===`integer`?`integer`:`number`},ree={number:`number`,boolean:`boolean`,duration:`duration`,timestamp:`timestamp`},Je=(e,t)=>{switch(t.kind){case`call`:{let n=qe(e,t,Je);return n&&{node:n.call,type:n.returns}}case`binary`:{let n=Je(e,t.left),r=Je(e,t.right);if(!n||!r)return;let i=n.type&&r.type?nee(n.type,r.type,t.op):n.type??r.type??`number`;if(!i){e.errors.push(v(`invalid-value`,`Cannot apply "${t.op}" to ${n.type} and ${r.type}`,`Add a duration to a timestamp, or combine numbers`,t.span));return}return{node:{...t,left:n.node,right:r.node},type:i}}case`number`:case`boolean`:case`duration`:case`timestamp`:return{node:t,type:ree[t.kind]};default:return{node:t,type:void 0}}},Ye=[`string`,`integer`,`number`,`timestamp`,`duration`,`any`],Xe=(e,t)=>{if(t.kind===`member`){let n=Be(e,t);return n&&{node:n,type:n.field.spec.type,spec:n.field.spec}}let n=Je(e,t);return n&&{...n,spec:void 0}},Ze=(e,t,n,r)=>{e.errors.push(v(`operator-not-allowed`,t,n,r.span))},Qe=(e,t,n)=>{if(!t.type)return Je(e,n)?.node;let r=Je(e,n);if(!r)return;let i=r.type&&(n.kind===`call`||n.kind===`binary`)?Ge(t.type,r.type)?void 0:{message:`Expected ${t.type} but got ${r.type}`,hint:`Compare values of the same type`}:Ke(t.type,t.spec,r.node);return i&&e.errors.push(v(`invalid-value`,i.message,i.hint,n.span)),i?void 0:r.node},iee=(e,t)=>{let n=Xe(e,t.left);if(!n)return;let r=n.type;if(n.spec?.repeated)return Ze(e,`"${t.op}" is not supported on repeated fields`,`Use field:value to test membership`,t);if(r===`map`||r===`message`)return Ze(e,`${r} fields cannot be compared`,`Use field:key, or compare a nested field`,t);if(r&&![`=`,`!=`].includes(t.op)&&!Ye.includes(r))return Ze(e,`"${t.op}" is not supported for ${r} fields`,`Supported: = !=`,t);let i=(t.op===`=`||t.op===`!=`)&&t.right.kind===`string`&&t.right.value.includes(`*`);if(i&&r&&r!==`string`&&r!==`any`){e.errors.push(v(`wildcard-not-allowed`,`Wildcards are only supported on string fields, not ${r}`,`Remove the "*"`,t.right.span));return}let a=i?t.right:Qe(e,n,t.right);return a&&{...t,left:n.node,right:a}},aee=(e,t)=>{let n=Xe(e,t.left);if(!n)return;let{type:r,spec:i}=n,a=Qe(e,!i?.repeated&&(r===`map`||r===`message`)?{...n,type:`string`}:n,t.right);return a&&{...t,left:n.node,right:a}},$e=(e,t)=>{switch(t.kind){case`sequence`:case`and`:case`or`:{let n=t.args.map(t=>$e(e,t));return n.every(e=>e)?{...t,args:n}:void 0}case`not`:{let n=$e(e,t.arg);return n&&{...t,arg:n}}case`compare`:return iee(e,t);case`has`:return aee(e,t);case`present`:{let n=Xe(e,t.left);return n&&{...t,left:n.node}}case`global`:return t;case`call`:{let n=qe(e,t,Je);if(n&&n.returns!==`boolean`){e.errors.push(v(`not-boolean`,`${t.name}() returns ${n.returns}, not a condition`,`Compare its result: f(x) > 1`,t.span));return}return n?.call}}},et=(e,t)=>{let n={schema:t,errors:[]},r=$e(n,e);return!r||n.errors.length>0?{ok:!1,errors:[...n.errors].sort((e,t)=>e.span.start-t.span.start)}:{ok:!0,ast:r}},tt={"\\":`\\\\`,'"':`\\"`,"\n":`\\n`,"\r":`\\r`," ":`\\t`,"\x07":`\\a`,"\b":`\\b`,"\f":`\\f`,"\v":`\\v`},oee=e=>{if(!e.isWellFormed())throw Error(`Strings with unpaired surrogates cannot be printed`);return`"${e.replace(/[\\"\u0000-\u001f\u007f-\u009f]/g,e=>tt[e]??`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}"`},see=e=>{switch(e.kind){case`string`:return oee(e.value);case`number`:return e.raw;case`boolean`:return String(e.value);case`duration`:return`${e.amount}${e.unit}`;case`timestamp`:return e.value}},cee=e=>e.kind===`number`&&e.raw.startsWith(`-`),nt=e=>{switch(e.kind){case`member`:return e.path.join(`.`);case`call`:return`${e.name}(${e.args.map(rt).join(`, `)})`;case`binary`:if(e.right.kind===`binary`)throw Error(`Arithmetic is left-associative; a binary on the right cannot be printed`);return`${nt(e.left)} ${e.op} ${nt(e.right)}`;default:return see(e)}},rt=e=>lee(e)?`(${st(e)})`:nt(e),it=[`member`,`string`,`number`,`boolean`,`duration`,`timestamp`,`binary`],lee=e=>!it.includes(e.kind)&&e.kind!==`call`,at=e=>{if(cee(e))throw Error(`A negative number cannot start a comparison; "-5 = x" parses as a negation`);return nt(e)},ot=(e,t)=>({and:[`and`,`or`],sequence:[`and`,`or`,`sequence`],or:[`and`,`or`,`sequence`],not:[`and`,`or`,`sequence`,`not`]})[e].includes(t.kind)?`(${st(t)})`:st(t),st=e=>{switch(e.kind){case`and`:return e.args.map(e=>ot(`and`,e)).join(` AND `);case`or`:return e.args.map(e=>ot(`or`,e)).join(` OR `);case`sequence`:return e.args.map(e=>ot(`sequence`,e)).join(` `);case`not`:return`NOT ${ot(`not`,e.arg)}`;case`compare`:return`${at(e.left)} ${e.op} ${nt(e.right)}`;case`has`:return`${at(e.left)}:${nt(e.right)}`;case`present`:return`${at(e.left)}:*`;case`global`:return nt(e.value);case`call`:return nt(e)}},ct=class{int;scale;constructor(e,t){this.int=e,this.scale=t}compare(e){let t=Math.max(this.scale,e.scale),n=this.int*10n**BigInt(t-this.scale),r=e.int*10n**BigInt(t-e.scale);return n<r?-1:+(n>r)}toNumber(){return Number(`${this.int}e-${this.scale}`)}},lt=/^(-?)(\d+)(?:\.(\d+))?$/,ut=e=>{let t=lt.exec(e);if(!t)return;let n=t[3]??``;return new ct(BigInt(`${t[1]}${t[2]}${n}`),n.length)},dt=/^-?(?:\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|0[xX][0-9a-fA-F]+)$/,ft=e=>{if(typeof e==`number`)return e;if(typeof e==`bigint`)return Number(e);if(e instanceof ct)return e.toNumber();if(typeof e==`string`&&dt.test(e))return e.startsWith(`-`)?-Number(e.slice(1)):Number(e)},pt=e=>typeof e==`bigint`?new ct(e,0):typeof e==`number`?Number.isFinite(e)?ut(String(e)):void 0:typeof e==`string`?ut(e):e instanceof ct?e:void 0,mt=(e,t)=>{let n=0,r=0,i=-1,a=0;for(;r<t.length;)if(n<e.length&&e[n]===`*`)i=n++,a=r;else if(n<e.length&&e[n]===t[r])n++,r++;else if(i>=0)n=i+1,r=++a;else return!1;for(;e[n]===`*`;)n++;return n===e.length},ht=e=>typeof e==`object`&&!!e&&!(e instanceof Date)&&!(e instanceof ct)&&`seconds`in e&&typeof e.seconds==`number`,gt=e=>{switch(e.kind){case`string`:return e.value;case`number`:return ut(e.raw)??e.value;case`boolean`:return e.value;case`duration`:return{seconds:e.amount*T[e.unit]};case`timestamp`:return new Date(E(e.value)??NaN)}},_t=e=>ht(e)?e.seconds:typeof e==`number`?e:typeof e==`string`?O(e):void 0,vt=e=>e instanceof Date?e.getTime():typeof e==`string`?E(e):void 0,yt=e=>{switch(e.kind){case`string`:return e.value;case`member`:return e.path.join(`.`);case`number`:return e.raw;case`boolean`:return String(e.value);case`duration`:return`${e.amount}${e.unit}`;case`timestamp`:return e.value;default:return}},bt=(e,t)=>{switch(e){case`=`:return t===0;case`!=`:return t!==0;case`<`:return t<0;case`<=`:return t<=0;case`>`:return t>0;case`>=`:return t>=0}},xt=(e,t)=>e<t?-1:+(e>t),St=(e,t)=>{let n=pt(e),r=pt(t);if(n&&r)return n.compare(r);let i=ft(e),a=ft(t);return i===void 0||a===void 0||Number.isNaN(i)||Number.isNaN(a)?void 0:xt(i,a)},uee=(e,t,n)=>{let r=(e===`=`||e===`!=`)&&n.includes(`*`);if(typeof t==`string`)return r?bt(e,+!mt(n,t)):bt(e,xt(t,n));if(typeof t==`number`||typeof t==`bigint`){let r=St(t,n);return r===void 0?void 0:bt(e,r)}if(t instanceof Date){let r=vt(n);return r===void 0?void 0:bt(e,xt(t.getTime(),r))}if(typeof t==`boolean`)return n===`true`||n===`false`?bt(e,xt(String(t),n)):void 0;if(ht(t)){let r=_t(n);return r===void 0?void 0:bt(e,xt(t.seconds,r))}},Ct=(e,t,n)=>{if(t==null)return!1;if(typeof n==`string`)return uee(e,t,n)??!1;if(n instanceof ct||typeof n==`number`||typeof n==`bigint`){let r=St(t,n);return r!==void 0&&bt(e,r)}if(typeof n==`boolean`){let r=typeof t==`string`?t===`true`||t!==`false`&&void 0:t;return typeof r==`boolean`&&bt(e,xt(String(r),String(n)))}if(n instanceof Date){let r=vt(t);return r===void 0||Number.isNaN(n.getTime())?!1:bt(e,xt(r,n.getTime()))}if(ht(n)){let r=_t(t);return r!==void 0&&bt(e,xt(r,n.seconds))}return!1},wt=(e,t)=>{let n=[e];for(let e of t)n=n.flatMap(t=>Array.isArray(t)?t.flatMap(t=>Tt(t,e)):Tt(t,e));return n.filter(e=>e!=null)},Tt=(e,t)=>typeof e!=`object`||!e?[]:e instanceof Map?e.has(t)?[e.get(t)]:[]:Object.hasOwn(e,t)?[e[t]]:[],Et=e=>e.flatMap(e=>Array.isArray(e)?e:[e]),Dt=32,Ot=(e,t)=>t>Dt||e==null?[]:typeof e==`string`?[e]:typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?[String(e)]:e instanceof Date?[e.toISOString()]:Array.isArray(e)?e.flatMap(e=>Ot(e,t+1)):e instanceof Map?[...e.values()].flatMap(e=>Ot(e,t+1)):typeof e==`object`?Object.values(e).flatMap(e=>Ot(e,t+1)):[],kt=(e,t)=>{let n=e.toLowerCase();return Ot(t,0).some(e=>e.toLowerCase().includes(n))},At=e=>[`member`,`string`,`number`,`boolean`,`duration`,`timestamp`,`call`,`binary`].includes(e.kind),jt=(e,t,n)=>{let r=e===`+`?1:-1;if(t instanceof Date&&ht(n))return new Date(t.getTime()+r*n.seconds*1e3);if(t instanceof Date&&n instanceof Date&&e===`-`)return{seconds:(t.getTime()-n.getTime())/1e3};if(ht(t)&&ht(n))return{seconds:t.seconds+r*n.seconds};let i=t instanceof ct?t.toNumber():t,a=n instanceof ct?n.toNumber():n;return typeof i==`number`&&typeof a==`number`?i+r*a:void 0},Mt=(e,t)=>{let n=t.options.functions?.[e.name];if(!n?.evaluate)throw Error(`Function "${e.name}" has no evaluate implementation`);let r=e.args.map((e,r)=>{let i=n.params[r]??n.rest;return e.kind===`member`&&i?.type===`field`?Et(wt(t.record,e.path)):At(e)?Nt(e,t):It(e,t)});return n.evaluate(...r)},Nt=(e,t)=>{switch(e.kind){case`member`:return e.path.join(`.`);case`call`:return Mt(e,t);case`binary`:return jt(e.op,Nt(e.left,t),Nt(e.right,t));default:return gt(e)}},Pt=(e,t)=>e.kind===`member`?wt(t.record,e.path):[Nt(e,t)],Ft=(e,t,n)=>Et(t).some(t=>Ct(e,t,n)),dee=(e,t)=>{let n=e.kind===`member`?e.field?.spec.type:void 0;return typeof t!=`string`||!n?t:n===`timestamp`?vt(t)===void 0?t:new Date(vt(t)):n===`duration`?_t(t)===void 0?t:{seconds:_t(t)}:n===`integer`||n===`number`?pt(t)??t:n===`boolean`?t===`true`||t!==`false`&&t:t},fee=(e,t)=>{let n=dee(e.left,Nt(e.right,t)),r=Pt(e.left,t);return e.op===`!=`?!Ft(`=`,r,n):Ft(e.op,r,n)},pee=(e,t)=>{let n=Nt(e.right,t),r=yt(e.right);return Pt(e.left,t).some(e=>Array.isArray(e)?e.some(e=>Ct(`=`,e,n)):e instanceof Map?r!==void 0&&e.has(r):typeof e==`object`&&e&&!(e instanceof Date)&&!ht(e)&&!(e instanceof ct)?r!==void 0&&Object.hasOwn(e,r):Ct(`=`,e,n))},It=(e,t)=>{switch(e.kind){case`sequence`:case`and`:return e.args.every(e=>It(e,t));case`or`:return e.args.some(e=>It(e,t));case`not`:return!It(e.arg,t);case`compare`:return fee(e,t);case`has`:return pee(e,t);case`present`:return Pt(e.left,t).some(e=>e!=null);case`global`:return(t.options.search??kt)(yt(e.value)??String(Nt(e.value,t)),t.record);case`call`:return Mt(e,t)===!0}},Lt=(e,t,n={})=>It(e,{record:t,options:n}),Rt=(e,t,n,r)=>({code:e,message:t,hint:n,span:r}),mee=(e,t)=>{let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++){let o=e[r-1]===t[a-1]?0:1;i[a]=Math.min(n[a]+1,i[a-1]+1,n[a-1]+o)}n=i}return n[t.length]},hee=(e,t)=>{let n=e.toLowerCase(),r=t.map(e=>({candidate:e,score:mee(n,e.toLowerCase())})).sort((e,t)=>e.score-t.score)[0];return r&&r.score<=Math.max(2,Math.floor(e.length/3))?r.candidate:void 0},zt={in:{params:[{name:`field`,type:`field`}],rest:{name:`value`,type:`any`}},search:{params:[{name:`text`,type:`string`}]},similar:{params:[{name:`field`,type:`field`,of:[`string`]},{name:`text`,type:`string`}]},regex:{params:[{name:`field`,type:`field`,of:[`string`]},{name:`pattern`,type:`string`}]},isNull:{params:[{name:`field`,type:`field`}]},now:{params:[],returns:`timestamp`}},Bt={extensions:{arithmetic:`now-offset`,durationUnits:!0}},Vt=e=>{switch(e.type){case`text`:return`string`;case`integer`:case`bigint`:return`integer`;case`boolean`:case`timestamp`:case`enum`:return e.type;default:return`any`}},Ht=e=>({fields:Object.fromEntries(Object.values(e.fields).map(e=>[e.name,{type:Vt(e),filterable:e.filterable,sortable:e.sortable,aliases:e.aliases,...e.enumValues&&{values:e.enumValues}}])),functions:zt}),Ut=(e,t,n,r)=>{e.errors.push(Rt(`unsupported`,t,n,r))},Wt=(e,t)=>t.kind===`member`?{kind:`field`,path:t.path,span:t.span}:Ut(e,`Only fields can be compared`,`Put a field name on the left, for example total > 100`,t.span),Gt=(e,t)=>{switch(t.kind){case`member`:return{kind:`string`,value:t.path.join(`.`),span:t.span};case`call`:return t.name===`now`&&t.args.length===0?{kind:`now`,span:t.span}:Ut(e,`${t.name}() cannot be used as a value`,`Only now() is a value function`,t.span);case`binary`:{let n=t.left;return n.kind===`call`&&n.name===`now`&&n.args.length===0&&t.right.kind===`duration`?{kind:`now`,offset:{sign:t.op,duration:t.right},span:t.span}:Ut(e,`Arithmetic is only supported as now() +/- duration`,`Write now() - 30d`,t.span)}default:return t}},Kt=(e,t)=>(`kind`in t&&[`member`,`call`,`binary`].includes(t.kind)?void 0:t)||(t.kind===`member`?{kind:`string`,value:t.path.join(`.`),span:t.span}:Ut(e,`Expected a literal value`,`Use strings, numbers, true/false, durations or timestamps`,t.span)),qt=e=>{switch(e.kind){case`member`:return e.path.join(`.`);case`string`:case`timestamp`:return e.kind,e.value;case`number`:return e.raw;case`boolean`:return String(e.value);case`duration`:return`${e.amount}${e.unit}`;default:return``}},Jt=(e,t)=>{let[n,r,...i]=t.args,a=n?.kind===`member`?Wt(e,n):void 0,o=e=>e?.kind===`string`?e.value:void 0,s=n=>{e.errors.push(Rt(`invalid-arguments`,`Invalid arguments to ${t.name}()`,`Usage: ${n}`,t.span))};switch(t.name){case`in`:{let n=t.args.slice(1).map(t=>Kt(e,t));return!a||n.length===0?s(`in(field, value1, value2, ...)`):n.every(e=>e)?{kind:`in`,field:a,values:n,span:t.span}:void 0}case`search`:return o(n)!==void 0&&!r?{kind:`search`,text:o(n),span:t.span}:s(`search("text")`);case`similar`:return a&&o(r)!==void 0&&i.length===0?{kind:`similar`,field:a,text:o(r),span:t.span}:s(`similar(field, "text")`);case`regex`:return a&&o(r)!==void 0&&i.length===0?{kind:`regex`,field:a,pattern:o(r),span:t.span}:s(`regex(field, "pattern")`);case`isNull`:return a&&!r?{kind:`isNull`,field:a,span:t.span}:s(`isNull(field)`);default:e.errors.push(Rt(`unknown-function`,`Unknown function "${t.name}"`,`Available functions: ${Object.keys(zt).join(`, `)}`,t.span));return}},gee=e=>e.every(e=>e)?e:void 0,Yt=(e,t)=>{switch(t.kind){case`sequence`:case`and`:case`or`:{let n=gee(t.args.map(t=>Yt(e,t)));return n&&{kind:t.kind===`or`?`or`:`and`,args:n,span:t.span}}case`not`:{let n=Yt(e,t.arg);return n&&{kind:`not`,arg:n,span:t.span}}case`compare`:{let n=Wt(e,t.left),r=Gt(e,t.right);return n&&r&&{kind:`compare`,op:t.op,field:n,value:r,span:t.span}}case`has`:{let n=Wt(e,t.left),r=Kt(e,t.right);return n&&r&&{kind:`has`,field:n,value:r,span:t.span}}case`present`:{let n=Wt(e,t.left);return n&&{kind:`present`,field:n,span:t.span}}case`global`:return{kind:`search`,text:qt(t.value),span:t.span};case`call`:return Jt(e,t)}},Xt=(e,t={})=>{let n=Re(e,{...Bt,...t}),r={errors:[]},i=n.ast&&Yt(r,n.ast),a=[...n.errors,...r.errors].sort((e,t)=>e.span.start-t.span.start);return a.length===0?{ok:!0,ast:i,errors:[]}:{ok:!1,ast:i,errors:a}},_ee=(e,t)=>t===2?e%4==0&&(e%100!=0||e%400==0)?29:28:[4,6,9,11].includes(t)?30:31,Zt=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return r>=1&&r<=12&&i>=1&&i<=_ee(n,r)},vee=e=>{let t=/^(\d{4}-\d{2}-\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|[+-](\d{2}):(\d{2}))$/.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[2]),Number(t[3]),Number(t[4])],[a,o]=[Number(t[5]??0),Number(t[6]??0)];return Zt(t[1])&&n<=23&&r<=59&&i<=59&&a<=23&&o<=59},Qt=(e,t)=>({message:e,hint:t}),yee=-(2n**63n),bee=2n**63n-1n,xee=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,$t=e=>e.kind===`number`?e.raw:e.kind===`string`?e.value:void 0,en=(e,t=`Write ${e} values like the examples in the docs`)=>Qt(`Expected ${e}`,t),tn=e=>{let t=$t(e),n=t===void 0?NaN:Number(t);if(t===void 0||t.trim()===``||!Number.isSafeInteger(n))return en(`a whole number`,`Use an integer such as 42, or a bigint field for larger values`)},nn=e=>{let t=$t(e);if(t===void 0||!/^-?\d+$/.test(t)||BigInt(t)<yee||BigInt(t)>bee)return en(`a 64-bit integer`,`Use plain digits such as 9007199254740993 (no exponent or fraction)`)},rn=e=>{let t=$t(e);if(t===void 0||!/^-?\d+(\.\d+)?$/.test(t))return en(`a decimal number`,`Use plain digits such as 100.50, or quote it: "100.50" (no exponent)`)},an=(e,t)=>{if(t.kind===`now`)return e.type===`date`||e.type===`timestamp`?void 0:Qt(`now() only works with date and timestamp fields`,`Field "${e.name}" is ${e.type}`);switch(e.type){case`text`:return t.kind===`string`?void 0:en(`a quoted string`,`Wrap the text in double quotes`);case`integer`:return tn(t);case`bigint`:return nn(t);case`decimal`:return rn(t);case`boolean`:return t.kind===`boolean`?void 0:en(`true or false`);case`date`:return t.kind===`string`&&Zt(t.value)?void 0:en(`a date`,`Quote a calendar date: "2012-04-21"`);case`timestamp`:return t.kind===`timestamp`||t.kind===`string`&&vee(t.value)?void 0:en(`an RFC-3339 timestamp`,`Use 2012-04-21T11:30:00Z, or now() - 7d`);case`uuid`:return t.kind===`string`&&xee.test(t.value)?void 0:en(`a uuid`,`Quote a uuid like "0b5a4f0e-6f2a-4a3c-9d4e-1f2a3b4c5d6e"`);case`enum`:return t.kind===`string`&&e.enumValues?.includes(t.value)?void 0:Qt(`Invalid enum value`,`Allowed values: ${(e.enumValues??[]).join(`, `)}`);case`currency`:return t.kind===`string`&&/^[A-Z]{3}$/.test(t.value)?void 0:en(`an ISO 4217 currency code`,`Use three capital letters, for example "EUR"`);case`country`:return t.kind===`string`&&/^[A-Z]{2}$/.test(t.value)?void 0:en(`an ISO 3166-1 country code`,`Use two capital letters, for example "NL"`);case`relation`:return t.kind===`string`||t.kind===`number`&&Number.isSafeInteger(t.value)?void 0:en(`a record key`,`Use the related record key: 42 or "abc"`);case`json`:case`file`:return Qt(`${e.type} fields cannot be compared`,`Use field:value on json fields, or isNull(field)`)}},on=(e,t)=>Object.hasOwn(e.fields,t)?e.fields[t]:Object.values(e.fields).find(e=>e.aliases.includes(t)),sn=(e,t,n)=>{if(t.path.length>1){e.errors.push(Rt(`unsupported-traversal`,`Traversal into "${t.path.join(`.`)}" is not supported yet`,`Filter on fields of this resource only`,t.span));return}let r=t.path[0],i=on(e.model,r);if(!i){let i=Object.values(e.model.fields).filter(e=>e[n]).map(e=>e.name),a=hee(r,i);e.errors.push(Rt(`unknown-field`,`Unknown field "${r}"`,a?`Did you mean "${a}"?`:`Available fields: ${i.join(`, `)}`,t.span));return}if(!i[n]){let r=n===`filterable`?`filterable`:`sortable`;e.errors.push(Rt(n===`filterable`?`not-filterable`:`not-sortable`,`Field "${i.name}" is not ${r}`,`Mark it with .${r}() in data.ts`,t.span));return}return i},cn=[`=`,`!=`],ln=[`=`,`!=`,`<`,`<=`,`>`,`>=`],un=e=>{switch(e){case`text`:case`integer`:case`bigint`:case`decimal`:case`date`:case`timestamp`:return ln;case`json`:case`file`:return[];default:return cn}},dn=e=>e===`json`||e===`file`,fn=(e,t,n)=>{let r=an(t,n);return r&&e.errors.push(Rt(`invalid-value`,r.message,r.hint,n.span)),!r},pn=(e,t,n,r)=>{e.errors.push(Rt(`operator-not-allowed`,t,n,r))},mn=(e,t)=>(e===`=`||e===`!=`)&&t.kind===`string`&&t.value.includes(`*`),hn=(e,t)=>{let n=sn(e,t.field,`filterable`);if(!n)return;let r=un(n.type);if(!r.includes(t.op)){pn(e,`Operator "${t.op}" is not supported for ${n.type} fields`,r.length?`Supported: ${r.join(` `)}`:`Use field:value on json fields, or isNull(field)`,t.span);return}if(mn(t.op,t.value)&&n.type!==`text`){e.errors.push(Rt(`wildcard-not-allowed`,`Wildcards are only supported on text fields, not ${n.type}`,`Remove the "*" or filter a text field`,t.value.span));return}if(mn(t.op,t.value)||fn(e,n,t.value))return{...t,field:n}},gn=(e,t)=>{let n=sn(e,t.field,`filterable`);if(n){if(n.type!==`json`){pn(e,`":" is only supported on json fields, not ${n.type}`,`Use = on ${n.type} fields, or field:* to test for a value`,t.span);return}return{...t,field:n}}},_n=(e,t)=>{let n=sn(e,t.field,`filterable`);if(n){if(dn(n.type)){pn(e,`in() is not supported for ${n.type} fields`,`Use field:value on json fields`,t.span);return}return t.values.map(t=>fn(e,n,t)).every(Boolean)?{...t,field:n}:void 0}},vn=(e,t,n)=>{let r=sn(e,n,`filterable`);if(r&&r.type!==`text`){pn(e,`${t}() only works on text fields, not ${r.type}`,`Field "${r.name}" is ${r.type}`,n.span);return}return r},yn=(e,t)=>{switch(t.kind){case`and`:case`or`:{let n=t.args.map(t=>yn(e,t));return n.every(e=>e)?{...t,args:n}:void 0}case`not`:{let n=yn(e,t.arg);return n&&{...t,arg:n}}case`compare`:return hn(e,t);case`has`:return gn(e,t);case`in`:return _n(e,t);case`search`:if(e.model.search?.length)return t;e.errors.push(Rt(`no-search-fields`,`This resource has no search fields`,`Declare them with .search((r) => [r.title]) in data.ts`,t.span));return;case`present`:case`isNull`:{let n=sn(e,t.field,`filterable`);return n&&{...t,field:n}}case`similar`:case`regex`:{let n=vn(e,t.kind,t.field);return n&&{...t,field:n}}}},bn=(e,t)=>{let n={model:e,errors:[]},r=yn(n,t);return!r||n.errors.length>0?{ok:!1,errors:[...n.errors].sort((e,t)=>e.span.start-t.span.start)}:{ok:!0,filter:r}},xn=(e,t)=>`path`in e?{kind:`member`,path:e.path,span:e.span}:{kind:`member`,path:[e.name],field:{name:e.name,spec:{type:Vt(e)}},span:t},Sn=(e,t,n)=>({kind:`call`,name:e,args:t,span:n}),Cn=(e,t)=>({kind:`string`,value:e,span:t}),wn=e=>{if(e.kind!==`now`)return e;let t={kind:`call`,name:`now`,args:[],span:e.span};return e.offset?{kind:`binary`,op:e.offset.sign,left:t,right:e.offset.duration,span:e.span}:t},Tn=(e,t={})=>{let n=e=>Tn(e,t);switch(e.kind){case`and`:case`or`:return{kind:e.kind,args:e.args.map(n),span:e.span};case`not`:return{kind:`not`,arg:n(e.arg),span:e.span};case`compare`:return{kind:`compare`,op:e.op,left:xn(e.field,e.span),right:wn(e.value),span:e.span};case`has`:return{kind:`has`,left:xn(e.field,e.span),right:e.value,span:e.span};case`present`:return{kind:`present`,left:xn(e.field,e.span),span:e.span};case`in`:return t.expand?{kind:`or`,args:e.values.map(t=>({kind:`compare`,op:`=`,left:xn(e.field,e.span),right:t,span:e.span})),span:e.span}:Sn(`in`,[xn(e.field,e.span),...e.values],e.span);case`search`:return Sn(`search`,[Cn(e.text,e.span)],e.span);case`similar`:return Sn(`similar`,[xn(e.field,e.span),Cn(e.text,e.span)],e.span);case`regex`:return Sn(`regex`,[xn(e.field,e.span),Cn(e.pattern,e.span)],e.span);case`isNull`:return t.expand?{kind:`not`,arg:{kind:`present`,left:xn(e.field,e.span),span:e.span},span:e.span}:Sn(`isNull`,[xn(e.field,e.span)],e.span)}},En=(e,t)=>{let n=bn(e,t);if(!n.ok&&n.errors.some(e=>e.code===`unsupported-traversal`))return n;let r=et(Tn(t),Ht(e));return r.ok?bn(e,t):{ok:!1,errors:r.errors}},Dn=/^[\d\s+\-().\/]+$/,On=e=>Dn.test(e)?e.replace(/\D/g,``):``,kn=e=>{let t=e.split(/\s+/).filter(Boolean).map(e=>({text:e,digits:On(e),whole:!1})),n=t.length>1?On(e.trim()):``;return n?[{text:e.trim(),digits:n,whole:!0},...t]:t},An=(e,t,n)=>e==null?!1:n===`digitsEnd`?t.digits!==``&&String(e).replace(/\D/g,``).endsWith(t.digits):!t.whole&&String(e).toLowerCase().includes(t.text.toLowerCase()),jn=(e,t,n)=>(e.search??[]).filter(r=>An(t[r],n,e.searchMatch?.[r])),Mn=(e,t,n)=>{let r=kn(n),i=r.filter(e=>!e.whole),a=r.find(e=>e.whole);return a&&jn(e,t,a).length>0?!0:i.length>0&&i.every(n=>jn(e,t,n).length>0)},Nn=(e,t,n,r)=>{for(let i of kn(n)){let n=jn(e,t,i);if(n.length>0&&!n.some(e=>r.includes(e)))return n[0]}},Pn=e=>()=>{throw Error(`Not implemented: ${e}() needs the database (the resource's search fields, trigram matching), so it cannot be evaluated against a record`)},See=(e,t,n)=>({...zt,search:{...zt.search,evaluate:n?e=>Mn(n,t,e):Pn(`search`)},similar:{...zt.similar,evaluate:Pn(`similar`)},regex:{...zt.regex,evaluate:(e,t)=>e.some(e=>typeof e==`string`&&new RegExp(t).test(e))},now:{...zt.now,evaluate:e}}),Cee=(e,t,n={})=>Lt(Tn(e,{expand:!0}),t,{functions:See(n.now??(()=>new Date),t,n.search)}),Fn=e=>st(Tn(e)),wee=e=>{let t=[];for(let n of e.matchAll(/,|\.|[^\s,.]+/g)){let e=n.index,r=n[0]===`,`?`comma`:n[0]===`.`?`dot`:`word`;t.push({kind:r,text:n[0],span:{start:e,end:e+n[0].length}})}return t},Tee=e=>{let t=wee(e),n=[],r=[],i={start:e.length,end:e.length},a=0,o=(e,t,r,i)=>n.push(v(e,t,r,i)),s=()=>{for(;a<t.length&&t[a].kind!==`comma`;)a++;a++},c=()=>{let e=t[a];if(!e||e.kind!==`word`)return o(`expected-field`,`Expected a field name but found ${e?`"${e.text}"`:`end of input`}`,`Write order_by like: createdAt desc, total`,e?.span??i),!1;let n=[e.text],s=e;for(a++;t[a]?.kind===`dot`;){let e=t[a+1];if(e?.kind!==`word`)return o(`expected-field`,`Expected a field name after "."`,`Write subfields like address.street`,e?.span??i),!1;n.push(e.text),s=e,a+=2}let c=t[a],l=`asc`;if(c?.kind===`word`){if(c.text!==`asc`&&c.text!==`desc`)return o(`unexpected-token`,`Expected "desc" or "," but found "${c.text}"`,`Separate fields with commas; append " desc" for descending order`,c.span),!1;l=c.text,s=c,a++}let u=t[a];return u&&u.kind!==`comma`?(o(`unexpected-token`,`Expected "," but found "${u.text}"`,`Separate fields with commas`,u.span),!1):(r.push({path:n,direction:l,span:{start:e.span.start,end:s.span.end}}),!0)};for(;a<t.length;){if(!c()){s();continue}t[a]?.kind===`comma`&&(a++,a>=t.length&&o(`expected-field`,`Expected a field name after ","`,`Remove the trailing comma`,i))}return n.length===0?{ok:!0,items:r,errors:[]}:{ok:!1,items:r,errors:n}},In=(e,t)=>{if(Object.hasOwn(e,t))return{name:t,field:e[t]};let n=Object.entries(e).find(([,e])=>e.aliases?.includes(t));return n&&{name:n[0],field:n[1]}},Eee=(e,t)=>{let n=[],r=[];for(let i of e){let e=In(t.fields,i.path[0]);if(!e){let e=Object.entries(t.fields).filter(([,e])=>e.sortable!==!1).map(([e])=>e),r=b(i.path[0],e);n.push(v(`unknown-field`,`Unknown field "${i.path[0]}"`,r?`Did you mean "${r}"?`:`Available fields: ${e.join(`, `)}`,i.span));continue}let a=[e.name],o=e.field,s=o.sortable!==!1,c=!1;for(let e of i.path.slice(1)){let t=o.fields?In(o.fields,e)?.field:o.value;if(!t){n.push(v(`invalid-traversal`,`Cannot sort by "${e}" inside "${a.join(`.`)}"`,`Only nested message fields and map values can be traversed`,i.span)),c=!0;break}a.push(o.fields?In(o.fields,e).name:e),o=t,s&&=o.sortable!==!1}if(!c){if(!s){n.push(v(`not-sortable`,`Field "${a.join(`.`)}" cannot be sorted on`,`Mark it sortable in the schema`,i.span));continue}r.push({...i,path:a})}}return n.length===0?{ok:!0,items:r}:{ok:!1,errors:n}},Dee=e=>e.map(e=>({path:e.path.path,direction:e.direction,span:e.span})),Oee=e=>e.replace(/([^\s,])(\s+)(asc|desc)(?=\s|,|$)/gi,(e,t,n,r)=>`${t}${n}${r.toLowerCase()}`),kee=e=>{let t=Tee(Oee(e)),n=t.items.map(e=>({path:{kind:`field`,path:e.path,span:e.span},direction:e.direction,span:e.span}));return t.ok?{ok:!0,items:n,errors:[]}:{ok:!1,items:n,errors:t.errors}},Aee=(e,t)=>{let n=t.filter(e=>e.path.path.length>1).map(e=>Rt(`unsupported-traversal`,`Traversal into "${e.path.path.join(`.`)}" is not supported yet`,`Sort on fields of this resource only`,e.path.span));if(n.length>0)return{ok:!1,errors:n};let r=Eee(Dee(t),Ht(e));return r.ok?{ok:!0,sort:r.items.map(e=>[e.path[0],e.direction])}:{ok:!1,errors:r.errors}},jee=e=>{let t=/^(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)([smhdw])$/.exec(e);if(!t)throw Error(`Invalid duration "${e}", expected for example 30d or 1.5h`);return{kind:`duration`,amount:Number(t[1]),unit:t[2],span:{start:0,end:0}}},Ln={start:0,end:0},Rn=e=>({kind:`field`,path:e.split(`.`),span:Ln}),zn=e=>{if(typeof e==`string`)return{kind:`string`,value:e,span:Ln};if(typeof e==`boolean`)return{kind:`boolean`,value:e,span:Ln};if(!Number.isFinite(e))throw Error(`Filter numbers must be finite`);return{kind:`number`,value:e,raw:String(e),span:Ln}},Mee=e=>typeof e==`object`?e:zn(e),Bn=(e,t)=>{if(t.length===0)throw Error(`where.${e} needs at least one filter`);return t.length===1?t[0]:{kind:e,args:t,span:Ln}},Vn=()=>{let e=e=>(t,n)=>({kind:`compare`,op:e,field:Rn(t),value:Mee(n),span:Ln}),t=e=>t=>({kind:`now`,offset:{sign:e,duration:jee(t)},span:Ln});return{eq:e(`=`),ne:e(`!=`),lt:e(`<`),lte:e(`<=`),gt:e(`>`),gte:e(`>=`),between:(t,n,r)=>Bn(`and`,[e(`>=`)(t,n),e(`<=`)(t,r)]),has:(e,t)=>({kind:`has`,field:Rn(e),value:zn(t),span:Ln}),present:e=>({kind:`present`,field:Rn(e),span:Ln}),in:(e,t)=>({kind:`in`,field:Rn(e),values:t.map(zn),span:Ln}),isNull:e=>({kind:`isNull`,field:Rn(e),span:Ln}),search:e=>({kind:`search`,text:e,span:Ln}),similar:(e,t)=>({kind:`similar`,field:Rn(e),text:t,span:Ln}),regex:(e,t)=>({kind:`regex`,field:Rn(e),pattern:t,span:Ln}),and:(...e)=>Bn(`and`,e),or:(...e)=>Bn(`or`,e),not:e=>({kind:`not`,arg:e,span:Ln}),now:()=>({kind:`now`,span:Ln}),ago:t(`-`),fromNow:t(`+`)}},Hn=Vn(),Un=/\{([A-Za-z_][A-Za-z0-9_]*)\}/g,Nee=e=>[...e.matchAll(Un)].map(e=>e[1]),Pee=e=>e.kind===`record`?(Array.isArray(e.key)?e.key:[e.key]).filter(e=>typeof e==`string`):e.kind===`list`?[e.filter,e.orderBy].filter(e=>e!==void 0):e.kind===`create`?Object.values(e.values??{}):[],Wn=e=>[...new Set(Pee(e).flatMap(Nee))],Gn=(e,t)=>e.replace(Un,(e,n)=>t[n]===null||t[n]===void 0?``:String(t[n])),Kn=(e,t={})=>{if(e.kind===`record`){let n=e=>typeof e==`string`?Gn(e,t):e;return{...e,key:Array.isArray(e.key)?e.key.map(n):n(e.key)}}return e.kind===`create`?e.values?{...e,values:Object.fromEntries(Object.entries(e.values).map(([e,n])=>[e,Gn(n,t)]))}:e:e.kind===`list`?{...e,...e.filter!==void 0&&{filter:Gn(e.filter,t)},...e.orderBy!==void 0&&{orderBy:Gn(e.orderBy,t)}}:e},qn=e=>/^\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(e)?.[1],Fee=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===1&&typeof e.$field==`string`,Iee=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Jn=e=>Fee(e)?e.$field:Array.isArray(e)?e.map(Jn):Iee(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Jn(t)])):e,Yn=`table`,Xn=/^[a-z0-9][a-z0-9_-]*$/,Zn=e=>{if(!e.startsWith(`/-/forms/`))return;let t=e.slice(9);return Xn.test(t)?{name:t}:void 0},Qn=e=>e.flatMap(e=>e.kind===`group`||e.kind===`tab`?Qn(e.items):[e]),$n=(e,t)=>{if(t===void 0)return e;let n=e?.lists?.find(e=>e.name===t);if(!e||!n)return;let{list:r,chart:i,help:a,nav:o,lists:s,names:c,...l}=e,{name:u,...d}=n;return{...l,...d}},er={text:`text`,integer:`integer`,decimal:`decimal`,boolean:`boolean`,date:`date`,choice:`text`,custom:`json`},tr=e=>({name:e.name,column:e.name,type:e.options?`enum`:er[e.kind],nullable:!0,readOnly:!1,filterable:e.kind!==`custom`,sortable:!1,aliases:[],...e.options&&{enumValues:e.options.map(e=>e.value)}}),nr=e=>({name:`inputs`,table:{name:`inputs`},fields:Object.fromEntries(e.map(e=>[e.name,tr(e)])),primaryKey:[]}),rr=(e,t)=>{let n=e[t].when;if(n===void 0)return;let r=Xt(n);if(!r.ok)return r.errors.map(e=>e.message).join(`; `);if(!r.ast)return`it is empty`;let i=En(nr(e.slice(0,t)),r.ast);return i.ok?i.filter:i.errors.map(e=>e.message).join(`; `)},ir=(e,t)=>{let n=new Set,r={};return e.forEach((i,a)=>{let o=rr(e,a);if(typeof o==`string`)throw Error(`Input "${i.name}": ${o}`);let s=o===void 0||Cee(o,r)===!0;s&&n.add(i.name),r[i.name]=s?t[i.name]??null:null}),n},ar=(e,t)=>Object.fromEntries(Object.entries(e).flatMap(([e,n])=>{let r=typeof n==`string`?qn(n):void 0;return r===void 0?[[e,n]]:Object.hasOwn(t,r)?[[e,t[r]]]:[]})),or=e=>`groupBy`in e,sr=e=>{if(!Array.isArray(e))return String(e);let t=e;return t.length===1?String(t[0]):t.map(e=>encodeURIComponent(String(e))).join(`,`)},cr=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/,lr=e=>{let t=cr.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:void 0},ur=(e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2],dr=/^(>=|<=|>|<|=)?(.+)$/,fr={">=":e=>e>=0,"<=":e=>e<=0,">":e=>e>0,"<":e=>e<0,"=":e=>e===0},pr=(e,t)=>{let n=lr(e),r=t.trim().split(/\s+/);if(!n||t.trim()===``)return;let i=!0;for(let e of r){let[,t=`=`,r=``]=dr.exec(e)??[],a=lr(r);if(!a)return;i&&=fr[t](ur(n,a))}return i},mr=(e,t)=>{if(e.api!==t.api)return`it is built for plugin API ${e.api}, and this app has plugin API ${t.api}`;let n=pr(t.version,e.protobase);if(n===void 0)return`its Protobase range "${e.protobase}" is not one this app reads, such as >=0.12.0`;if(!n)return`it needs Protobase ${e.protobase}, and this app runs ${t.version}`},hr=`[Filtered]`,gr=/authorization|cookie|passw|secret|token|api[-_]?key|credential|session|csrf|signature|^sig$/i,_r=new Set([`url`,`query_string`,`from`,`to`]),vr=12,yr=e=>e.replace(/(^|&)([^=&]*)=([^&]*)/g,(e,t,n)=>gr.test(n)?`${t}${n}=${hr}`:e),br=e=>{let t=e.indexOf(`?`);if(t===-1)return e;let n=e.indexOf(`#`,t),r=n===-1?e.slice(t+1):e.slice(t+1,n);return`${e.slice(0,t+1)}${yr(r)}${n===-1?``:e.slice(n)}`},xr=(e,t,n)=>gr.test(e)?hr:typeof t==`string`&&_r.has(e)?e===`query_string`?yr(t):br(t):Sr(t,n+1),Sr=(e,t)=>t>vr||typeof e!=`object`||!e?e:Array.isArray(e)?e.map(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`?[e[0],xr(e[0],e[1],t)]:Sr(e,t+1)):Object.fromEntries(Object.entries(e).map(([e,n])=>[e,xr(e,n,t)])),Cr=e=>Sr(e,0),wr=[`unknown-field`,`not-filterable`,`not-sortable`,`unsupported-traversal`,`invalid-traversal`],Tr=e=>e.replace(/(["']?)\{[A-Za-z_][A-Za-z0-9_]*\}\1/g,(e,t)=>t?`${t}x${t}`:`0`),Er=(e,t)=>{let n=Xt(Tr(t));if(!n.ok)return n.errors.map(e=>`filter: ${e.message}`);if(!n.ast)return[];let r=En(e,n.ast);return r.ok?[]:r.errors.filter(e=>wr.includes(e.code)).map(e=>`filter: ${e.message}`)},Dr=(e,t)=>{if(Wn({kind:`list`,resource:e.name,orderBy:t}).length>0)return[];let n=kee(t);if(!n.ok)return n.errors.map(e=>`orderBy: ${e.message}`);let r=Aee(e,n.items);return r.ok?[]:r.errors.map(e=>`orderBy: ${e.message}`)},Or=(e,{models:t,pages:n,source:r,createPages:i})=>{let a=Wn(e).flatMap(e=>r?Object.hasOwn(r.fields,e)?[]:[`"{${e}}" is not a field of ${r.name}`]:[`"{${e}}" takes a value from the record, but the link sits on none`]);switch(e.kind){case`page`:return n&&!n.has(e.page)?[`unknown page "${e.page}"`]:[];case`list`:case`record`:case`create`:{let n=Object.hasOwn(t,e.resource)?t[e.resource]:void 0;return n?e.kind===`create`&&i?.has(e.resource)?a:e.kind===`create`?[...a,...Object.keys(e.values??{}).filter(e=>!Object.hasOwn(n.fields,e)).map(t=>`values: unknown field "${t}" on ${e.resource}`)]:e.kind===`list`?[...a,...e.filter?Er(n,e.filter):[],...e.orderBy?Dr(n,e.orderBy):[]]:a:[`unknown resource "${e.resource}"`]}default:return[`an address's kind is list, record, create or page, not "${String(e.kind)}"`]}},kr={messages:[],replying:!1},Ar=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);return n===-1?[...e,t]:e.map((e,r)=>r===n?t:e)},jr=(e,t,n)=>{let r=e.find(e=>e.id===t);return Ar(e,r?{...r,parts:Ar(r.parts,n)}:{id:t,from:`assistant`,parts:[n]})},Mr=(e,t)=>{switch(t.type){case`state`:return t.state;case`message`:return{...e,messages:Ar(e.messages,t.message)};case`part`:return{...e,messages:jr(e.messages,t.messageId,t.part)};case`patch`:{let{replying:n=e.replying,status:r=e.status,placeholder:i=e.placeholder}=t;return{messages:e.messages,replying:n,...r!=null&&{status:r},...i!=null&&{placeholder:i}}}}},Nr=async(e,t,n)=>{let r=new TextDecoder,i=e.getReader();n?.addEventListener(`abort`,()=>void i.cancel(),{once:!0});let a=``,o=[],s=e=>{if(e===``){o.length>0&&t(o.join(`
|
|
4
4
|
`)),o=[];return}e.startsWith(`data:`)&&o.push(e.slice(e.startsWith(`data: `)?6:5))};for(;;){let{done:e,value:t}=await i.read();a+=e?r.decode():r.decode(t,{stream:!0});let n=a.split(/\r\n|\r|\n/);if(a=e?``:n.pop()??``,n.forEach(s),e)return s(``)}},Pr={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};Pr.node;var Fr=d(Pr),Ir={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};Ir.node;var Lr=d(Ir),Rr={name:`arrow-right-left`,size:24,node:[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]};Rr.node;var zr=d(Rr),Br={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Br.node;var Vr=d(Br),Hr={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};Hr.node;var Ur=d(Hr),Wr={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};Wr.node;var Gr=d(Wr),Kr={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};Kr.node;var qr=d(Kr),Jr={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};Jr.node;var Yr=d(Jr),Xr={name:`bath`,size:24,node:[[`path`,{d:`M10 4 8 6`,key:`1rru8s`}],[`path`,{d:`M17 19v2`,key:`ts1sot`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`M7 19v2`,key:`12npes`}],[`path`,{d:`M9 5 7.621 3.621A2.121 2.121 0 0 0 4 5v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5`,key:`14ym8i`}]]};Xr.node;var Zr=d(Xr),Qr={name:`bed`,size:24,node:[[`path`,{d:`M2 4v16`,key:`vw9hq8`}],[`path`,{d:`M2 8h18a2 2 0 0 1 2 2v10`,key:`1dgv2r`}],[`path`,{d:`M2 17h20`,key:`18nfp3`}],[`path`,{d:`M6 8v9`,key:`1yriud`}]]};Qr.node;var $r=d(Qr),ei={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};ei.node;var ti=d(ei),ni={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};ni.node;var ri=d(ni),ii={name:`bookmark-check`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}],[`path`,{d:`m9 10 2 2 4-4`,key:`1gnqz4`}]]};ii.node;var ai=d(ii),oi={name:`bookmark-plus`,size:24,node:[[`path`,{d:`M12 7v6`,key:`lw1j43`}],[`path`,{d:`M15 10H9`,key:`o6yqo3`}],[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};oi.node;var si=d(oi),ci={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};ci.node;var li=d(ci),ui={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};ui.node;var Lee=d(ui),di={name:`boxes`,size:24,node:[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]};di.node;var fi=d(di),pi={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};pi.node;var mi=d(pi),hi={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};hi.node;var gi=d(hi),_i={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};_i.node;var Ree=d(_i),vi={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};vi.node;var zee=d(vi),yi={name:`chart-gantt`,size:24,node:[[`path`,{d:`M10 6h8`,key:`zvc2xc`}],[`path`,{d:`M12 16h6`,key:`yi5mkt`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M8 11h7`,key:`wz2hg0`}]]};yi.node;var Bee=d(yi),bi={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};bi.node;var xi=d(bi),Si={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};Si.node;var Ci=d(Si),wi={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};wi.node;var Ti=d(wi),Ei={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Ei.node;var Di=d(Ei),Oi={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};Oi.node;var ki=d(Oi),Ai={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Ai.node;var Vee=d(Ai),ji={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};ji.node;var Hee=d(ji),Mi={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};Mi.node;var Uee=d(Mi),Ni={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};Ni.node;var Wee=d(Ni),Pi={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Pi.node;var Gee=d(Pi),Fi={name:`columns-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]],aliases:[`panels-left-right`]};Fi.node;var Kee=d(Fi),Ii={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};Ii.node;var Li=d(Ii),Ri={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};Ri.node;var qee=d(Ri),zi={name:`credit-card`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}],[`path`,{d:`M6 14h2`,key:`mk7k0u`}]]};zi.node;var Bi=d(zi),Vi={name:`door-open`,size:24,node:[[`path`,{d:`M10 21H2`,key:`1sthdo`}],[`path`,{d:`M10 3H7a2 2 0 00-2 2v16`,key:`15gt7x`}],[`path`,{d:`M14 12h.01`,key:`1jfl7z`}],[`path`,{d:`M19 21V5a2 2 0 00-1.675-1.974l-6.163-1.013A1 1 0 0010 3v18a1 1 0 001.124.992z`,key:`tyvg9a`}],[`path`,{d:`M22 21h-3`,key:`1ec3tr`}]]};Vi.node;var Jee=d(Vi),Hi={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};Hi.node;var Ui=d(Hi),Wi={name:`earth`,size:24,node:[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]],aliases:[`globe-2`]};Wi.node;var Yee=d(Wi),Gi={name:`ellipsis-vertical`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]],aliases:[`more-vertical`]};Gi.node;var Xee=d(Gi),Ki={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Ki.node;var qi=d(Ki),Ji={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};Ji.node;var Yi=d(Ji),Xi={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Xi.node;var Zee=d(Xi),Zi={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Zi.node;var Qee=d(Zi),Qi={name:`file-code-corner`,size:24,node:[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]],aliases:[`file-code-2`]};Qi.node;var $ee=d(Qi),$i={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};$i.node;var ete=d($i),ea={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};ea.node;var ta=d(ea),na={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};na.node;var ra=d(na),ia={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};ia.node;var tte=d(ia),aa={name:`heart`,size:24,node:[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]};aa.node;var oa=d(aa),sa={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};sa.node;var ca=d(sa),la={name:`images`,size:24,node:[[`path`,{d:`m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16`,key:`9kzy35`}],[`path`,{d:`M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2`,key:`1t0f0t`}],[`circle`,{cx:`13`,cy:`7`,r:`1`,fill:`currentColor`,key:`1obus6`}],[`rect`,{x:`8`,y:`2`,width:`14`,height:`14`,rx:`2`,key:`1gvhby`}]]};la.node;var nte=d(la),ua={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};ua.node;var rte=d(ua),da={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};da.node;var fa=d(da),pa={name:`land-plot`,size:24,node:[[`path`,{d:`m12 8 6-3-6-3v10`,key:`mvpnpy`}],[`path`,{d:`m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12`,key:`ek95tt`}],[`path`,{d:`m6.49 12.85 11.02 6.3`,key:`1kt42w`}],[`path`,{d:`M17.51 12.85 6.5 19.15`,key:`v55bdg`}]]};pa.node;var ite=d(pa),ma={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};ma.node;var ha=d(ma),ga={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};ga.node;var _a=d(ga),va={name:`leaf`,size:24,node:[[`path`,{d:`M11 20a10 10 0 0010-10 25.9 25.9 0 00-1.04-7.281 1 1 0 00-1.755-.325C15.833 5.5 13 5.5 9.8 6.1A7 7 0 0011 20`,key:`1wjnjv`}],[`path`,{d:`M2 21a5 5 0 012.911-4.544C7.613 15.212 8.351 15.24 11 13`,key:`c1ejpn`}]]};va.node;var ya=d(va),ba={name:`life-buoy`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.93 4.93 4.24 4.24`,key:`1ymg45`}],[`path`,{d:`m14.83 9.17 4.24-4.24`,key:`1cb5xl`}],[`path`,{d:`m14.83 14.83 4.24 4.24`,key:`q42g0n`}],[`path`,{d:`m9.17 14.83-4.24 4.24`,key:`bqpfvv`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]};ba.node;var xa=d(ba),Sa={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};Sa.node;var Ca=d(Sa),wa={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};wa.node;var ate=d(wa),Ta={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};Ta.node;var ote=d(Ta),Ea={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};Ea.node;var ste=d(Ea),Da={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};Da.node;var Oa=d(Da),ka={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};ka.node;var Aa=d(ka),ja={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};ja.node;var Ma=d(ja),Na={name:`map`,size:24,node:[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]};Na.node;var Pa=d(Na),Fa={name:`memory-stick`,size:24,node:[[`path`,{d:`M12 12v-2`,key:`fwoke6`}],[`path`,{d:`M12 18v-2`,key:`qj6yno`}],[`path`,{d:`M16 12v-2`,key:`heuere`}],[`path`,{d:`M16 18v-2`,key:`s1ct0w`}],[`path`,{d:`M2 11h1.5`,key:`15p63e`}],[`path`,{d:`M20 18v-2`,key:`12ehxp`}],[`path`,{d:`M20.5 11H22`,key:`khsy7a`}],[`path`,{d:`M4 18v-2`,key:`1c3oqr`}],[`path`,{d:`M8 12v-2`,key:`1mwtfd`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`rect`,{x:`2`,y:`6`,width:`20`,height:`10`,rx:`2`,key:`1qcswk`}]]};Fa.node;var Ia=d(Fa),La={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};La.node;var Ra=d(La),za={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};za.node;var Ba=d(za),Va={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Va.node;var Ha=d(Va),Ua={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};Ua.node;var cte=d(Ua),Wa={name:`network`,size:24,node:[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]};Wa.node;var Ga=d(Wa),Ka={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};Ka.node;var qa=d(Ka),Ja={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};Ja.node;var Ya=d(Ja),Xa={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};Xa.node;var Za=d(Xa),Qa={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Qa.node;var lte=d(Qa),$a={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};$a.node;var eo=d($a),to={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};to.node;var no=d(to),ro={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};ro.node;var io=d(ro),ao={name:`puzzle`,size:24,node:[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]};ao.node;var oo=d(ao),so={name:`receipt`,size:24,node:[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};so.node;var co=d(so),lo={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};lo.node;var uo=d(lo),fo={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};fo.node;var po=d(fo),mo={name:`ruler-dimension-line`,size:24,node:[[`path`,{d:`M10 15v-3`,key:`1pjskw`}],[`path`,{d:`M14 15v-3`,key:`1o1mqj`}],[`path`,{d:`M18 15v-3`,key:`cws6he`}],[`path`,{d:`M2 8V4`,key:`3jv1jz`}],[`path`,{d:`M22 6H2`,key:`1iqbfk`}],[`path`,{d:`M22 8V4`,key:`16f4ou`}],[`path`,{d:`M6 15v-3`,key:`1ij1qe`}],[`rect`,{x:`2`,y:`12`,width:`20`,height:`8`,rx:`2`,key:`1tqiko`}]]};mo.node;var ho=d(mo),go={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};go.node;var _o=d(go),vo={name:`send-horizontal`,size:24,node:[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]],aliases:[`send-horizonal`]};vo.node;var yo=d(vo),bo={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};bo.node;var xo=d(bo),So={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};So.node;var Co=d(So),wo={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};wo.node;var To=d(wo),Eo={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};Eo.node;var Do=d(Eo),Oo={name:`shopping-cart`,size:24,node:[[`path`,{d:`m2.05 2.05 1.099-.028a1 1 0 0 1 1.008.815l2.69 14.347A1 1 0 0 0 7.83 18H18`,key:`uebgi3`}],[`path`,{d:`M4.563 5h16.435a1 1 0 0 1 .981 1.204l-1.026 6.226A2 2 0 0 1 18.962 14H6.25`,key:`1j7c9p`}],[`circle`,{cx:`18`,cy:`20`,r:`2`,key:`t9985n`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};Oo.node;var ko=d(Oo),Ao={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};Ao.node;var jo=d(Ao),Mo={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};Mo.node;var No=d(Mo),Po={name:`square-kanban`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 7v7`,key:`1x2jlm`}],[`path`,{d:`M12 7v4`,key:`xawao1`}],[`path`,{d:`M16 7v9`,key:`1hp2iy`}]],aliases:[`kanban-square`]};Po.node;var Fo=d(Po),Io={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Io.node;var ute=d(Io),Lo={name:`sun-moon`,size:24,node:[[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715`,key:`xlf6rm`}],[`path`,{d:`M16 12a4 4 0 0 0-4-4`,key:`6vsxu`}],[`path`,{d:`m19 5-1.256 1.256`,key:`1yg6a6`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}]]};Lo.node;var dte=d(Lo),Ro={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Ro.node;var fte=d(Ro),zo={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};zo.node;var Bo=d(zo),Vo={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};Vo.node;var pte=d(Vo),Ho={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};Ho.node;var Uo=d(Ho),Wo={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Wo.node;var mte=d(Wo),Go={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Go.node;var Ko=d(Go),qo={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};qo.node;var Jo=d(qo),Yo={name:`truck`,size:24,node:[[`path`,{d:`M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2`,key:`wrbu53`}],[`path`,{d:`M15 18H9`,key:`1lyqi6`}],[`path`,{d:`M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14`,key:`lysw3i`}],[`circle`,{cx:`17`,cy:`18`,r:`2`,key:`332jqn`}],[`circle`,{cx:`7`,cy:`18`,r:`2`,key:`19iecd`}]]};Yo.node;var Xo=d(Yo),Zo={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};Zo.node;var Qo=d(Zo),$o={name:`user-round-cog`,size:24,node:[[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`m15.228 16.852-.923-.383`,key:`npixar`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`M2 21a8 8 0 0 1 10.434-7.62`,key:`1yezr2`}],[`path`,{d:`m20.772 16.852.924-.383`,key:`htqkph`}],[`path`,{d:`m20.772 19.148.924.383`,key:`9w9pjp`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]],aliases:[`user-cog-2`]};$o.node;var hte=d($o),es={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};es.node;var ts=d(es),ns={name:`wallet`,size:24,node:[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]};ns.node;var gte=d(ns),rs={name:`warehouse`,size:24,node:[[`path`,{d:`M18 21V10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1v11`,key:`pb2vm6`}],[`path`,{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 1.132-1.803l7.95-3.974a2 2 0 0 1 1.837 0l7.948 3.974A2 2 0 0 1 22 8z`,key:`doq5xv`}],[`path`,{d:`M6 13h12`,key:`yf64js`}],[`path`,{d:`M6 17h12`,key:`1jwigz`}]]};rs.node;var is=d(rs),as={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};as.node;var _te=d(as),os={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};os.node;var ss=d(os),cs={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};cs.node;var vte=d(cs),L=t(r(),1),R=a({en:{signInSecurity:`Sign-in & security`,signInPolicy:`Sign-in policy`,couldNotReadMethods:`Could not read your sign-in methods`,theProvider:`the provider`,loading:`Loading`,backupCodes:`Backup codes`,copied:`Copied`,copy:`Copy`,download:`Download`,cancel:`Cancel`,save:`Save`,name:`Name`,yourPassword:`Your password`,continue:`Continue`,on:`On`,off:`Off`,optional:`Optional`,required:`Required`,passkeys:`Passkeys`,passkey:`Passkey`,passkeysAllowed:`Sign in with Face ID, Touch ID, Windows Hello, your phone or a security key instead of a password.`,passkeysRequired:`This app requires a passkey for every account. Sign in with Face ID, Touch ID, Windows Hello, your phone or a security key.`,passkeysForbidden:`Your admin turned passkeys off for this app, so they cannot be used to sign in.`,addedOn:e=>`Added ${e}`,addedEarlier:`Added earlier`,synced:`Synced across your devices`,oneDevice:`On one device`,rename:`Rename`,remove:`Remove`,keepLastPasskey:`Passkeys are required: add another one before removing this one.`,addPasskey:`Add a passkey`,renamePasskey:`Rename passkey`,renamePasskeyDescription:`A name that tells you where this passkey lives, such as the device or password manager.`,removePasskey:`Remove passkey?`,removePasskeyDescription:e=>`${e} will no longer sign you in here. It stays on the device until you delete it there.`,thisPasskey:`This passkey`,connectedAccounts:`Connected accounts`,connectedAccountsDescription:`Sign in with these instead of your password. Connecting one asks you to sign in there; its address may differ from yours here.`,connected:`Connected`,connect:e=>`Connect ${e}`,stopped:e=>`Stopped ${e}`,ended:e=>`Ended ${e}`,signedInUntil:e=>`Signed in until ${e}`,staffSignIns:`Staff sign-ins`,staffSignInsDescription:e=>`Each time staff of ${e} signed in as someone here, newest first.`,noStaffSignIns:`No staff has signed in as anyone yet.`,as:`as`,qrCode:`QR code for your authenticator app`,twoFactor:`Two-factor authentication`,twoFactorAllowed:`Ask for a second step after your password or an emailed sign-in code: a code from an authenticator app, or one emailed to you. A passkey needs no second step.`,twoFactorRequired:`This app requires two-factor authentication for every account. Turn it on to keep using the app.`,twoFactorForbidden:`Your admin turned two-factor authentication off for this app.`,twoFactorOnWithApp:`Signing in with a password or an emailed sign-in code also asks for a code from your authenticator app. Backup codes work when you do not have the app.`,twoFactorOnWithAppOrMail:`Signing in with a password or an emailed sign-in code also asks for a code from your authenticator app, or one emailed to you. Backup codes work when you do not have the app.`,twoFactorOnWithMail:`Signing in with a password or an emailed sign-in code also asks for a code emailed to you.`,turnOn:`Turn on`,turnOff:`Turn off`,addAuthenticator:`Add an authenticator app`,newBackupCodes:`New backup codes`,twoFactorIsRequired:`This app requires two-factor authentication.`,turnOffTitle:`Turn off two-factor authentication?`,turnOffDescription:`Signing in then needs only your password or an emailed code. Your backup codes stop working.`,newCodesTitle:`Make new backup codes?`,newCodesDescription:`Your current backup codes stop working, and you get ten new ones.`,makeNewCodes:`Make new codes`,yourNewCodes:`Your new backup codes`,keepCodesSafe:`Keep them somewhere safe: each one signs you in once if you lose your phone. They are not shown again.`,savedCodes:`I saved my backup codes`,authenticatorApp:`Authenticator app`,authenticatorAppDescription:`A code from an app such as Google Authenticator, Microsoft Authenticator or 1Password. Comes with backup codes.`,emailedCode:`Emailed code`,emailedCodeDescription:`A code mailed to your address each time you sign in with a password or an emailed sign-in code.`,twoFactorIsOn:`Two-factor authentication is on. Keep these backup codes somewhere safe: each one signs you in once if you lose your phone. They are not shown again.`,scanCode:`Scan this code with your authenticator app, then enter the 6-digit code it shows.`,cannotScan:`Can't scan it? Enter this key in the app:`,codeFromApp:`Code from the app`,secondStep:`Second step`,password:`Password`,passwordDescription:`Sign in with the email address and a password.`,emailedSignInCode:`Emailed sign-in code`,emailedSignInCodeDescription:`Sign in with a one-time code mailed to the account's address.`,passkeysPolicyDescription:`Sign in with Face ID, Touch ID, Windows Hello, a phone or a security key. Required: everyone adds one after signing in.`,twoFactorPolicyDescription:`A code from an authenticator app, or an emailed one, after a password or an emailed sign-in code. Required: everyone turns it on after signing in.`,staffAccess:`Staff sign-in as a person`,staffAccessDescription:`The team that runs this app signs in as someone to help them, with a reason, for a short session. Each time is in the log below; with "Email the person" they are told too.`,emailThePerson:`Email the person`,platformSignIn:`Sign-in through the platform`,platformSignInDescription:`The sign-in provider the platform that runs this app adds, for people who have an account here already. It never creates accounts.`,platformSignInWith:e=>`Sign in with ${e} through the platform`,codeNeedsMail:`Needs mail settings (PROTOBASE_SMTP_URL and PROTOBASE_MAIL_FROM): off until they are set.`,passwordStaysOn:`Without mail settings, password sign-in stays on so nobody is locked out.`,staffNeedsMail:`Needs mail settings (PROTOBASE_SMTP_URL and PROTOBASE_MAIL_FROM): staff cannot sign in until they are set.`,platformOff:`Off while passkeys or two-factor authentication are required: it skips the second step.`,appliesAs:e=>`Applies as ${e} for now.`,lastSaved:e=>`Last saved on ${e}.`,lastSavedBy:(e,t)=>`Last saved by ${e} on ${t}.`,neverChanged:`Never changed: this is the app's default.`,reset:`Reset`,couldNotReadStaffSignIns:`Could not read the staff sign-ins`,couldNotReadPolicy:`Could not read the sign-in policy`,policySaved:`Saved. It applies to every sign-in from now on.`,policySubtitle:`How people sign in to this app. Signed-in people keep their session, and are asked for what is newly required within 15 minutes.`},nl:{signInSecurity:`Inloggen en beveiliging`,signInPolicy:`Inlogbeleid`,couldNotReadMethods:`Kon je inlogmethoden niet lezen`,theProvider:`de provider`,loading:`Laden`,backupCodes:`Back-upcodes`,copied:`Gekopieerd`,copy:`Kopiëren`,download:`Downloaden`,cancel:`Annuleren`,save:`Bewaren`,name:`Naam`,yourPassword:`Je wachtwoord`,continue:`Doorgaan`,on:`Aan`,off:`Uit`,optional:`Optioneel`,required:`Verplicht`,passkeys:`Passkeys`,passkey:`Passkey`,passkeysAllowed:`Log in met Face ID, Touch ID, Windows Hello, je telefoon of een beveiligingssleutel in plaats van een wachtwoord.`,passkeysRequired:`Deze app vraagt een passkey voor elk account. Log in met Face ID, Touch ID, Windows Hello, je telefoon of een beveiligingssleutel.`,passkeysForbidden:`Je beheerder heeft passkeys uitgezet voor deze app, dus je kunt er niet mee inloggen.`,addedOn:e=>`Toegevoegd ${e}`,addedEarlier:`Eerder toegevoegd`,synced:`Gesynchroniseerd op je apparaten`,oneDevice:`Op één apparaat`,rename:`Naam wijzigen`,remove:`Verwijderen`,keepLastPasskey:`Passkeys zijn verplicht: voeg er nog een toe voordat je deze verwijdert.`,addPasskey:`Passkey toevoegen`,renamePasskey:`Naam van passkey wijzigen`,renamePasskeyDescription:`Een naam die zegt waar deze passkey staat, zoals het apparaat of de wachtwoordbeheerder.`,removePasskey:`Passkey verwijderen?`,removePasskeyDescription:e=>`Met ${e} log je hier niet meer in. Die blijft op het apparaat tot je die daar verwijdert.`,thisPasskey:`deze passkey`,connectedAccounts:`Gekoppelde accounts`,connectedAccountsDescription:`Log hiermee in in plaats van met je wachtwoord. Koppelen vraagt je daar in te loggen; het adres daar kan anders zijn dan hier.`,connected:`Gekoppeld`,connect:e=>`${e} koppelen`,stopped:e=>`Gestopt ${e}`,ended:e=>`Afgelopen ${e}`,signedInUntil:e=>`Ingelogd tot ${e}`,staffSignIns:`Inlogs van medewerkers`,staffSignInsDescription:e=>`Elke keer dat een medewerker van ${e} hier als iemand anders inlogde, nieuwste eerst.`,noStaffSignIns:`Nog geen medewerker heeft als iemand anders ingelogd.`,as:`als`,qrCode:`QR-code voor je authenticator-app`,twoFactor:`Tweestapsverificatie`,twoFactorAllowed:`Vraag een tweede stap na je wachtwoord of een gemailde inlogcode: een code uit een authenticator-app, of een die je gemaild krijgt. Een passkey heeft geen tweede stap nodig.`,twoFactorRequired:`Deze app vraagt tweestapsverificatie voor elk account. Zet het aan om de app te blijven gebruiken.`,twoFactorForbidden:`Je beheerder heeft tweestapsverificatie uitgezet voor deze app.`,twoFactorOnWithApp:`Inloggen met een wachtwoord of een gemailde inlogcode vraagt ook een code uit je authenticator-app. Back-upcodes werken als je de app niet bij de hand hebt.`,twoFactorOnWithAppOrMail:`Inloggen met een wachtwoord of een gemailde inlogcode vraagt ook een code uit je authenticator-app, of een die je gemaild krijgt. Back-upcodes werken als je de app niet bij de hand hebt.`,twoFactorOnWithMail:`Inloggen met een wachtwoord of een gemailde inlogcode vraagt ook een code die je gemaild krijgt.`,turnOn:`Aanzetten`,turnOff:`Uitzetten`,addAuthenticator:`Authenticator-app toevoegen`,newBackupCodes:`Nieuwe back-upcodes`,twoFactorIsRequired:`Deze app vraagt tweestapsverificatie.`,turnOffTitle:`Tweestapsverificatie uitzetten?`,turnOffDescription:`Inloggen vraagt dan alleen je wachtwoord of een gemailde code. Je back-upcodes werken niet meer.`,newCodesTitle:`Nieuwe back-upcodes maken?`,newCodesDescription:`Je huidige back-upcodes werken niet meer, en je krijgt tien nieuwe.`,makeNewCodes:`Nieuwe codes maken`,yourNewCodes:`Je nieuwe back-upcodes`,keepCodesSafe:`Bewaar ze op een veilige plek: met elke code log je één keer in als je je telefoon kwijt bent. Ze worden niet opnieuw getoond.`,savedCodes:`Ik heb mijn back-upcodes bewaard`,authenticatorApp:`Authenticator-app`,authenticatorAppDescription:`Een code uit een app zoals Google Authenticator, Microsoft Authenticator of 1Password. Met back-upcodes.`,emailedCode:`Gemailde code`,emailedCodeDescription:`Een code naar je adres, elke keer dat je inlogt met een wachtwoord of een gemailde inlogcode.`,twoFactorIsOn:`Tweestapsverificatie staat aan. Bewaar deze back-upcodes op een veilige plek: met elke code log je één keer in als je je telefoon kwijt bent. Ze worden niet opnieuw getoond.`,scanCode:`Scan deze code met je authenticator-app en vul daarna de code van 6 cijfers in die de app toont.`,cannotScan:`Lukt scannen niet? Vul deze sleutel in de app in:`,codeFromApp:`Code uit de app`,secondStep:`Tweede stap`,password:`Wachtwoord`,passwordDescription:`Inloggen met het e-mailadres en een wachtwoord.`,emailedSignInCode:`Gemailde inlogcode`,emailedSignInCodeDescription:`Inloggen met een eenmalige code naar het adres van het account.`,passkeysPolicyDescription:`Inloggen met Face ID, Touch ID, Windows Hello, een telefoon of een beveiligingssleutel. Verplicht: iedereen voegt er een toe na het inloggen.`,twoFactorPolicyDescription:`Een code uit een authenticator-app, of een gemailde, na een wachtwoord of een gemailde inlogcode. Verplicht: iedereen zet het aan na het inloggen.`,staffAccess:`Medewerker logt in als iemand anders`,staffAccessDescription:`Het team dat deze app beheert, logt in als iemand om die te helpen, met een reden, voor een korte sessie. Elke keer staat in het logboek hieronder; met "De persoon mailen" krijgt die het ook te horen.`,emailThePerson:`De persoon mailen`,platformSignIn:`Inloggen via het platform`,platformSignInDescription:`De inlogprovider die het platform van deze app toevoegt, voor mensen die hier al een account hebben. Die maakt nooit accounts.`,platformSignInWith:e=>`Inloggen met ${e} via het platform`,codeNeedsMail:`Vraagt mailinstellingen (PROTOBASE_SMTP_URL en PROTOBASE_MAIL_FROM): uit tot die zijn ingesteld.`,passwordStaysOn:`Zonder mailinstellingen blijft inloggen met een wachtwoord aan, zodat niemand wordt buitengesloten.`,staffNeedsMail:`Vraagt mailinstellingen (PROTOBASE_SMTP_URL en PROTOBASE_MAIL_FROM): medewerkers kunnen niet inloggen tot die zijn ingesteld.`,platformOff:`Uit zolang passkeys of tweestapsverificatie verplicht zijn: het slaat de tweede stap over.`,appliesAs:e=>`Geldt voorlopig als ${e}.`,lastSaved:e=>`Laatst bewaard op ${e}.`,lastSavedBy:(e,t)=>`Laatst bewaard door ${e} op ${t}.`,neverChanged:`Nooit gewijzigd: dit is de standaard van de app.`,reset:`Terugzetten`,couldNotReadStaffSignIns:`Kon de inlogs van medewerkers niet lezen`,couldNotReadPolicy:`Kon het inlogbeleid niet lezen`,policySaved:`Bewaard. Het geldt vanaf nu voor elke inlog.`,policySubtitle:`Hoe mensen inloggen bij deze app. Wie is ingelogd, houdt de sessie en krijgt binnen 15 minuten de vraag naar wat nieuw verplicht is.`}}),ls=t(i()),us=`/-/account`,ds=`/-/sign-in-policy`,yte=(e,t,n)=>[{id:`account-security`,label:R(`signInSecurity`),icon:fa,href:`${e}${us}`,active:t===us},...n?[{id:`sign-in-policy`,label:R(`signInPolicy`),icon:Do,href:`${e}${ds}`,active:t===ds}]:[]],bte=[`always`,`editing`,`reading`],fs=e=>e!==void 0&&!bte.includes(e),ps=(e,t)=>t?.[e]??e,ms={list:`list`,filter:`filter`,orderBy:`order_by`,display:`display`,filterLayout:`layout`,map:`map`,calendar:`calendar`,timeline:`timeline`,savedSearch:`saved_search`,create:`new`,edit:`edit`,open:`open`,tab:`tab`},xte=[`list`,`display`,`filter`,`orderBy`,`filterLayout`,`savedSearch`],hs=e=>`${e.latitude.toFixed(5)},${e.longitude.toFixed(5)},${e.zoom.toFixed(2)}`,gs=(e,t,n=-t)=>Number.isFinite(e)&&e>=n&&e<=t,_s=e=>{let t=e?.split(`,`);if(t?.length!==3||t.some(e=>e.trim()===``))return;let[n,r,i]=t.map(Number);return gs(n,90)&&gs(r,180)&&gs(i,22,0)?{latitude:n,longitude:r,zoom:i}:void 0},vs=e=>`${e.scale},${e.day}`,ys=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;let[n,r,i]=t.slice(1).map(Number),a=new Date(Date.UTC(n,r-1,i));return a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i},bs=(e,t)=>{let n=e?.split(`,`);if(n?.length!==2)return;let[r,i]=n;return t.includes(r)&&ys(i)?{scale:r,day:i}:void 0},xs=e=>{let t=new URLSearchParams;for(let n of xte){let r=e[n];r===void 0||r===``&&n!==`filter`||t.set(ms[n],r)}e.map&&t.set(ms.map,hs(e.map)),e.calendar&&t.set(ms.calendar,vs(e.calendar)),e.timeline&&t.set(ms.timeline,vs(e.timeline));let n=t.toString();return n?`?${n}`:``},Ss=e=>{let t=new URLSearchParams;e.edit&&t.set(ms.edit,`true`);for(let n of e.open??[])t.append(ms.open,n);e.tab&&t.set(ms.tab,e.tab);let n=t.toString();return n?`?${n}`:``},Cs=(e,t=``)=>{switch(e.kind){case`page`:return`${t}/${encodeURIComponent(e.page)}`;case`create`:return`${t}/${encodeURIComponent(e.resource)}/${ms.create}${Ts(e.values)}`;case`record`:return`${t}/${encodeURIComponent(e.resource)}/${encodeURIComponent(sr(e.key))}${Ss(e)}`;case`list`:return`${t}/${encodeURIComponent(e.resource)}${xs(e)}`}},ws=e=>{try{return e.split(`/`).filter(Boolean).map(decodeURIComponent)}catch(e){if(e instanceof URIError)return;throw e}},Ts=(e={})=>{let t=new URLSearchParams(Object.entries(e).filter(([,e])=>e!==``)).toString();return t?`?${t}`:``},Es=e=>e===`bar`||e===`panel`?e:void 0,Ds=(e,t)=>{let n=new URL(e,`http://app`),r=ws(n.pathname);if(!r||r.length===0||r.length>2)return;let[i,a]=r;if(i===`-`)return;if(t.has(i))return a===void 0?{kind:`page`,page:i}:void 0;if(a===ms.create){let e=Object.fromEntries([...n.searchParams].filter(([,e])=>e!==``));return{kind:`create`,resource:i,...Object.keys(e).length>0&&{values:e}}}if(a!==void 0){let e=[...new Set(n.searchParams.getAll(ms.open).filter(e=>e!==``))],t=n.searchParams.get(ms.tab)||void 0;return{kind:`record`,resource:i,key:a,...n.searchParams.get(ms.edit)===`true`&&{edit:!0},...e.length>0&&{open:e},...t&&{tab:t}}}let o=n.searchParams,s=o.get(ms.list)||void 0,c=o.get(ms.display)||void 0,l=o.get(ms.filter)??void 0,u=o.get(ms.orderBy)||void 0,d=Es(o.get(ms.filterLayout)),f=_s(o.get(ms.map)),p=bs(o.get(ms.calendar),[`month`,`week`]),m=bs(o.get(ms.timeline),[`week`,`month`,`quarter`]),h=o.get(ms.savedSearch)||void 0;return{kind:`list`,resource:i,...s&&{list:s},...c&&{display:c},...l!==void 0&&{filter:l},...u&&{orderBy:u},...d&&{filterLayout:d},...f&&{map:f},...p&&{calendar:p},...m&&{timeline:m},...h&&{savedSearch:h}}},Os={signature:`sig`},ks=e=>{let t=e.startsWith(`?`)?e.slice(1):e;return new URLSearchParams(t).has(Os.signature)?{oauthQuery:t}:{}},As=`/-/sign-in`,js={step:`step`,next:`next`},Ms=[`sign-in`,`forgot-password`,`email-code`,`sign-up`,`sign-up-code`,`sign-up-details`],Ns=e=>Ms.includes(e),Ps=e=>{if(!e?.startsWith(`/`))return;let t=new URL(e,`http://local`);if(t.origin===`http://local`&&t.pathname!==`/-/sign-in`)return`${t.pathname}${t.search}`},Fs=({step:e=`sign-in`,next:t}={})=>{let n=new URLSearchParams;e!==`sign-in`&&n.set(js.step,e);let r=Ps(t);r&&r!==`/`&&n.set(js.next,r);let i=n.toString();return i?`${As}?${i}`:As},Is=(e,t)=>{if(e!==`/-/sign-in`)return;let n=t.get(js.step),r=Ps(t.get(js.next));return{step:Ns(n)?n:`sign-in`,...r&&{next:r}}},Ls=e=>typeof e==`string`?e:e&&Fn(e),Rs=e=>{let t=Object.entries(e??{}).map(([e,t])=>`${e}.${t}`);return t.length>0?t:void 0},zs=e=>({photos:e&&`${e.resource}.${e.field}.${e.image}`,photos_order_by:e?.sort}),Bs=(e={})=>({filter:Ls(e.filter)||void 0,order_by:e.orderBy,page_size:e.pageSize,page_token:e.pageToken||void 0,fields:e.fields?.join(`,`),labels:Rs(e.labels)?.join(`,`),...zs(e.photos),count:e.count}),Vs=e=>{let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!==void 0&&t.set(n,String(r));let n=t.toString();return n?`?${n}`:``},Hs=e=>e.startsWith(`/`)&&!e.startsWith(`//`),Us=e=>{if(typeof e!=`object`||!e)return!1;let{uri:t,url:n}=e;return typeof t==`string`&&typeof n==`string`&&Hs(n)},Ws=e=>e!==void 0&&URL.canParse(e)?new URL(e).origin:void 0,Gs=(e,t)=>({...e,url:`${t}${e.url}`,...e.variants&&{variants:Object.fromEntries(Object.entries(e.variants).map(([e,n])=>[e,Hs(n.url)?{...n,url:`${t}${n.url}`}:n]))}}),Ks=(e,t)=>t===void 0||typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Us(n)?Gs(n,t):n])),qs=(e,t)=>t===void 0?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n.map(e=>Us(e)?Gs(e,t):e)])),Js=class extends Error{problem;constructor(e){super(e.detail??e.title),this.problem=e,this.name=`ApiError`}get status(){return this.problem.status}get slug(){return this.problem.type.split(`:`).at(-1)??``}get operation(){return this.problem.operation??this.errors.find(e=>e.operation!==void 0)?.operation}get blockedBy(){return this.problem.blockedBy}get errors(){return this.problem.errors??[]}get filterErrors(){return this.slug===`invalid-filter`?this.errors:[]}},Ys=class extends Js{constructor(e){super(e),this.name=`PreconditionFailedError`}},Xs=e=>e instanceof Js,Zs=e=>typeof e==`object`&&!!e&&`type`in e&&`status`in e,Qs=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.json():void 0,n=Zs(t)?t:{type:`urn:protobase:problem:unknown`,title:e.statusText||`Request failed`,status:e.status};return n.status===412?new Ys(n):new Js(n)},$s=(e={})=>{let t=e.baseUrl??`/api/v1`,n=t.replace(/\/[^/]*$/,``),r=e.fetch??((e,t)=>fetch(e,t));return async({method:i,path:a,query:o=``,body:s,headers:c,accept:l=[],system:u,raw:d,via:f,signal:p})=>{let m=async l=>{let m=await e.token?.({refresh:l});return(f??r)(`${u?n:t}${a}${o}`,{method:i,headers:{...s!==void 0&&{"content-type":`application/json`},...m&&{authorization:`Bearer ${m}`},...e.headers?.(),...c},body:d??(s===void 0?void 0:JSON.stringify(s)),...p&&{signal:p}})},h=await m(!1);h.status===401&&e.token&&(h=await m(!0),h.status===401&&e.onUnauthenticated?.());let g=h.headers.get(`x-meta-version`);if(g&&e.onMetaVersion?.(g),!h.ok&&!l.includes(h.status))throw await Qs(h);return h}},ec=e=>new Headers(e.trim().split(/[\r\n]+/).filter(Boolean).map(e=>{let t=e.indexOf(`:`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]})),tc=e=>(t,n={})=>new Promise((r,i)=>{let a=new XMLHttpRequest;a.open(n.method??`GET`,String(t)),new Headers(n.headers).forEach((e,t)=>a.setRequestHeader(t,e)),a.responseType=`blob`,a.upload.onprogress=t=>e(t.loaded,t.lengthComputable?t.total:t.loaded),a.onload=()=>{let e=a.status===204||a.status===304;r(new Response(e?null:a.response,{status:a.status,statusText:a.statusText,headers:ec(a.getAllResponseHeaders())}))},a.onerror=()=>i(TypeError(`Network request failed`)),a.onabort=()=>i(new DOMException(`The upload was aborted`,`AbortError`)),n.signal?.addEventListener(`abort`,()=>a.abort()),a.send(n.body)}),nc=e=>Math.min(3e4,1e3*2**e),rc=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),ic=(e,t,n=nc)=>{let r=new AbortController,{signal:i}=r,a,o=0,s=e=>{o=0,a=e.cursor,e.type===`resync`&&t.onResync(),e.type===`changes`&&t.onChanges(e.changes)},c=async()=>{let t=await e({method:`GET`,path:`/live`,query:Vs({after:a}),headers:{accept:`text/event-stream`},system:!0,signal:i});if(!t.body)throw Error(`The server answered the live stream without a body`);await Nr(t.body,e=>s(JSON.parse(e)),i)};return(async()=>{for(;!i.aborted;){let e=await c().then(()=>void 0,e=>e);if(i.aborted)return;t.onRetry?.(e),await rc(n(o++),i)}})(),()=>r.abort()},ac=e=>typeof e==`string`?e:e.toModel().name,oc=(e,t)=>`/${ac(e)}/${sr(t)}`,sc=(e,t,n)=>({items:e.items.map(e=>Ks(e,n)),nextPageToken:e.next_page_token,totalSizeEstimate:e.total_size_estimate,...e.prev_page_token!==void 0&&{prevPageToken:e.prev_page_token},...e.total_size!==void 0&&{totalSize:e.total_size},...e.labels!==void 0&&{labels:e.labels},...e.photos!==void 0&&{photos:qs(e.photos,n)},...t.headers.get(`x-protobase-warning`)&&{warning:t.headers.get(`x-protobase-warning`)}}),cc=({created_at:e,...t})=>({...t,createdAt:e}),lc=e=>e.headers.get(`etag`)??``,uc=async(e,t)=>{let{permissions:n,...r}=await e.json();return{record:Ks(r,t),etag:lc(e),...n&&{permissions:n}}},dc=(e,t)=>({results:(e.results??[]).map(e=>e.op===`create`||e.op===`update`?{...e,record:Ks(e.record,t)}:e.op===`reorder`?{...e,records:e.records.map(e=>({...e,record:Ks(e.record,t)}))}:e)}),fc=(e={})=>{let t=$s(e),n=Ws(e.baseUrl),r=async(e,r)=>{let i=await t({method:`GET`,path:`/${ac(e)}`,query:Vs(Bs(r))});return sc(await i.json(),i,n)},i=async(e,r)=>{let i=Bs(r),a=await t({method:`POST`,path:`/${ac(e)}:search`,body:{...i,fields:r?.fields,labels:Rs(r?.labels)}});return sc(await a.json(),a,n)},a=async(e,r)=>uc(await t({method:`GET`,path:oc(e,r)}),n),o=async(e,r)=>{let i=await t({method:`POST`,path:`/${ac(e)}`,body:r});return{record:Ks(await i.json(),n),etag:lc(i),location:i.headers.get(`location`)??``}},s=async(e,r,i,a)=>uc(await t({method:`PATCH`,path:oc(e,r),body:i,headers:{"if-match":a}}),n),c=async(e,n,{etag:r}={})=>{await t({method:`DELETE`,path:oc(e,n),headers:r?{"if-match":r}:void 0})},l=async(e,r)=>{let i=await t({method:`POST`,path:`${oc(e,r)}:undelete`});return{record:Ks(await i.json(),n),etag:lc(i)}},u=async(e,n,r)=>(await(await t({method:`POST`,path:`${oc(e,n)}:reveal`,body:{field:r}})).json()).value,d=async(e,r,i)=>uc(await t({method:`POST`,path:`${oc(e,r)}:generate`,body:{action:i}}),n),f=async(e,n,{pageSize:r,pageToken:i}={})=>{let a=Vs({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${oc(e,n)}:history`,query:a})).json();return{items:o.items.map(({database_role:e,...t})=>({...t,databaseRole:e})),nextPageToken:o.next_page_token}},p=async(e,n,{pageSize:r,pageToken:i}={})=>{let a=Vs({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${oc(e,n)}:comments`,query:a})).json();return{items:o.items.map(cc),nextPageToken:o.next_page_token}},m=async(e,n,{body:r,mentions:i=[]})=>cc(await(await t({method:`POST`,path:`${oc(e,n)}:comments`,body:{body:r,mentions:i}})).json()),h=async(e,n,r)=>(await(await t({method:`GET`,path:`${oc(e,n)}:mentionable`,query:Vs({q:r})})).json()).items,g=async e=>{let r=e=>typeof e==`object`&&e&&`$ref`in e?e:sr(e),i=e.map(e=>({...e,resource:ac(e.resource),...`key`in e&&{key:r(e.key)},...e.op===`reorder`&&{keys:e.keys.map(r)}}));return dc(await(await t({method:`POST`,path:`:batchWrite`,body:{ops:i}})).json(),n)},_=async(e,n,r={})=>(await(await t({method:`GET`,path:`/${ac(e)}:facets`,query:Vs({field:n,filter:Ls(r.filter)||void 0,limit:r.limit,label:r.label})})).json()).facets,v=async(e,n)=>{let r=await(await t({method:`GET`,path:`/${ac(e)}:aggregate`,query:Vs({group_by:n.groupBy,filter:Ls(n.filter)||void 0,sum:n.sum,average:n.average,maximum:n.maximum,limit:n.limit,label:n.label,granularity:n.granularity,range:n.range,from:n.from,to:n.to,time_zone:n.timeZone,split_by:n.splitBy,split_limit:n.splitLimit,split_label:n.splitLabel})})).json();return{groupBy:r.group_by,granularity:r.granularity,timeZone:r.time_zone,groups:r.groups,...r.split_by!==void 0&&{splitBy:r.split_by,splits:r.splits}}},y=async(e,n)=>{let r=await(await t({method:`GET`,path:`/${ac(e)}:series`,query:Vs({field:n.field,range:n.range,from:n.from,to:n.to,granularity:n.granularity,time_zone:n.timeZone,filter:Ls(n.filter)||void 0})})).json();return{field:r.field,granularity:r.granularity,timeZone:r.time_zone,points:r.points}},b=async(e,n,r={})=>(await t({method:`GET`,path:`/${ac(e)}:histogram`,query:Vs({field:n,buckets:r.buckets,filter:Ls(r.filter)||void 0})})).json(),x=async(e,r)=>{let i=await(await t({method:`GET`,path:`/${ac(e)}:map`,query:Vs({latitude:r.latitude,longitude:r.longitude,zoom:r.zoom,filter:Ls(r.filter)||void 0,order_by:r.orderBy,fields:r.fields?.join(`,`),labels:Rs(r.labels)?.join(`,`),...zs(r.photos)})})).json();return{items:i.items.map(e=>Ks(e,n)),buckets:i.buckets,totalSize:i.total_size,...i.labels!==void 0&&{labels:i.labels},...i.photos!==void 0&&{photos:qs(i.photos,n)}}},S=async(e,r)=>{let i=await t({method:`GET`,path:`/${ac(e)}:seek`,query:Vs({...Bs(r),position:r.position})});return sc(await i.json(),i,n)},C=async(e,{signal:n}={})=>{let r=await t({method:`GET`,path:`/meta`,system:!0,headers:e?{"if-none-match":e}:void 0,accept:[304],...n&&{signal:n}});return r.status===304?{status:`unchanged`}:{status:`modified`,meta:await r.json(),etag:lc(r)}},w=async(e,{method:n,body:r,path:i=``,query:a,headers:o}={})=>{let s=await t({method:n??(r===void 0?`GET`:`POST`),path:`/functions/${encodeURIComponent(e)}${i}`,query:a?`?${new URLSearchParams(a)}`:``,body:r,headers:o,system:!0});if(s.status!==204)return s.headers.get(`content-type`)?.includes(`json`)?s.json():s.text()},T=async(e,n,r,{onProgress:i,signal:a}={})=>{let o=`name`in r&&typeof r.name==`string`?r.name:void 0,s=i&&typeof XMLHttpRequest<`u`?tc(i):void 0,c=await(await t({method:`POST`,path:`/${ac(e)}:upload`,query:`?${new URLSearchParams({field:n,...o!==void 0&&{name:o}})}`,raw:r,headers:{"content-type":r.type||`application/octet-stream`},...s&&{via:s},...a&&{signal:a}})).json();return i?.(r.size,r.size),c},E=e=>`/forms/${encodeURIComponent(e)}`;return{list:r,search:i,get:a,create:o,update:s,remove:c,undelete:l,generate:d,reveal:u,history:f,comments:p,comment:m,mentionable:h,batchWrite:g,facets:_,aggregate:v,series:y,histogram:b,map:x,seek:S,meta:C,invoke:w,upload:T,form:async e=>(await t({method:`GET`,path:E(e),system:!0})).json(),formChallenge:async e=>(await t({method:`GET`,path:`${E(e)}:challenge`,system:!0})).json(),submitForm:async(e,n,r)=>{await t({method:`POST`,path:E(e),body:{values:n,proof:r},system:!0})},live:e=>ic(t,e)}},pc=e=>typeof e==`string`?e:e.toModel().name,mc=(e,t)=>{let n=n=>t(pc(n))??e;return{list:(e,t)=>n(e).list(e,t),search:(e,t)=>n(e).search(e,t),get:(e,t)=>n(e).get(e,t),create:(e,t)=>n(e).create(e,t),update:(e,t,r,i)=>n(e).update(e,t,r,i),remove:(e,t,r)=>n(e).remove(e,t,r),undelete:(e,t)=>n(e).undelete(e,t),generate:(e,t,r)=>n(e).generate(e,t,r),reveal:(e,t,r)=>n(e).reveal(e,t,r),history:(e,t,r)=>n(e).history(e,t,r),comments:(e,t,r)=>n(e).comments(e,t,r),comment:(e,t,r)=>n(e).comment(e,t,r),mentionable:(e,t,r)=>n(e).mentionable(e,t,r),batchWrite:t=>{let r=[...new Set(t.map(e=>n(e.resource)))];return r.length>1?Promise.reject(Error(`A batch writes to one API, but these writes are for ${[...new Set(t.map(e=>pc(e.resource)))].join(`, `)}, which different APIs serve`)):(r[0]??e).batchWrite(t)},facets:(e,t,r)=>n(e).facets(e,t,r),aggregate:(e,t)=>n(e).aggregate(e,t),series:(e,t)=>n(e).series(e,t),histogram:(e,t,r)=>n(e).histogram(e,t,r),map:(e,t)=>n(e).map(e,t),seek:(e,t)=>n(e).seek(e,t),meta:(t,n)=>e.meta(t,n),invoke:(t,n)=>e.invoke(t,n),upload:(e,t,r,i)=>n(e).upload(e,t,r,i),form:t=>e.form(t),formChallenge:t=>e.formChallenge(t),submitForm:(t,n,r)=>e.submitForm(t,n,r),live:t=>e.live(t)}},hc=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.type==`string`&&Array.isArray(e.children),gc=e=>typeof e==`object`&&!!e&&e.kind===`member`,_c=e=>gc(e)?[e.path.join(`.`)]:typeof e!=`object`||!e?[]:Object.values(e).flatMap(_c),vc=e=>gc(e)?{...e,path:[e.path.join(`.`)]}:Array.isArray(e)?e.map(vc):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,vc(t)])),yc=e=>{let t=Re(e);return t.ok?t.ast?{ok:!0,ast:t.ast,paths:[...new Set(_c(t.ast))]}:{ok:!1,message:`the condition is empty`}:{ok:!1,message:t.errors.map(e=>e.message).join(`; `)}},bc=(e,t)=>e.ast!==void 0&&Lt(vc(e.ast),t),xc=(e,t)=>{let[n,r,...i]=e.split(`.`);return n&&r===`count`&&i.length===0&&!t(n)?n:void 0},Sc=(e,t,n)=>{let r=[],i=e[t],a=n.split(`.`);for(let[o,s]of a.entries()){if(!i)return{ok:!1,message:`unknown resource "${t}"`};let c=Object.hasOwn(i.fields,s)?i.fields[s]:void 0;if(!c)return{ok:!1,message:`unknown field "${a.slice(0,o+1).join(`.`)}" on ${i.name}`};if(r.push({model:i,field:c}),o===a.length-1)break;if(c.type!==`relation`||!c.relation)return{ok:!1,message:`"${a.slice(0,o+1).join(`.`)}" is not a relation, so "${n}" cannot go through it`};t=c.relation.resource,i=e[t]}return{ok:!0,steps:r}},Cc=(e,t)=>({...e,fields:Object.fromEntries(Object.entries(e.fields).map(([e,n])=>{if(!n.relation||Object.hasOwn(t,n.relation.resource))return[e,n];let{relation:r,...i}=n;return[e,i]}))}),wc=(e,t)=>{if(e.kind===`group`){let n=e.items.flatMap(e=>wc(e,t));return n.length>0?[{...e,items:n}]:[]}if(e.kind===`tab`){let n=e.items.flatMap(e=>wc(e,t));return n.length>0?[{...e,items:n}]:[]}if(e.kind!==`related`)return[e];if(!Object.hasOwn(t,e.resource)||e.through&&!Object.hasOwn(t,e.through.resource))return[];let{columns:n,...r}=e,i=n?.filter(n=>Sc(t,e.resource,n).ok);return[i&&i.length>0?{...r,columns:i}:r]},Tc=(e,t,n)=>e.run?.kind!==`link`||!(`to`in e.run)||Or(e.run.to,{models:n,pages:new Set,source:t}).length===0,Ec=(e,t)=>({...e,layout:e.layout.flatMap(e=>wc(e,t)),actions:e.actions.filter(n=>Tc(n,t[e.resource],t))}),Dc=(e,t)=>{let n=e.resources.filter(e=>t.resources.includes(e.name)),r=Object.fromEntries(n.map(e=>[e.name,e])),i=n.map(e=>Cc(e,r)),a=Object.fromEntries(i.map(e=>[e.name,e]));return{resources:i,views:e.views.filter(e=>Object.hasOwn(a,e.resource)).map(e=>Ec(e,a)),permissions:Object.fromEntries(n.flatMap(t=>e.permissions?.[t.name]?[[t.name,e.permissions[t.name]]]:[]))}},Oc=class extends Error{status;code;constructor(e,t,n){super(e),this.status=t,this.code=n,this.name=`AuthError`}},kc=(e,t)=>new Oc(e?.message||t,e?.status??500,e?.code),Ac=e=>({signInMethods:async()=>{let{data:t,error:n}=await e.$fetch(`/account/sign-in-methods`);if(n||!t)throw kc(n,`Could not read your sign-in methods`);return t},passkeys:async()=>{let{data:t,error:n}=await e.passkey.listUserPasskeys();if(n||!t)throw kc(n,`Could not read your passkeys`);return t.map(e=>({id:e.id,backedUp:e.backedUp,...e.name&&{name:e.name},...e.createdAt&&{createdAt:new Date(e.createdAt).toISOString()}}))},addPasskey:async t=>{let{error:n}=await e.passkey.addPasskey(t?{name:t}:{});if(n)throw kc(n,`Could not add the passkey`)},renamePasskey:async(t,n)=>{let{error:r}=await e.passkey.updatePasskey({id:t,name:n});if(r)throw kc(r,`Could not rename the passkey`)},removePasskey:async t=>{let{error:n}=await e.passkey.deletePasskey({id:t});if(n)throw kc(n,`Could not remove the passkey`)},startAuthenticatorApp:async t=>{let{data:n,error:r}=await e.twoFactor.enable({method:`totp`,...t&&{password:t}});if(r||n?.method!==`totp`)throw kc(r,`Could not start two-factor authentication`);return{totpURI:n.totpURI,backupCodes:n.backupCodes}},confirmAuthenticatorApp:async t=>{let{error:n}=await e.twoFactor.verifyTotp({code:t});if(n)throw kc(n,`The code did not work`)},turnOnEmailedCodes:async t=>{let{error:n}=await e.twoFactor.enable({method:`otp`,...t&&{password:t}});if(n)throw kc(n,`Could not turn on two-factor authentication`)},turnOffTwoFactor:async t=>{let{error:n}=await e.twoFactor.disable(t?{password:t}:{});if(n)throw kc(n,`Could not turn off two-factor authentication`)},linkedProviders:async()=>{let{data:t,error:n}=await e.listAccounts();if(n||!t)throw kc(n,`Could not read your linked accounts`);return[...new Set(t.map(e=>e.providerId).filter(e=>e!==`credential`))]},linkProvider:async(t,n)=>{let{data:r,error:i}=await e.linkSocial({provider:t,callbackURL:n,errorCallbackURL:n,disableRedirect:!0});if(i||!r?.url)throw kc(i,`Could not start linking the account`);return r.url},connectedApps:async()=>{let{data:t,error:n}=await e.$fetch(`/account/connected-apps`);if(n||!t)throw kc(n,`Could not read your connected apps`);return t.apps},disconnectApp:async t=>{let{error:n}=await e.$fetch(`/account/connected-apps/disconnect`,{method:`POST`,body:{clientId:t}});if(n)throw kc(n,`Could not disconnect the app`)},newBackupCodes:async t=>{let{data:n,error:r}=await e.twoFactor.generateBackupCodes(t?{password:t}:{});if(r||!n)throw kc(r,`Could not make new backup codes`);return n.backupCodes}}),jc=(e,t)=>new Oc(e?.message||e?.error_description||t,e?.status??500,e?.code??e?.error),Mc=e=>({client:async t=>{let{data:n,error:r}=await e.$fetch(`/oauth2/public-client`,{query:{client_id:t}});if(r||!n)throw jc(r,`Could not read the app asking`);return n},resume:async t=>{let{data:n,error:r}=await e.$fetch(`/oauth2/continue`,{method:`POST`,body:{postLogin:!0,oauth_query:t}});if(r||!n?.url)throw jc(r,`Could not go on with the request`);return{url:n.url}},answer:async(t,n)=>{let{data:r,error:i}=await e.$fetch(`/oauth2/consent`,{method:`POST`,body:{accept:t,oauth_query:n}});if(i||!r?.url)throw jc(i,`Could not answer the request`);return{url:r.url}}});function Nc(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{code:e,message:t,toString:()=>e}]))}var Pc=Nc({CHALLENGE_NOT_FOUND:`Challenge not found`,YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY:`You are not allowed to register this passkey`,FAILED_TO_VERIFY_REGISTRATION:`Failed to verify registration`,PASSKEY_NOT_FOUND:`Passkey not found`,AUTHENTICATION_FAILED:`Authentication failed`,UNABLE_TO_CREATE_SESSION:`Unable to create session`,USER_NOT_FOUND:`User not found`,FAILED_TO_UPDATE_PASSKEY:`Failed to update passkey`,PREVIOUSLY_REGISTERED:`Previously registered`,REGISTRATION_CANCELLED:`Registration cancelled`,AUTH_CANCELLED:`Auth cancelled`,UNKNOWN_ERROR:`Unknown error`,SESSION_REQUIRED:`Passkey registration requires an authenticated session`,RESOLVE_USER_REQUIRED:`Passkey registration requires either an authenticated session or a resolveUser callback when requireSession is false`,RESOLVED_USER_INVALID:`Resolved user is invalid`}),Fc=`1.7.12`;function Ic(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Lc(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function Rc(){return zc.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var zc={stubThis:e=>e};function Bc(e){let{id:t}=e;return{...e,id:Lc(t),transports:e.transports}}function Vc(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var Hc=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function Uc({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new Hc({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new Hc({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new Hc({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new Hc({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new Hc({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new Hc({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new Hc({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new Hc({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!Vc(t))return new Hc({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new Hc({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new Hc({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new Hc({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var Wc=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},Gc=[`cross-platform`,`platform`];function Kc(e){if(e&&!(Gc.indexOf(e)<0))return e}async function qc(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!Rc())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:Lc(t.challenge),user:{...t.user,id:Lc(t.user.id)},excludeCredentials:t.excludeCredentials?.map(Bc)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=Wc.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw Uc({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){Jc(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=Ic(e))}catch(e){Jc(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=Ic(c.getAuthenticatorData())}catch(e){Jc(`getAuthenticatorData()`,e)}return{id:o,rawId:Ic(s),response:{attestationObject:Ic(c.attestationObject),clientDataJSON:Ic(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:Kc(a.authenticatorAttachment)}}function Jc(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function Yc(){if(!Rc())return Xc.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?Xc.stubThis(new Promise(e=>e(!1))):Xc.stubThis(e.isConditionalMediationAvailable())}var Xc={stubThis:e=>e};function Zc({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new Hc({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new Hc({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!Vc(t))return new Hc({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new Hc({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new Hc({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function Qc(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!Rc())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(Bc));let a={...t,challenge:Lc(t.challenge),allowCredentials:i},o={};if(n){if(!await Yc())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=Wc.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Zc({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=Ic(u.userHandle)),{id:c,rawId:Ic(l),response:{authenticatorData:Ic(u.authenticatorData),clientDataJSON:Ic(u.clientDataJSON),signature:Ic(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Kc(s.authenticatorAttachment)}}var $c=`1.7.12`,el=Symbol.for(`better-auth:broadcast-channel`),Ste=()=>Math.floor(Date.now()/1e3),Cte=class{listeners=new Set;name;constructor(e=`better-auth.message`){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(typeof window<`u`)try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:Ste()}))}catch{}}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=e=>{if(e.key!==this.name)return;let t=JSON.parse(e.newValue??`{}`);t?.event===`session`&&t?.data&&this.listeners.forEach(e=>e(t))};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}}};function tl(e=`better-auth.message`){return globalThis[el]||(globalThis[el]=new Cte(e)),globalThis[el]}var nl=[],rl=0,il=null,al=4,wte=globalThis.nanostoresGlobal||={epoch:0},Tte=()=>{let e,t;for(;rl<nl.length;){t=rl,rl+=al;let n=il?.get(nl[t]);if(n){if(!n.has(nl[t+1]))continue;n.clear()}try{nl[t](nl[t+1].value,nl[t+2],nl[t+3])}catch(t){e=t}}if(nl.length=rl=0,e)throw e},ol=e=>{let t=[],n={eq:Object.is,get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(e){return n.lc=t.push(e),()=>{il?.get(e)?.delete(n);for(let t=rl;t<nl.length;)nl[t]===e&&nl[t+1]===n?nl.splice(t,al):t+=al;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){wte.epoch++;let i=!nl.length&&!0;for(let i of t)nl.push(i,n,e,r);i&&Tte()},off(){},set(e){let t=n.value;n.eq(t,e)||(n.value=e,n.notify(t))},subscribe(e){let t=n.listen(e);return e(n.value),t},value:e};return n},Ete=2,Dte=5,sl=6,cl=10,ll=(e,t,n,r)=>(e.events=e.events||{},e.events[n+cl]||(e.events[n+cl]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);~i&&(r.splice(i,1),r.length||(e.events[n+cl](),delete e.events[n+cl]))}),Ote=(e,t)=>ll(e,t,Ete,t=>{let n=e.set,r=e.setKey;return e.setKey&&=(n,i)=>{let a;if(t({abort:()=>{a=!0},changed:n,newValue:{...e.value,[n]:i}}),!a)return r(n,i)},e.set=e=>{let r;if(t({abort:()=>{r=!0},newValue:e}),!r)return n(e)},()=>{e.set=n,e.setKey=r}}),ul=1e3,dl=(e,t)=>ll(e,n=>{let r=t(n);r&&e.events[sl].push(r)},Dte,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[sl]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[sl])t();e.events[sl]=[]}},ul)},()=>{e.listen=n,e.off=r}});function fl(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function pl(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!pl(e[n],t[n]))return!1;return!0}if(fl(e)&&fl(t)){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!(r in t)||!pl(e[r],t[r]))return!1;return!0}return!1}function ml(e,t){return Ote(e,({newValue:n,abort:r})=>{t(e.value,n)&&r()})}var hl=Symbol.for(`better-auth:focus-manager`),kte=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||typeof document>`u`||window.addEventListener===void 0)return()=>{};let e=()=>{document.visibilityState===`visible`&&this.setFocused(!0)};return document.addEventListener(`visibilitychange`,e,!1),()=>{document.removeEventListener(`visibilitychange`,e,!1)}}};function gl(){return globalThis[hl]||(globalThis[hl]=new kte),globalThis[hl]}var _l=Symbol.for(`better-auth:online-manager`),Ate=class{listeners=new Set;isOnline=typeof navigator<`u`?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(`online`,e,!1),window.addEventListener(`offline`,t,!1),()=>{window.removeEventListener(`online`,e,!1),window.removeEventListener(`offline`,t,!1)}}};function vl(){return globalThis[_l]||(globalThis[_l]=new Ate),globalThis[_l]}var jte={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Mte=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,yl={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},Nte=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Pte(e){return e instanceof Date&&!isNaN(e.getTime())}function Fte(e){let t=Nte.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u,d]=t,f=new Date(Date.UTC(parseInt(n,10),parseInt(r,10)-1,parseInt(i,10),parseInt(a,10),parseInt(o,10),parseInt(s,10),c?parseInt(c.padEnd(3,`0`),10):0));if(l){let e=(parseInt(u,10)*60+parseInt(d,10))*(l===`+`?-1:1);f.setUTCMinutes(f.getUTCMinutes()+e)}return Pte(f)?f:null}function Ite(e,t={}){let{strict:n=!1,warnings:r=!1,reviver:i,parseDates:a=!0}=t;if(typeof e!=`string`)return e;let o=e.trim(),s=o.toLowerCase();if(s.length<=9&&s in yl)return yl[s];if(!Mte.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(jte).some(([e,t])=>{let n=t.test(o);return n&&r&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`),n})&&n)throw Error(`[better-json] Potential prototype pollution attempt detected`);try{return JSON.parse(o,(e,t)=>{if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){r&&console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);return}if(a&&typeof t==`string`){let e=Fte(t);if(e)return e}return i?i(e,t):t})}catch(t){if(n)throw t;return e}}function Lte(e,t={strict:!0}){return Ite(e,t)}var Rte=Symbol.for(`better-auth:auth-query`);function bl(e){let t=ol(e);return Object.defineProperty(t,Rte,{value:!0}),t}var zte=()=>typeof window>`u`;function Bte(e,t){return pl(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}var Vte=(e,t,n,r)=>{let i=bl({data:null,error:null,isPending:!0,isRefetching:!1,refetch:e=>o(e)});dl(i,()=>ml(i,Bte));let a=0,o=async e=>{let o=++a;return new Promise(s=>{let c=typeof r==`function`?r({data:i.get().data,error:i.get().error,isPending:i.get().isPending}):r;n(t,{...c,query:{...c?.query,...e?.query},async onSuccess(e){if(o===a){let t=i.get(),n=t.data!=null&&e.data!=null&&pl(t.data,e.data)?t.data:e.data;i.set({data:n,error:null,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}await c?.onSuccess?.(e)},async onError(e){let{request:t}=e,n=typeof t.retry==`number`?t.retry:t.retry?.attempts,r=t.retryAttempt||0;if(!(n&&r<n)){if(o===a){let t=e.error.status===401;i.set({error:e.error,data:t?null:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}await c?.onError?.(e)}},async onRequest(e){if(o===a){let e=i.get();i.set({isPending:e.data===null,data:e.data,error:null,isRefetching:!0,refetch:i.value.refetch})}await c?.onRequest?.(e)}}).catch(e=>{o===a&&i.set({error:e,data:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}).finally(()=>{s(void 0)})})};e=Array.isArray(e)?e:[e];let s=!1,c=!1,l=!1,u=()=>{if(s){l=!0;return}s=!0,o().finally(()=>{s=!1;let e=l&&c;l=!1,e&&u()})};return dl(i,()=>{if(zte())return;c=!0;let t=!1,n,r=e.map(e=>e.listen(()=>{t?o():(t=!0,clearTimeout(n),u())}));return n=setTimeout(()=>{t=!0,u()},0),()=>{c=!1;for(let e of r)e();clearTimeout(n)}}),i},xl=()=>Math.floor(Date.now()/1e3),Hte=5;function Ute(e){let{fetchSession:t,shouldPollSession:n=()=>!0,sessionSignal:r,options:i={}}=e,a=i.sessionOptions?.refetchInterval??0,o=i.sessionOptions?.refetchOnWindowFocus??!0,s=i.sessionOptions?.refetchWhenOffline??!1,c={isInitialized:!1,lastSessionRequest:0},l=()=>s||vl().isOnline,u=e=>{if(l()){if(e?.event===`storage`){t();return}if(e?.event===`poll`){c.lastSessionRequest=xl(),t();return}if(e?.event===`visibilitychange`){if(xl()-c.lastSessionRequest<Hte)return;c.lastSessionRequest=xl(),t();return}t()}},d=e=>{tl().post({event:`session`,data:{trigger:e},clientId:Math.random().toString(36).substring(7)})},f=()=>{a&&a>0&&(c.pollInterval=setInterval(()=>{n()&&u({event:`poll`})},a*1e3))},p=()=>{c.unsubscribeBroadcast=tl().subscribe(()=>{u({event:`storage`})})},m=()=>{o&&(c.unsubscribeFocus=gl().subscribe(()=>{u({event:`visibilitychange`})}))},h=()=>{c.unsubscribeOnline=vl().subscribe(e=>{e&&u({event:`visibilitychange`})})},g=()=>{c.unsubscribeSignal=r.listen(()=>{t()})};return{init:()=>{c.isInitialized||(c.isInitialized=!0,f(),p(),m(),h(),g(),c.cleanupBroadcastSetup=tl().setup(),c.cleanupFocusSetup=gl().setup(),c.cleanupOnlineSetup=vl().setup())},cleanup:()=>{c.isInitialized&&(c.pollInterval&&=(clearInterval(c.pollInterval),void 0),c.unsubscribeBroadcast&&=(c.unsubscribeBroadcast(),void 0),c.unsubscribeFocus&&=(c.unsubscribeFocus(),void 0),c.unsubscribeOnline&&=(c.unsubscribeOnline(),void 0),c.unsubscribeSignal&&=(c.unsubscribeSignal(),void 0),c.cleanupBroadcastSetup&&=(c.cleanupBroadcastSetup(),void 0),c.cleanupFocusSetup&&=(c.cleanupFocusSetup(),void 0),c.cleanupOnlineSetup&&=(c.cleanupOnlineSetup(),void 0),c.isInitialized=!1,c.lastSessionRequest=0)},triggerRefetch:u,broadcastSessionUpdate:d}}var Sl=Object.create(null),Cl=e=>({}),wl=new Proxy(Sl,{get(e,t){return Cl()[t]??Sl[t]},has(e,t){return t in Cl()||t in Sl},set(e,t,n){let r=Cl(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=Cl(!0);return delete n[t],!0},ownKeys(){let e=Cl(!0);return Object.keys(e)}});wl.NODE_ENV;function Tl(e,t){return typeof process<`u`?{}[e]??t:typeof Deno<`u`?Deno.env.get(e)??t:typeof Bun<`u`?Bun.env[e]??t:t}Object.freeze({get BETTER_AUTH_SECRET(){return Tl(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return Tl(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return Tl(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return Tl(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return Tl(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return Tl(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return Tl(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function Wte(){let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.prototype.hasOwnProperty.call(e,`writable`)?e.writable:e.set!==void 0}function Gte(e){let t=e.split(`
|
|
5
5
|
at `);return t.length<=1?e:(t.splice(1,1),t.join(`
|
|
6
6
|
at `))}function Kte(e,t){class n extends e{#e;constructor(...e){if(Wte()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=Gte(t.replace(/^Error/,this.name)))}get errorStack(){return this.#e}}return Object.defineProperty(n.prototype,"constructor",{get(){return t},enumerable:!1,configurable:!0}),n}var qte={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,"I'M_A_TEAPOT":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};Kte(class extends Error{status;body;headers;statusCode;constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:qte[e]){if(super(t?.message,t&&`cause`in t?{cause:t.cause}:void 0),this.status=e,this.body=t,this.headers=n,this.statusCode=r,this.name=`APIError`,this.status=e,this.headers=n,this.statusCode=r,t&&`cause`in t){let{cause:e,...n}=t;this.body=Object.defineProperty(n,"cause",{value:e,writable:!0,configurable:!0});return}this.body=t}},Error);var El=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},Jte=47;function Dl(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===Jte;)t--;return t===e.length?e:e.slice(0,t)}function Yte(e){try{return(Dl(new URL(e).pathname)||`/`)!==`/`}catch{throw new El(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function Xte(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new El(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof El?t:new El(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function Ol(e,t=`/api/auth`){if(Xte(e),Yte(e))return e;let n=Dl(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function kl(e,t){return!e||e.trim()===``?!1:t===`proto`?e===`http`||e===`https`:t===`host`?[/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))?!1:/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e):!1}function Zte(e,t,n,r,i){if(e)return Ol(e,t);if(r!==!1){let e=wl.BETTER_AUTH_URL||wl.NEXT_PUBLIC_BETTER_AUTH_URL||wl.PUBLIC_BETTER_AUTH_URL||wl.NUXT_PUBLIC_BETTER_AUTH_URL||wl.NUXT_PUBLIC_AUTH_URL||(wl.BASE_URL===`/`?void 0:wl.BASE_URL);if(e)return Ol(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&kl(o,`proto`)&&kl(a,`host`))try{return Ol(`${o}://${a}`,t)}catch{}if(n){let e=Qte(n.url);if(!e)throw new El(`Could not get origin from request. Please provide a valid base URL.`);return Ol(e,t)}if(typeof window<`u`&&window.location)return Ol(window.location.origin,t)}function Qte(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var $te=[`javascript:`,`data:`,`vbscript:`];function Al(e){let t;try{t=new URL(e)}catch{return!0}return!$te.includes(t.protocol)}var ene={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&Al(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}},tne=()=>typeof window>`u`,nne=ul;function rne(e,t){if(typeof window>`u`)return;let n=e.get();n.data===null&&t!==null&&e.set({...n,data:t,error:null,isPending:!1})}function jl(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}function ine(e){return!e||e.session===null&&e.user===null?null:e}function ane(e,t){return pl(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function one(e,t){let n=ol(!1),r,i=0,a=0;n.listen(()=>{a++,i=0});let o=e=>u(e),s=bl({data:null,error:null,isPending:!0,isRefetching:!1,refetch:o});ml(s,ane);let c=async(t,n)=>{let r=s.value;if(s.set({...r,isPending:r.data===null,isRefetching:!0,error:null,refetch:o}),t.aborted)return`aborted`;try{let r=await e(`/get-session`,{method:`GET`,query:n?.query,signal:t});if(t.aborted)return`aborted`;let{data:i,error:a}=jl(r),c=`fresh`;if(i?.needsRefresh)try{let n=await e(`/get-session`,{method:`POST`,signal:t});if(t.aborted)return`aborted`;({data:i,error:a}=jl(n))}catch{if(t.aborted)return`aborted`;c=`stale`}if(a){let e=s.value,t=a?.status===401;return s.set({data:t?null:e.data,error:a,isPending:!1,isRefetching:!1,refetch:o}),`failed`}let l=ine(i),u=s.value,d=u.data!=null&&l!=null&&pl(u.data,l)?u.data:l;return s.set({data:d,error:null,isPending:!1,isRefetching:!1,refetch:o}),c}catch(e){if(t.aborted)return`aborted`;let n=s.value;return s.set({data:n.data,error:e,isPending:!1,isRefetching:!1,refetch:o}),`failed`}},l=()=>{let e=s.value.data?.session?.expiresAt,t=e instanceof Date?e.getTime():1/0;return Math.min(Date.now()+nne,t)},u=e=>{i=0,r?.cancel();let t=new AbortController,n={cancel:()=>t.abort(),promise:Promise.resolve().then(()=>t.signal.aborted?`aborted`:c(t.signal,e)),revision:a};r=n;let o=e=>{r===n&&(r=void 0,e===`fresh`&&n.revision===a&&(i=l()))};return n.promise.then(o,()=>o(`failed`)),n.promise.then(()=>void 0)},d=()=>r?.revision===a?r.promise.then(()=>void 0):Date.now()<i?Promise.resolve():u(),f=()=>{};return dl(s,()=>{let e;tne()||(e=setTimeout(()=>{d()},0));let r=Ute({fetchSession:u,shouldPollSession:()=>s.value.data!=null,sessionSignal:n,options:t});return r.init(),f=r.broadcastSessionUpdate,()=>{e&&clearTimeout(e),r.cleanup()}}),{session:s,$sessionSignal:n,broadcastSessionUpdate:e=>f(e)}}function Ml(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function Nl(e,t,n=`.`,r){if(!Ml(t))return Nl(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:Ml(a)&&Ml(i[t])?Nl(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function sne(e){return(...t)=>t.reduce((t,n)=>Nl(t,n,``,e),{})}var cne=sne(),lne=class extends Error{constructor(e,t,n){super(t||e.toString(),{cause:n}),this.status=e,this.statusText=t,this.error=n,Error.captureStackTrace(this,this.constructor)}},une=async(e,t)=>{let n=t||{},r={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:n,hooks:r};for(let i of t?.plugins||[]){if(i.init){let t=await i.init?.call(i,e.toString(),n);n=t.options||n,e=t.url}r.onRequest.push(i.hooks?.onRequest),r.onResponse.push(i.hooks?.onResponse),r.onSuccess.push(i.hooks?.onSuccess),r.onError.push(i.hooks?.onError),r.onRetry.push(i.hooks?.onRetry)}return{url:e,options:n,hooks:r}},Pl=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},dne=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function fne(e){if(typeof e==`number`)return new Pl({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new Pl(e);case`exponential`:return new dne(e);default:throw Error(`Invalid retry strategy`)}}var pne=[`get`,`post`,`put`,`patch`,`delete`];function Fl(e){if(!e.startsWith(`@`))return{method:void 0,path:e};let t=e.indexOf(`/`),n=e.slice(1,t===-1?void 0:t);return pne.includes(n)?{method:n,path:t===-1?e:e.slice(t+1)}:{method:void 0,path:e}}var mne=e=>e===`.`||e===`..`,hne=e=>e.split(`:`).map(e=>encodeURIComponent(e)).join(`:`);function gne(e,t){let n=t.get(e);if(n===void 0)return hne(e);if(mne(n))throw TypeError(`Path parameters cannot be reserved path segments`);return encodeURIComponent(n)}function _ne(e,t){let{baseURL:n,params:r,query:i}=t||{query:{},params:{},baseURL:``},a=e.startsWith(`http`)?e.split(`/`).slice(0,3).join(`/`):n||``,{path:o}=Fl(e);o!==e&&(e=`/${o}`),a.endsWith(`/`)||(a+=`/`);let[s,c]=e.replace(a,``).split(`?`),l=new URLSearchParams(c);for(let[e,t]of Object.entries(i||{})){if(t==null)continue;let n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let n of t)l.append(e,n);continue}else n=JSON.stringify(t);l.set(e,n)}let u=new Map;if(r){if(Array.isArray(r)){let e=s.split(`/`).filter(e=>e.startsWith(`:`));for(let[t,n]of e.entries()){let e=r[t];u.set(n,String(e))}}else for(let[e,t]of Object.entries(r))u.set(`:${e}`,String(t))}s=s.split(`/`).map(e=>gne(e,u)).join(`/`),s=s.replace(/^\/+/,``);let d=l.toString();return d=d.length>0?`?${d}`.replace(/\+/g,`%20`):``,a.startsWith(`http`)?new URL(`${s}${d}`,a):`${a}${s}${d}`}var vne=async e=>{let t={},n=async e=>typeof e==`function`?await e():e;if(e?.auth){if(e.auth.type===`Bearer`){let r=await n(e.auth.token);if(!r)return t;t.authorization=`Bearer ${r}`}else if(e.auth.type===`Basic`){let[r,i]=await Promise.all([n(e.auth.username),n(e.auth.password)]);if(!r||!i)return t;t.authorization=`Basic ${btoa(`${r}:${i}`)}`}else if(e.auth.type===`Custom`){let[r,i]=await Promise.all([n(e.auth.prefix),n(e.auth.value)]);if(!i)return t;t.authorization=`${r??``} ${i}`}}return t},yne=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function bne(e){let t=e.headers.get(`content-type`),n=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]);if(!t)return`json`;let r=t.split(`;`).shift()||``;return yne.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function xne(e){try{return JSON.parse(e),!0}catch{return!1}}function Il(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}function Ll(e){try{return JSON.parse(e)}catch{return e}}function Rl(e){return typeof e==`function`}function Sne(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&Rl(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&Rl(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}function zl(...e){let t={};for(let n of e)if(n){if(n instanceof Headers)n.forEach((e,n)=>{t[n]=e});else{let e=Array.isArray(n)?n:Object.entries(n);for(let[n,r]of e)r!=null&&(t[n]=r)}}return t}async function Cne(e){let t=new Headers(zl(e?.headers,await vne(e)));if(!t.has(`content-type`)){let n=wne(e?.body);n&&t.set(`content-type`,n)}return t}function wne(e){return Il(e)?`application/json`:null}function Tne(e){let t=e.get(`content-type`);return t?t.split(`;`)[0].trim().toLowerCase():null}function Ene(e,t){let{body:n}=e;return n?!Il(n)||typeof n==`string`?n:Tne(t)===`application/x-www-form-urlencoded`?new URLSearchParams(n).toString():JSON.stringify(n):null}function Dne(e,t){if(t?.method)return t.method.toUpperCase();let{method:n}=Fl(e);return n?n.toUpperCase():t?.body?`POST`:`GET`}function One(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var kne=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function Bl(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new kne(n.issues);return n.value}function Vl(e){"@babel/helpers - typeof";return Vl=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Vl(e)}function Ane(e,t){if(Vl(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Vl(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function jne(e){var t=Ane(e,`string`);return Vl(t)==`symbol`?t:t+``}function Mne(e,t,n){return(t=jne(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Hl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ul(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Hl(Object(n),!0).forEach(function(t){Mne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hl(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Wl=async(e,t)=>{var n;let{hooks:r,url:i,options:a}=await une(e,t),o=Sne(a),s=new AbortController,c=a.signal??s.signal,l=_ne(i,a),u=await Cne(a),d=Ene(a,u),f=Dne(i,a),p=Ul(Ul({},a),{},{url:l,headers:u,body:d,method:f,signal:c});for(let e of r.onRequest)if(e){let t=await e(p);typeof t==`object`&&t&&Object.assign(p,t)}(`pipeTo`in p&&typeof p.pipeTo==`function`||typeof(t==null||(n=t.body)==null?void 0:n.pipe)==`function`)&&(`duplex`in p||(p.duplex=`half`));let{clearTimeout:m}=One(a,s),h=await o(p.url,p);m();let g={response:h,request:p};for(let e of r.onResponse)if(e){var _;let n=await e(Ul(Ul({},g),{},{response:t!=null&&(_=t.hookOptions)!=null&&_.cloneResponse?h.clone():h}));n instanceof Response?h=n:typeof n==`object`&&n&&(h=n.response)}if(h.ok){if(p.method===`HEAD`)return{data:``,error:null};let e=bne(h),n={data:null,response:h,request:p};if(e===`json`||e===`text`){let e=await h.text();n.data=await(p.jsonParser??Ll)(e)}else n.data=await h[e]();p?.output&&p.output&&!p.disableValidation&&(n.data=await Bl(p.output,n.data));for(let e of r.onSuccess)if(e){var v;await e(Ul(Ul({},n),{},{response:t!=null&&(v=t.hookOptions)!=null&&v.cloneResponse?h.clone():h}))}return t?.throw?n.data:{data:n.data,error:null}}let y=t?.jsonParser??Ll,b=await h.text(),x=xne(b),S=x?await y(b):null,C={response:h,responseText:b,request:p,error:Ul(Ul({},S),{},{status:h.status,statusText:h.statusText})};for(let e of r.onError)if(e){var w;await e(Ul(Ul({},C),{},{response:t!=null&&(w=t.hookOptions)!=null&&w.cloneResponse?h.clone():h}))}if(t?.retry){let n=fne(t.retry),i=t.retryAttempt??0;if(await n.shouldAttemptRetry(i,h)){for(let e of r.onRetry)e&&await e(g);let a=n.getDelay(i);return await new Promise(e=>setTimeout(e,a)),await Wl(e,Ul(Ul({},t),{},{retryAttempt:i+1}))}}if(t?.throw)throw new lne(h.status,h.statusText,x?S:b);return{data:null,error:Ul(Ul({},S),{},{status:h.status,statusText:h.statusText})}},Nne=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){var r;let i=Ul(Ul({},n),e.query!==void 0&&{query:Ul(Ul({},e.query),n?.query)}),a=((r=e.plugins)==null||(r=r.find(e=>e.schema?.config?t.startsWith(e.schema.config.baseURL||``)||t.startsWith(e.schema.config.prefix||``):!1))==null?void 0:r.schema)||e.schema;if(a){let r=t;a.config?.prefix&&r.startsWith(a.config.prefix)&&(r=r.replace(a.config.prefix,``),a.config.baseURL&&(t=t.replace(a.config.prefix,a.config.baseURL))),a.config?.baseURL&&r.startsWith(a.config.baseURL)&&(r=r.replace(a.config.baseURL,``)),r.startsWith(`/`)&&r.charAt(1)===`@`&&(r=r.substring(1));let o=a.schema[r];if(o){let{method:a,path:s}=Fl(r);a&&(t=t.slice(0,t.length-r.length)+s);let c=n?.headers;if(o.headers&&!n?.disableValidation){let e={};if(n?.headers){if(n.headers instanceof Headers)n.headers.forEach((t,n)=>{e[n.toLowerCase()]=t});else if(typeof n.headers==`object`)for(let[t,r]of Object.entries(n.headers))r!=null&&(e[t.toLowerCase()]=r)}let t=await Bl(o.headers,e),r={};for(let[e,n]of Object.entries(t))r[e.toLowerCase()]=n;c=r}let l=o.method??a;if(i=Ul(Ul(Ul(Ul({},i),l!==void 0&&{method:l}),o.output!==void 0&&{output:o.output}),c!==void 0&&{headers:c}),!n?.disableValidation){if(o.query&&(i.query=await Bl(o.query,n?.query),i.query!==null&&typeof i.query==`object`)){let t=Ul({},e.query);for(let e of Object.keys(t))n?.query&&Object.prototype.hasOwnProperty.call(n.query,e)&&(t[e]=n.query[e]);i.query=Ul(Ul({},t),i.query)}i=Ul(Ul({},i),{},{body:o.input?await Bl(o.input,n?.body):n?.body,params:o.params?await Bl(o.params,n?.params):n?.params})}return{url:t,options:i}}}return Ul({url:t},(n!==void 0||e.query!==void 0)&&{options:i})}}),Pne=e=>{async function t(t,n){let r=Ul(Ul(Ul({},e),n),{},{headers:zl(e?.headers,n?.headers),plugins:[...e?.plugins||[],Nne(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await Wl(t,r)}catch(e){return{data:null,error:{status:500,statusText:`Fetch Error`,message:`Fetch related error. Captured by catchAllError option. See error property for more details.`,error:e}}}return await Wl(t,r)}return t},Fne=e=>{if(typeof process>`u`)return;let t=e??`/api/auth`;if({}.NEXT_PUBLIC_AUTH_URL)return{}.NEXT_PUBLIC_AUTH_URL;if(typeof window>`u`){if({}.NEXTAUTH_URL)try{return{}.NEXTAUTH_URL}catch{}if({}.VERCEL_URL)try{let e={}.VERCEL_URL.startsWith(`http`)?``:`https://`;return`${new URL(`${e}${{}.VERCEL_URL}`).origin}${t}`}catch{}}},Ine=e=>e===`/sign-out`||e===`/update-user`||e===`/update-session`||e===`/sign-up/email`||e===`/sign-in/email`||e===`/delete-user`||e===`/verify-email`||e===`/revoke-sessions`||e===`/revoke-session`||e===`/revoke-other-sessions`||e===`/change-email`||e===`/change-password`,Lne=(e,t)=>{let n=`credentials`in Request.prototype,r=Zte(e?.baseURL,e?.basePath,void 0,t)??Fne(e?.basePath)??`/api/auth`,i=e?.plugins?.flatMap(e=>e.fetchPlugins).filter(e=>e!==void 0)||[],a={id:`lifecycle-hooks`,name:`lifecycle-hooks`,hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:o,onError:s,onRequest:c,onResponse:l,...u}=e?.fetchOptions||{},d=Pne({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?Lte(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[ene],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=one(d,e),h=!1,g=e=>{h||e===null||(h=!0,rne(p,e))},_=e?.plugins||[],v={},y={$sessionSignal:f,session:p},b={"/sign-out":`POST`,"/revoke-sessions":`POST`,"/revoke-other-sessions":`POST`,"/delete-user":`POST`},x=[{signal:`$sessionSignal`,matcher:Ine,callback(e){e===`/sign-out`?m(`signout`):(e===`/update-user`||e===`/update-session`)&&m(`updateUser`)}}];for(let e of _)e.getAtoms&&Object.assign(y,e.getAtoms?.(d)),e.pathMethods&&Object.assign(b,e.pathMethods),e.atomListeners&&x.push(...e.atomListeners);let S={notify:e=>{y[e].set(!y[e].get())},listen:(e,t)=>{y[e].subscribe(t)},atoms:y};for(let t of _)t.getActions&&(v=cne(t.getActions?.(d,S,e)??{},v));return{get baseURL(){return r},pluginsActions:v,pluginsAtoms:y,pluginPathMethods:b,atomListeners:x,hydrateSession:g,$sessionSignal:f,$fetch:d,$store:S}};function Rne(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function zne(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Bne=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,Vne=/['\u2019]/g;function Gl(e){return e.replace(Vne,``).match(Bne)??[]}function Kl(e){return Gl(e).map(e=>e.toLowerCase()).join(`-`)}function ql(e,t,n){let r=t[e],{fetchOptions:i,query:a,...o}=n||{};return r||(i?.method?i.method:o&&Object.keys(o).length>0?`POST`:`GET`)}function Jl(e,t,n,r,i){function a(o=[]){return new Proxy(function(){},{get(t,n){if(typeof n!=`string`||n===`then`||n===`catch`||n===`finally`)return;let r=[...o,n],i=e;for(let e of r)if(i&&typeof i==`object`&&e in i)i=i[e];else{i=void 0;break}return typeof i==`function`||Rne(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(Kl).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=ql(c,n,l);return await t(c,{...m,body:h===`GET`?void 0:{...p,...m?.body||{}},query:d||m?.query,method:h,async onSuccess(e){if(await m?.onSuccess?.(e),!i||m.disableSignal)return;let t=i.filter(e=>e.matcher(c));if(!t.length)return;let n=new Set;for(let e of t){let t=r[e.signal];if(!t)return;if(n.has(e.signal))continue;n.add(e.signal);let i=t.get();setTimeout(()=>{t.set(!i)},10),e.callback?.(c)}}})}})}return a()}function Yl(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,hydrateSession:i,$fetch:a,atomListeners:o,$store:s}=Lne(e),c={};for(let[e,t]of Object.entries(r))c[`use${zne(e)}`]=t;return Jl({...n,...c,hydrateSession:i,$fetch:a,$store:s},a,t,r,o)}var Xl=(e,{$listPasskeys:t,$store:n})=>({signIn:{passkey:async(r,i)=>{let a=await e(`/passkey/generate-authenticate-options`,{method:`GET`,throw:!1});if(!a.data)return a;let o=a.data.extensions||r?.extensions?{...a.data.extensions||{},...r?.extensions||{}}:void 0,s;try{s=await Qc({optionsJSON:{...a.data,extensions:o},useBrowserAutofill:r?.autoFill})}catch(e){return{data:null,error:{code:e instanceof Hc?e.code:`AUTH_CANCELLED`,message:Pc.AUTH_CANCELLED.message,status:400,statusText:`BAD_REQUEST`}}}try{let{clientExtensionResults:a,...o}=s,c=await e(`/passkey/verify-authentication`,{body:{response:o},...r?.fetchOptions,...i,method:`POST`,throw:!1});return t.set(Math.random()),n.notify(`$sessionSignal`),r?.returnWebAuthnResponse?{...c,webauthn:{response:s,clientExtensionResults:a}}:c}catch(e){return console.error(`[Better Auth] Error verifying passkey`,e),{data:null,error:{code:`AUTH_CANCELLED`,message:Pc.AUTH_CANCELLED.message,status:400,statusText:`BAD_REQUEST`}}}}},passkey:{addPasskey:async(r,i)=>{let a=await e(`/passkey/generate-register-options`,{method:`GET`,query:{...r?.authenticatorAttachment&&{authenticatorAttachment:r.authenticatorAttachment},...r?.name&&{name:r.name},...r?.context&&{context:r.context}},throw:!1});if(!a.data)return a;try{let o=a.data.extensions||r?.extensions?{...a.data.extensions||{},...r?.extensions||{}}:void 0,s=await qc({optionsJSON:{...a.data,extensions:o},useAutoRegister:r?.useAutoRegister}),{clientExtensionResults:c,...l}=s,u=await e(`/passkey/verify-registration`,{...r?.fetchOptions,...i,body:{response:l,name:r?.name,...r?.createSession&&{createSession:!0}},method:`POST`,throw:!1});return u.data?(t.set(Math.random()),u.data.session&&n.notify(`$sessionSignal`),r?.returnWebAuthnResponse?{...u,webauthn:{response:s,clientExtensionResults:c}}:u):u}catch(e){return e instanceof Hc?e.code===`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`?{data:null,error:{code:e.code,message:Pc.PREVIOUSLY_REGISTERED.message,status:400,statusText:`BAD_REQUEST`}}:e.code===`ERROR_CEREMONY_ABORTED`?{data:null,error:{code:e.code,message:Pc.REGISTRATION_CANCELLED.message,status:400,statusText:`BAD_REQUEST`}}:{data:null,error:{code:e.code,message:e.message,status:400,statusText:`BAD_REQUEST`}}:{data:null,error:{code:`UNKNOWN_ERROR`,message:e instanceof Error?e.message:Pc.UNKNOWN_ERROR.message,status:500,statusText:`INTERNAL_SERVER_ERROR`}}}}},$Infer:{}}),Zl=()=>{let e=ol();return{id:`passkey`,version:Fc,$InferServerPlugin:{},getActions:(t,n)=>Xl(t,{$listPasskeys:e,$store:n}),getAtoms(t){return{listPasskeys:Vte(e,`/passkey/list-user-passkeys`,t,{method:`GET`}),$listPasskeys:e}},pathMethods:{"/passkey/register":`POST`,"/passkey/authenticate":`POST`},atomListeners:[{matcher(e){return e===`/passkey/verify-registration`||e===`/passkey/delete-passkey`||e===`/passkey/update-passkey`||e===`/sign-out`},signal:`$listPasskeys`},{matcher:e=>e===`/passkey/verify-authentication`,signal:`$sessionSignal`}],$ERROR_CODES:Pc}},Ql=Nc({OTP_EXPIRED:`OTP expired`,INVALID_OTP:`Invalid OTP`,TOO_MANY_ATTEMPTS:`Too many attempts`}),$l=()=>({id:`email-otp`,version:$c,$InferServerPlugin:{},atomListeners:[{matcher:e=>e===`/email-otp/verify-email`||e===`/sign-in/email-otp`||e===`/email-otp/request-email-change`,signal:`$sessionSignal`}],$ERROR_CODES:Ql}),eu=e=>{let t=e?.jwks?.jwksPath??`/jwks`;return{id:`better-auth-client`,version:$c,$InferServerPlugin:{},pathMethods:{[t]:`GET`},getActions:(e,n,r)=>({jwks:async n=>await e(t,{method:`GET`,...n})})}},tu=Nc({OTP_NOT_ENABLED:`OTP not enabled`,OTP_NOT_CONFIGURED:`OTP is not available`,OTP_HAS_EXPIRED:`OTP has expired`,TOTP_NOT_ENABLED:`TOTP not enabled`,TOTP_ALREADY_ENABLED:`TOTP is already enabled`,TOTP_NOT_CONFIGURED:`TOTP is not available`,TWO_FACTOR_NOT_ENABLED:`Two factor isn't enabled`,BACKUP_CODES_NOT_ENABLED:`Backup codes aren't enabled`,INVALID_BACKUP_CODE:`Invalid backup code`,INVALID_CODE:`Invalid code`,TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:`Too many attempts. Please request a new code.`,ACCOUNT_TEMPORARILY_LOCKED:`Too many failed verification attempts. Your account is temporarily locked. Please try again later.`,INVALID_TWO_FACTOR_COOKIE:`Invalid two factor cookie`}),nu=e=>({id:`two-factor`,version:$c,$InferServerPlugin:{},atomListeners:[{matcher:e=>e.startsWith(`/two-factor/`),signal:`$sessionSignal`}],pathMethods:{"/two-factor/disable":`POST`,"/two-factor/enable":`POST`,"/two-factor/send-otp":`POST`,"/two-factor/generate-backup-codes":`POST`,"/two-factor/get-totp-uri":`POST`,"/two-factor/verify-totp":`POST`,"/two-factor/verify-otp":`POST`,"/two-factor/verify-backup-code":`POST`},fetchPlugins:[{id:`two-factor`,name:`two-factor`,hooks:{async onSuccess(t){if(t.data?.twoFactorRedirect){if(e?.onTwoFactorRedirect){await e.onTwoFactorRedirect({twoFactorMethods:t.data.twoFactorMethods});return}e?.twoFactorPage&&typeof window<`u`&&Al(e.twoFactorPage)&&(window.location.href=e.twoFactorPage)}}}}],$ERROR_CODES:tu}),ru=(e,t,n)=>Yl({baseURL:e,basePath:t,plugins:[eu(),$l(),nu(),Zl()],fetchOptions:{customFetchImpl:n}}),iu=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):typeof e==`string`?JSON.parse(e):[],au=e=>{let t=e.split(`,`);return t.includes(`owner`)?`owner`:t.includes(`admin`)?`admin`:`member`},ou=e=>({id:e.id,userId:e.userId,name:e.user.name||e.user.email,email:e.user.email,role:au(e.role),appRoles:iu(e.appRoles),createdAt:new Date(e.createdAt).toISOString()}),su=e=>({id:e.id,email:e.email,role:au(e.role),appRoles:iu(e.appRoles),status:e.status,expiresAt:new Date(e.expiresAt).toISOString(),...e.organizationName&&{organizationName:e.organizationName}}),cu=(e,t)=>{let n=async(t,n,r={})=>{let{data:i,error:a}=await e.$fetch(t,{method:r.method??(r.body?`POST`:`GET`),...r.body&&{body:r.body},...r.query&&{query:r.query}});if(a)throw kc(a,n);return i},r=async e=>(await t(),e);return{list:async()=>await n(`/organization/list`,`Could not read your organizations`)??[],current:()=>n(`/organization/current`,`Could not read the current organization`),switchTo:async e=>r(await n(`/organization/switch`,`Could not switch the organization`,{body:{organizationId:e}})),search:(e,t=0)=>n(`/organization/search`,`Could not search the organizations`,{query:{query:e,...t>0&&{offset:String(t)}}}),create:async e=>r(await n(`/organization/create`,`Could not create the organization`,{body:e})),rename:(e,t)=>n(`/organization/update`,`Could not change the organization`,{body:{organizationId:e,data:t}}),remove:async e=>r(await n(`/organization/delete`,`Could not delete the organization`,{body:{organizationId:e}})),leave:async e=>r(await n(`/organization/leave`,`Could not leave the organization`,{body:{organizationId:e}})),members:async e=>(await n(`/organization/list-members`,`Could not read the members`,{query:{organizationId:e,limit:`1000`}})).members.map(ou),setRole:(e,t,r)=>n(`/organization/update-member-role`,`Could not change the role`,{body:{organizationId:e,memberId:t,role:r}}),setAppRoles:(e,t)=>n(`/organization/set-app-roles`,`Could not change the app roles`,{body:{memberId:e,appRoles:t}}),removeMember:(e,t)=>n(`/organization/remove-member`,`Could not remove the member`,{body:{organizationId:e,memberIdOrEmail:t}}),transferOwnership:(e,t=`admin`)=>n(`/organization/transfer-ownership`,`Could not hand the organization over`,{body:{memberId:e,keepAs:t}}),invitations:async e=>(await n(`/organization/list-invitations`,`Could not read the invitations`,{query:{organizationId:e}})??[]).map(su),invite:async(e,t)=>{let r=await n(`/organization/invite-member`,`Could not send the invitation`,{body:{organizationId:e,...t}});return{invitation:su(r),...r.link&&{link:r.link}}},resend:async(e,t)=>{let r=await n(`/organization/invite-member`,`Could not send the invitation again`,{body:{organizationId:e,email:t.email,role:t.role,resend:!0}});return{invitation:su(r),...r.link&&{link:r.link}}},revoke:e=>n(`/organization/cancel-invitation`,`Could not revoke the invitation`,{body:{invitationId:e}}),myInvitations:async()=>(await n(`/organization/list-user-invitations`,`Could not read your invitations`)??[]).map(su),invitation:e=>n(`/invitation`,`This invitation link is not valid`,{query:{token:e}}),accept:async e=>r(await n(`/invitation/accept`,`Could not accept the invitation`,{body:{token:e}})),signUpFromInvitation:async(e,t)=>r(await n(`/invitation/sign-up`,`Could not create your account`,{body:{token:e,...t}}))}},lu=(e,t)=>({current:async()=>{let{data:t,error:n}=await e.$fetch(`/role/current`,{method:`GET`});if(n)throw kc(n,`Could not read your roles`);return t},switchTo:async n=>{let{error:r}=await e.$fetch(`/role/switch`,{method:`POST`,body:{role:n}});if(r)throw kc(r,`Could not switch the role`);await t()}}),uu=20,du=e=>Array.isArray(e)?e:(e??``).split(`,`).map(e=>e.trim()).filter(Boolean),fu=e=>({id:e.id,name:e.name||e.email,email:e.email,roles:du(e.role),blocked:!!e.banned,createdAt:new Date(e.createdAt).toISOString()}),pu=e=>({id:e.id,email:e.email,roles:e.roles,expiresAt:new Date(e.expiresAt).toISOString()}),mu=e=>({invitation:pu(e),...e.link&&{link:e.link}}),hu=e=>{let t=async(t,n,r={})=>{let{data:i,error:a}=await e.$fetch(t,{method:r.body?`POST`:`GET`,...r.body&&{body:r.body},...r.query&&{query:r.query}});if(a)throw kc(a,n);return i};return{search:async(e,n=0)=>{let r=await t(`/admin/list-users`,`Could not read the users`,{query:{limit:String(uu),sortBy:`createdAt`,sortDirection:`asc`,...n>0&&{offset:String(n)},...e&&{searchValue:e,searchField:`email`}}});return{users:r.users.map(fu),total:r.total}},create:async e=>fu((await t(`/admin/create-user`,`Could not create the account`,{body:{email:e.email,name:e.name,role:e.roles,...e.password&&{password:e.password}}})).user),setRoles:(e,n)=>t(`/admin/set-role`,`Could not change the roles`,{body:{userId:e,role:n}}),block:e=>t(`/admin/ban-user`,`Could not block the account`,{body:{userId:e}}),unblock:e=>t(`/admin/unban-user`,`Could not unblock the account`,{body:{userId:e}}),invite:async e=>mu(await t(`/users/invite`,`Could not send the invitation`,{body:e})),invitations:async()=>(await t(`/users/invitations`,`Could not read the invitations`)).invitations.map(pu),revoke:e=>t(`/users/invitations/cancel`,`Could not revoke the invitation`,{body:{id:e}}),roles:()=>t(`/users/roles`,`Could not read the roles`)}},gu=(e,t)=>{let n=async e=>e?.twoFactorRedirect?{kind:`two-factor`,methods:e.twoFactorMethods??[]}:(await t(),{kind:`signed-in`,user:e?.user});return{signIn:async(t,r)=>{let{data:i,error:a}=await e.signIn.email({email:t,password:r});if(a||!i)throw kc(a,`Sign-in failed`);return n(i)},sendSignInCode:async t=>{let{error:n}=await e.emailOtp.sendVerificationOtp({email:t,type:`sign-in`});if(n)throw kc(n,`Could not send the code`)},signInWithCode:async(t,r)=>{let{data:i,error:a}=await e.signIn.emailOtp({email:t,otp:r});if(a||!i)throw kc(a,`Sign-in failed`);return n(i)},sendSignUpCode:async t=>{let{error:n}=await e.$fetch(`/sign-up/send-code`,{method:`POST`,body:{email:t}});if(n)throw kc(n,`Could not send the code`)},verifySignUpCode:async(t,n)=>{let{data:r,error:i}=await e.$fetch(`/sign-up/verify-code`,{method:`POST`,body:{email:t,code:n}});if(i||!r)throw kc(i,`Could not check the code`);return r.ticket},signUp:async n=>{let{data:r,error:i}=await e.$fetch(`/sign-up/create`,{method:`POST`,body:n});if(i||!r)throw kc(i,`Could not create your account`);return await t(),r.user},signInWithPasskey:async n=>{let r=await e.$fetch(`/passkey/generate-authenticate-options`,{method:`GET`,...n&&{query:{rpId:n}}});if(r.error||!r.data)throw kc(r.error,`Sign-in failed`);let{clientExtensionResults:i,...a}=await Qc({optionsJSON:r.data}).catch(e=>{throw new Oc(`Auth cancelled`,400,e instanceof Hc?e.code:`AUTH_CANCELLED`)}),o=await e.$fetch(`/passkey/verify-authentication`,{method:`POST`,body:{response:a}});if(o.error||!o.data)throw kc(o.error,`Sign-in failed`);return await t(),o.data.user},sendTwoFactorCode:async()=>{let{error:t}=await e.twoFactor.sendOtp();if(t)throw kc(t,`Could not send the code`)},verifyTwoFactor:async({method:n,code:r,trustDevice:i=!1})=>{let{data:a,error:o}=await(n===`totp`?e.twoFactor.verifyTotp:n===`otp`?e.twoFactor.verifyOtp:e.twoFactor.verifyBackupCode)({code:r,trustDevice:i});if(o||!a)throw kc(o,`The code did not work`);return await t(),a.user}}},_u=e=>({read:async()=>{let{data:t,error:n}=await e.$fetch(`/policy/sign-in`);if(n||!t)throw kc(n,`Could not read the sign-in policy`);return t},save:async t=>{let{data:n,error:r}=await e.$fetch(`/policy/sign-in`,{method:`POST`,body:t});if(r||!n)throw kc(r,`Could not save the sign-in policy`);return n}}),vu=e=>new Date(e).toISOString(),yu=({startedAt:e,expiresAt:t,endedAt:n,...r})=>({...r,startedAt:vu(e),expiresAt:vu(t),...n&&{endedAt:vu(n)}}),bu=e=>({start:async t=>{let{data:n,error:r}=await e.$fetch(`/staff/sign-in`,{method:`POST`,body:t});if(r||!n?.url)throw kc(r,`Could not start the staff sign-in`);return n.url},current:async()=>{let{data:t,error:n}=await e.$fetch(`/staff/session`);if(n||!t)throw kc(n,`Could not read the session`);return t.staff?yu(t.staff):void 0},stop:async()=>{let{error:t}=await e.$fetch(`/staff/stop`,{method:`POST`,body:{}});if(t)throw kc(t,`Could not end the staff session`)},log:async()=>{let{data:t,error:n}=await e.$fetch(`/staff/sign-ins`);if(n||!t)throw kc(n,`Could not read the staff sign-ins`);return t.signIns.map(yu)}}),xu=e=>{let t=e.split(`.`)[1];if(!t)throw Error(`Not a JWT`);let n=JSON.parse(atob(t.replace(/-/g,`+`).replace(/_/g,`/`)));if(typeof n.exp!=`number`)throw Error(`The token has no expiry`);return n.exp*1e3},Su=(e={})=>{let t=e.origin??globalThis.location?.origin??`http://localhost`,n=e.basePath??`/api/auth`,r=e.refreshMarginMs??6e4,i=e.fetch??((e,t)=>fetch(e,t)),a=ru(t,n,i),o=bu(a),c,l,u,d=()=>{c=void 0,clearTimeout(u)},f=async()=>{let{data:t}=await a.$fetch(`/token`);if(!t?.token){d();return}return c={token:t.token,expiresAt:xu(t.token)},clearTimeout(u),u=setTimeout(()=>void p({refresh:!0}).then(t=>t||e.onSignedOut?.()),Math.max(1e3,c.expiresAt-Date.now()-r)),c.token},p=async({refresh:e=!1}={})=>!e&&c&&c.expiresAt-Date.now()>r?c.token:(l??=f().finally(()=>{l=void 0}),l);return{token:p,status:async()=>{let e=await i(`${t}${n}/status`);if(e.status===404)throw new Oc(`This server has no sign-in. Is the API URL right?`,404);if(!e.ok)throw new Oc(`Could not read the sign-in status`,e.status);let r=await e.json();return{needsAdmin:!!r.needsAdmin,signInMethods:r.signInMethods??[`password`],passwordReset:!!r.passwordReset,...r.signUp&&{signUp:!0},socialProviders:r.socialProviders??[],...r.platformSignIn&&{platformSignIn:r.platformSignIn},samlProviders:r.samlProviders??[],...r.staffSignIn&&{staffSignIn:r.staffSignIn},...r.passkeyDomains&&{passkeyDomains:r.passkeyDomains},...r.organizations&&{organizations:r.organizations},...r.anonymous&&{anonymous:!0},...r.mcp&&{mcp:!0},...r.plugins&&r.plugins.length>0&&{plugins:r.plugins},...s(r.locale)&&{locale:r.locale}}},session:async()=>{let{data:e}=await a.getSession();return e?.user},...gu(a,()=>p({refresh:!0})),signInSocial:async(e,t)=>{let{data:n,error:r}=await a.signIn.social({provider:e,callbackURL:t,errorCallbackURL:t,disableRedirect:!0});if(r||!n?.url)throw kc(r,`Sign-in failed`);return n.url},signInSaml:async(e,t)=>{let{data:n,error:r}=await a.$fetch(`/sign-in/sso`,{method:`POST`,body:{providerId:e,callbackURL:t,errorCallbackURL:t}});if(r||!n?.url)throw kc(r,`Sign-in failed`);return n.url},signOut:async()=>{d(),await a.signOut()},requestPasswordReset:async(e,t)=>{let{error:n}=await a.requestPasswordReset({email:e,redirectTo:t});if(n)throw kc(n,`Could not send the reset link`)},resetPassword:async(e,t)=>{let{error:n}=await a.resetPassword({token:e,newPassword:t});if(n)throw kc(n,`Could not set the password`)},account:Ac(a),connect:Mc(a),organizations:cu(a,()=>p({refresh:!0})),roles:lu(a,()=>p({refresh:!0})),signInPolicy:_u(a),users:hu(a),staff:{...o,stop:async()=>{d(),await o.stop()}}}},Cu=e=>Math.min(3e4,1e3*2**e),wu=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),Tu=`http://same-origin.invalid`,Eu=(e,t)=>{let n=new URL(e,Tu),r=new URL(t,`${n.href}/`);if(r.origin!==n.origin)throw Error(`${t} is not on the assistant backend's origin`);return n.origin===Tu?`${r.pathname}${r.search}`:r.href},Du=e=>{let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>fetch(e,t)),r=e.retryDelayMs??Cu,i=async(r,i)=>{let a=await e.token(),o=await n(`${t}${r}`,{method:i.method,headers:{...i.body===void 0?{accept:`text/event-stream`}:{"content-type":`application/json`},...a&&{authorization:`Bearer ${a}`}},body:i.body===void 0?void 0:JSON.stringify(i.body),signal:i.signal});if(!o.ok)throw await Qs(o);return o},a=async(e,t,n)=>{let r=await i(`/events`,{method:`GET`,signal:e});if(!r.body)throw Error(`The assistant backend answered the event stream without a body`);n(),await Nr(r.body,e=>t(JSON.parse(e)),e)};return{connect:(e,t)=>{let n=new AbortController,{signal:i}=n;return(async()=>{let n=0;for(;!i.aborted;){t?.({state:`connecting`});let o=await a(i,e,()=>{n=0,t?.({state:`open`})}).then(()=>void 0,e=>e??Error(`The assistant stream failed`));if(i.aborted)return;t?.({state:`retrying`,...o!==void 0&&{error:o}}),await wu(r(n++),i)}})(),()=>n.abort()},send:async(e,t)=>{await i(`/messages`,{method:`POST`,body:{text:e,...t&&{page:t}}})},act:async(e,t)=>{await i(`/actions`,{method:`POST`,body:{partId:e,actionId:t}})},fetch:async(r,i={})=>{let a=Eu(t,r),o=await e.token(),s=new Headers(i.headers);o&&s.set(`authorization`,`Bearer ${o}`);let c=await n(a,{...i,headers:s});if(!c.ok)throw await Qs(c);return c}}},Ou=e=>typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!==null&&`code`in e.error&&`message`in e.error,ku=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.clone().json():void 0;return Ou(t)?new Js({type:`urn:protobase:problem:${t.error.code}`,title:e.statusText||`Request failed`,status:e.status,detail:t.error.message}):Qs(e)},Au=e=>{let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>fetch(e,t)),r=async(r,i)=>{let a=await e.token(),o=await n(`${t}${r}`,{method:i,headers:{accept:`application/json`,...a&&{authorization:`Bearer ${a}`}}});if(!o.ok)throw await ku(o);return await o.json()};return{status:()=>r(``,`GET`),update:()=>r(`/update`,`POST`)}},ju=e=>(0,L.useSyncExternalStore)(t=>{let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},()=>window.matchMedia(e).matches,()=>!1),Mu=()=>ju(`(min-width: 768px)`),Nu=()=>ju(`not all and (min-width: 640px)`),Pu=a({en:{navigation:`Navigation`,resources:`Resources`,breadcrumb:`Breadcrumb`,tabs:`Tabs`,more:`More`,openNavigation:`Open navigation`,backTo:e=>`Back to ${e}`,search:`Search`,closeSearch:`Close search`,clearSearch:`Clear search`,globalSearch:`Global search`,searchResults:`Search results`,searching:`Searching`,noMatches:e=>`No matches for “${e}”`,profileMenu:`Profile menu`,organizations:`Organizations`,roles:`Roles`,signIn:`Sign in`,signOut:`Sign out`,theme:`Theme`,light:`Light`,dark:`Dark`,system:`System`,recent:e=>`Recent ${e}`,loading:`Loading...`,couldNotLoad:`Could not load`,viewAll:`View all`,couldNotSearch:e=>`Could not search ${e.toLowerCase()}`},nl:{navigation:`Navigatie`,resources:`Onderdelen`,breadcrumb:`Kruimelpad`,tabs:`Tabbladen`,more:`Meer`,openNavigation:`Navigatie openen`,backTo:e=>`Terug naar ${e}`,search:`Zoeken`,closeSearch:`Zoeken sluiten`,clearSearch:`Zoekopdracht wissen`,globalSearch:`Overal zoeken`,searchResults:`Zoekresultaten`,searching:`Zoeken`,noMatches:e=>`Niets gevonden voor “${e}”`,profileMenu:`Profielmenu`,organizations:`Organisaties`,roles:`Rollen`,signIn:`Inloggen`,signOut:`Uitloggen`,theme:`Thema`,light:`Licht`,dark:`Donker`,system:`Systeem`,recent:e=>`Recente ${e}`,loading:`Laden...`,couldNotLoad:`Kon niet laden`,viewAll:`Alles bekijken`,couldNotSearch:e=>`Kon niet zoeken in ${e.toLowerCase()}`}}),z=t(_(),1),Fu=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Iu=`flex min-h-[49px] min-w-0 flex-1 flex-col items-center justify-center gap-1 pb-1 pt-1.5 text-[10px] font-medium leading-none`,Lu=({tabs:e,onNavigate:t,onMore:n,moreOpen:r,moreControls:i,sticky:a,ref:o})=>{let s=!e.some(e=>e.active);return(0,z.jsxs)(`nav`,{ref:o,"aria-label":Pu(`tabs`),className:g(`flex shrink-0 border-t bg-background pb-[env(safe-area-inset-bottom)] md:hidden`,a&&`sticky bottom-0 z-30`),children:[e.map(e=>{let n=e.icon;return(0,z.jsxs)(`a`,{href:e.href,"aria-current":e.active?`page`:void 0,...e.external?{target:`_blank`,rel:`noreferrer`}:{},onClick:n=>{!e.external&&t&&Fu(n)&&(n.preventDefault(),t(e.href))},className:g(Iu,e.active?`text-primary-text`:`text-muted-foreground`),children:[(0,z.jsx)(n,{className:`size-6`,strokeWidth:e.active?2.2:1.9,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`max-w-full truncate px-0.5`,children:e.label})]},e.id)}),(0,z.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":i,"data-current":s||void 0,onClick:n,className:g(Iu,s?`text-primary-text`:`text-muted-foreground`),children:[(0,z.jsx)(qi,{className:`size-6`,strokeWidth:s?2.2:1.9,"aria-hidden":!0}),Pu(`more`)]})]})},Ru=`data-pb-scroll-locked`,zu=()=>{let{body:e,documentElement:t}=document,n=e.style.overflow,r=t.hasAttribute(Ru);return window.innerWidth>t.clientWidth&&t.setAttribute(Ru,``),e.style.overflow=`hidden`,()=>{e.style.overflow=n,r||t.removeAttribute(Ru)}},Bu=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,Vu=[],Hu=(e,t,n)=>{let r=(0,L.useRef)(n);r.current=n,(0,L.useEffect)(()=>{if(!t||!e.current)return;let n=e.current,i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=zu(),o={};Vu.push(o);let s=()=>[...n.querySelectorAll(Bu)];(s()[0]??n).focus();let c=e=>{if(Vu.at(-1)!==o)return;if(e.key===`Escape`)return r.current();if(e.key!==`Tab`)return;let t=s();if(t.length===0)return e.preventDefault();let i=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===i?(e.preventDefault(),a.focus()):!e.shiftKey&&document.activeElement===a?(e.preventDefault(),i.focus()):n.contains(document.activeElement)||(e.preventDefault(),i.focus())};return document.addEventListener(`keydown`,c),()=>{document.removeEventListener(`keydown`,c),Vu.splice(Vu.indexOf(o),1),a(),i?.focus()}},[t,e])},Uu=({id:e,open:t,onClose:n,children:r})=>{let i=(0,L.useRef)(null);return Hu(i,t,n),t?(0,z.jsxs)(`div`,{className:`fixed inset-0 z-50 md:hidden`,children:[(0,z.jsx)(`div`,{className:`absolute inset-0 bg-backdrop/40`,onClick:n,"aria-hidden":!0}),(0,z.jsx)(`div`,{ref:i,id:e,role:`dialog`,"aria-modal":`true`,"aria-label":Pu(`navigation`),tabIndex:-1,className:`absolute inset-y-0 left-0 flex w-60 max-w-[85vw] bg-sidebar shadow-pop outline-none`,onClick:e=>e.target.closest(`a`)&&n(),children:r})]}):null},Wu=(0,L.createContext)(()=>{}),Gu=e=>{let t=(0,L.useContext)(Wu);(0,L.useLayoutEffect)(()=>(t(e),()=>t(void 0)),[t,e])},Ku=e=>{(0,L.useLayoutEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`scrollbar-gutter`,`stable`),()=>{t.style.removeProperty(`scrollbar-gutter`)}},[e])},qu=[`--pb-sticky-top`,`--pb-sticky-bottom`,`scroll-padding-top`,`scroll-padding-bottom`],Ju=(e,t,n,r)=>{(0,L.useLayoutEffect)(()=>{if(!e)return;let r=document.documentElement,i=()=>{let e=`${t.current?.offsetHeight??0}px`,i=`${n.current?.offsetHeight??0}px`;r.style.setProperty(`--pb-sticky-top`,e),r.style.setProperty(`--pb-sticky-bottom`,i),r.style.setProperty(`scroll-padding-top`,e),r.style.setProperty(`scroll-padding-bottom`,i)},a=new ResizeObserver(i);for(let e of[t.current,n.current])e&&a.observe(e);return i(),()=>{a.disconnect();for(let e of qu)r.style.removeProperty(e)}},[e,t,n,r])},Yu=({className:e})=>(0,z.jsx)(`span`,{className:g(`block h-3 rounded bg-muted [animation:pb-shimmer_1.4s_ease-in-out_infinite]`,e)}),Xu=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Zu=({parts:e,onNavigate:t})=>(0,z.jsx)(`nav`,{"aria-label":Pu(`breadcrumb`),className:`flex min-w-0 items-center gap-1.5`,children:e.map((n,r)=>{let i=r===e.length-1,{label:a,href:o,loading:s}=typeof n==`string`?{label:n,href:void 0,loading:!1}:n,c=s?(0,z.jsx)(Yu,{className:`w-24`}):a,l=g(`truncate`,i?`font-semibold`:`text-muted-foreground`);return(0,z.jsxs)(`span`,{className:g(`min-w-0 items-center gap-1.5`,i?`flex`:`hidden md:flex`),children:[r>0&&(0,z.jsx)(Di,{className:`hidden size-3.5 shrink-0 text-faint-foreground md:block`}),o?(0,z.jsx)(`a`,{href:o,"aria-current":i?`page`:void 0,"aria-label":s?a:void 0,"aria-busy":s||void 0,onClick:e=>{t&&Xu(e)&&(e.preventDefault(),t(o))},className:g(l,`rounded-sm hover:text-foreground hover:underline`),children:c}):(0,z.jsx)(`span`,{className:l,"aria-label":s?a:void 0,"aria-busy":s||void 0,children:c})]},`${r}-${a}`)})}),Qu=({to:e,onClick:t,...n})=>(0,z.jsx)(`a`,{href:e.href,onClick:n=>{t?.(n),!n.defaultPrevented&&Xu(n)&&(n.preventDefault(),e.onFollow())},...n}),$u=`M312.3 9.9Q257 9.9 217.1 -21.1Q177.3 -52.1 168.4 -108.8L181.1 -110.3V205H54.8V-510H176.7V-404.5L168.3 -407Q179.7 -460.8 221.2 -490.4Q262.7 -520 319.8 -520Q376.2 -520 417 -488.4Q457.8 -456.8 479.8 -398.6Q501.8 -340.5 501.8 -259.9Q501.8 -177.6 478.3 -116.8Q454.9 -55.9 412.5 -23Q370.1 9.9 312.3 9.9ZM274.4 -92.6Q320.2 -92.6 345.8 -133.8Q371.4 -175.1 371.4 -256.4Q371.4 -337.7 345.7 -377.6Q320.1 -417.5 274 -417.5Q228.6 -417.5 202.7 -376.4Q176.9 -335.3 176.9 -254Q176.9 -173.3 202.7 -132.9Q228.4 -92.6 274.4 -92.6Z M549.8 0V-510H671.7V-388.3H676.1V0H549.8ZM676.1 -286.5 661.3 -386.2Q677.9 -455.2 711.8 -487.6Q745.7 -520 794.3 -520Q809 -520 818 -516.6V-394.2Q814.2 -395.6 807.1 -396.1Q800 -396.6 789.4 -396.6Q734.6 -396.6 705.3 -370.5Q676.1 -344.4 676.1 -286.5Z M1043.8 10Q974.7 10 922.6 -23.6Q870.6 -57.2 842.1 -117.5Q813.6 -177.8 813.6 -257Q813.6 -336.5 842.2 -395.5Q870.8 -454.5 922.5 -487.2Q974.2 -520 1043.8 -520Q1113.7 -520 1165.4 -487.2Q1217.1 -454.5 1245.6 -395.5Q1274 -336.5 1274 -257Q1274 -177.8 1245.5 -117.5Q1217 -57.2 1165.3 -23.6Q1113.6 10 1043.8 10ZM1043.8 -90.5Q1073.5 -90.5 1095.9 -108.9Q1118.2 -127.3 1130.9 -164.4Q1143.6 -201.5 1143.6 -257.5Q1143.6 -339.8 1116 -379.7Q1088.4 -419.5 1043.8 -419.5Q999.3 -419.5 971.6 -379.5Q944 -339.5 944 -257.5Q944 -201.5 956.7 -164.4Q969.4 -127.3 991.8 -108.9Q1014.3 -90.5 1043.8 -90.5Z M1509 10.2Q1427.2 10.2 1387.6 -29.2Q1348 -68.6 1348 -147.7V-613.8L1474.2 -666.1V-146.7Q1474.2 -118.4 1489.9 -104.3Q1505.6 -90.3 1539.2 -90.3Q1552 -90.3 1562.7 -92.5Q1573.3 -94.8 1582.5 -98.7V-1.9Q1571.6 4 1552 7.1Q1532.4 10.2 1509 10.2ZM1270.1 -411V-510H1580.6V-411H1270.1Z M1810.8 10Q1741.7 10 1689.6 -23.6Q1637.6 -57.2 1609.1 -117.5Q1580.6 -177.8 1580.6 -257Q1580.6 -336.5 1609.2 -395.5Q1637.8 -454.5 1689.5 -487.2Q1741.2 -520 1810.8 -520Q1880.7 -520 1932.4 -487.2Q1984.1 -454.5 2012.6 -395.5Q2041 -336.5 2041 -257Q2041 -177.8 2012.5 -117.5Q1984 -57.2 1932.3 -23.6Q1880.6 10 1810.8 10ZM1810.8 -90.5Q1840.5 -90.5 1862.9 -108.9Q1885.2 -127.3 1897.9 -164.4Q1910.6 -201.5 1910.6 -257.5Q1910.6 -339.8 1883 -379.7Q1855.4 -419.5 1810.8 -419.5Q1766.3 -419.5 1738.6 -379.5Q1711 -339.5 1711 -257.5Q1711 -201.5 1723.7 -164.4Q1736.4 -127.3 1758.8 -108.9Q1781.3 -90.5 1810.8 -90.5Z M2343.3 9.9Q2288 9.9 2247.7 -21.1Q2207.4 -52.1 2198.5 -108.8L2205.8 -110.3V0H2085.8V-720H2212.1V-404.5L2203.7 -407Q2215.1 -460.8 2255.6 -490.4Q2296.2 -520 2351 -520Q2407.3 -520 2448 -488.4Q2488.8 -456.8 2510.8 -398.6Q2532.8 -340.5 2532.8 -259.9Q2532.8 -177.6 2509.3 -116.8Q2485.9 -55.9 2443.5 -23Q2401.1 9.9 2343.3 9.9ZM2305.4 -92.6Q2350.7 -92.6 2376.6 -133.8Q2402.4 -175.1 2402.4 -256.4Q2402.4 -337.7 2376.5 -377.6Q2350.6 -417.5 2305 -417.5Q2260.5 -417.5 2234.2 -376.4Q2207.9 -335.3 2207.9 -254Q2207.9 -173.3 2234.1 -132.9Q2260.3 -92.6 2305.4 -92.6Z M2834 0Q2828 -19.1 2825.7 -41.7Q2823.3 -64.2 2823.3 -91.8H2818.6V-356Q2818.6 -391.9 2803.1 -409.1Q2787.5 -426.3 2756.2 -426.3Q2724.2 -426.3 2706.4 -408.7Q2688.7 -391.2 2686.3 -358.9H2571.2Q2574.6 -429.6 2625.4 -474.8Q2676.1 -520 2763.5 -520Q2850.2 -520 2896.1 -476.5Q2941.9 -432.9 2941.9 -352.2V-91.8Q2941.9 -69.5 2944.7 -46.7Q2947.5 -23.8 2954.1 0H2834ZM2690.6 10Q2631.9 10 2595.4 -26.3Q2558.9 -62.5 2558.9 -124.5Q2558.9 -185 2594.3 -224Q2629.8 -263 2704.5 -287.6L2845.4 -337.4V-248.7L2753.4 -219.3Q2716.5 -206.1 2699.3 -186.6Q2682.2 -167.2 2682.2 -139Q2682.2 -112.4 2697.5 -98.4Q2712.9 -84.3 2739.4 -84.3Q2773.2 -84.3 2795.9 -104.1Q2818.6 -123.9 2818.6 -153.1L2829.9 -85.8Q2812.6 -37.4 2776.8 -13.7Q2741 10 2690.6 10Z M3168 10Q3080.6 10 3030.1 -34.2Q2979.6 -78.4 2974.7 -158.1H3082.4Q3086.3 -120 3108.9 -100.5Q3131.5 -80.9 3169.8 -80.9Q3202 -80.9 3218.9 -93.9Q3235.8 -106.9 3235.8 -131.3Q3235.8 -151.1 3224.3 -165.6Q3212.9 -180.1 3178.9 -195.4L3111.2 -224.8Q3053 -247.7 3023.8 -284.2Q2994.5 -320.8 2994.5 -373.9Q2994.5 -440.1 3040.1 -480Q3085.7 -520 3162.8 -520Q3242.2 -520 3288.4 -480Q3334.6 -440 3339.5 -367.9H3231.8Q3228.6 -399.7 3211.3 -414.4Q3194 -429.1 3164 -429.1Q3136.1 -429.1 3120.5 -417Q3104.8 -405 3104.8 -382.7Q3104.8 -364.2 3117.7 -349.8Q3130.6 -335.5 3162.4 -321.6L3236.6 -289.6Q3288.6 -269.2 3317.4 -229.2Q3346.1 -189.1 3346.1 -136.9Q3346.1 -69 3299.2 -29.5Q3252.3 10 3168 10Z M3587.8 10Q3520 10 3469.2 -23.3Q3418.5 -56.6 3390.5 -116.5Q3362.6 -176.3 3362.6 -255.8Q3362.6 -336.4 3390.9 -395.7Q3419.3 -454.9 3470.7 -487.5Q3522 -520 3591.1 -520Q3656.6 -520 3702.7 -489.8Q3748.8 -459.7 3773.7 -403.1Q3798.6 -346.5 3798.6 -266.5Q3798.6 -253.7 3798 -242.5Q3797.5 -231.3 3795.8 -221.4H3440V-306.9H3709L3681.8 -277.9Q3681.6 -355.2 3657.7 -390.7Q3633.8 -426.3 3589.3 -426.3Q3541.7 -426.3 3515.6 -384Q3489.5 -341.7 3489.5 -255Q3489.5 -168.4 3515 -126.1Q3540.5 -83.7 3590.6 -83.7Q3623.7 -83.7 3644.6 -102Q3665.5 -120.3 3673.8 -156.3H3788.9Q3772.2 -81.6 3721.5 -35.8Q3670.8 10 3587.8 10Z`,ed=`fill-[#ff5a1f] dark:fill-[#ff6a33]`,td=`fill-[#14161a] dark:fill-[#f1f0ea]`,nd=({className:e})=>(0,z.jsxs)(`svg`,{viewBox:`0 0 32 32`,className:g(`size-7 shrink-0`,e),"aria-hidden":!0,children:[(0,z.jsx)(`path`,{className:ed,fillRule:`evenodd`,d:`M0 5a5 5 0 0 1 5-5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zM4 5a1 1 0 0 1 1-1h5v6H4z`}),(0,z.jsx)(`path`,{className:td,d:`M17 0h10a5 5 0 0 1 5 5v22a5 5 0 0 1-5 5H5a5 5 0 0 1-5-5V17h17z`})]}),rd=({className:e})=>(0,z.jsx)(`svg`,{viewBox:`54.8 -720 3743.8 925`,className:g(`h-3.5 w-auto`,e),role:`img`,"aria-label":`Protobase`,children:(0,z.jsx)(`path`,{className:td,d:$u})}),id=`Protobase`,ad=({compact:e,workspace:t,appName:n,appIcon:r})=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5 overflow-hidden`,children:[r?(0,z.jsx)(`img`,{src:r,alt:``,className:`size-7 shrink-0 object-contain`}):(0,z.jsx)(nd,{}),!e&&(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 leading-tight`,children:[r||n&&n!==id?(0,z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:n??id}):(0,z.jsx)(rd,{className:`self-start`}),t&&(0,z.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:t})]})]}),od=[{label:`Sales`,items:[{id:`orders`,label:`Orders`,icon:ko,count:12},{id:`customers`,label:`Customers`,icon:mi},{id:`invoices`,label:`Invoices`,icon:ta,count:3}]},{label:`Inventory`,items:[{id:`products`,label:`Products`,icon:qa},{id:`stock-moves`,label:`Stock moves`,icon:fi},{id:`warehouses`,label:`Warehouses`,icon:is},{id:`shipments`,label:`Shipments`,icon:Xo}]},{label:`Finance`,items:[{id:`payments`,label:`Payments`,icon:Bi},{id:`credit-notes`,label:`Credit notes`,icon:co},{id:`reports`,label:`Reports`,icon:zee}]},{label:`Admin`,items:[{id:`users`,label:`Users`,icon:ts},{id:`settings`,label:`Settings`,icon:To}]}],sd={xs:`size-5 text-[9px]`,sm:`size-6 text-[10px]`,md:`size-8 text-xs`},cd=({initials:e,hue:t,size:n=`sm`,className:r})=>(0,z.jsx)(`span`,{className:g(`inline-flex shrink-0 select-none items-center justify-center rounded-full font-semibold text-white ring-2 ring-background`,sd[n],r),style:{background:`oklch(0.58 0.13 ${t})`},children:e}),ld=({people:e,size:t=`sm`})=>(0,z.jsx)(`span`,{className:`inline-flex -space-x-1`,children:e.map(e=>(0,z.jsx)(cd,{...e,size:t},e.initials))}),ud=e=>{let t=e.slice(1),n=t.length===3?[...t].map(e=>e+e).join(``):t,[r,i,a]=[0,2,4].map(e=>{let t=Number.parseInt(n.slice(e,e+2),16)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a},dd=`#ffffff`,fd=`#111827`,pd=e=>{let t=ud(e);return 1.05/(t+.05)>=(t+.05)/(ud(fd)+.05)?dd:fd},md={neutral:`bg-muted text-muted-foreground`,blue:`bg-primary-soft text-primary-text`,green:`bg-success-soft text-success-text`,amber:`bg-warning-soft text-warning-text`,red:`bg-danger-soft text-danger-text`,violet:`bg-violet-soft text-violet-text`},hd={neutral:`bg-faint-foreground`,blue:`bg-primary`,green:`bg-success`,amber:`bg-warning`,red:`bg-danger`,violet:`bg-violet`},gd=`polygon(0 0, calc(100% - 0.625rem) 0, 100% 50%, calc(100% - 0.625rem) 100%, 0 100%)`,_d=({tone:e=`neutral`,dot:t=!0,color:n,shape:r,children:i,className:a})=>(0,z.jsxs)(`span`,{style:{...n!==void 0&&{backgroundColor:n,color:pd(n)},...r===`arrow`&&{clipPath:gd}},className:g(r===`arrow`?`inline-flex h-5 items-center gap-1.5 rounded-l-sm pr-4 pl-2 text-xs font-semibold whitespace-nowrap`:`inline-flex h-5 items-center gap-1.5 rounded-full px-2 text-xs font-medium whitespace-nowrap`,n===void 0&&md[e],a),children:[t&&n===void 0&&r===void 0&&(0,z.jsx)(`span`,{className:g(`size-1.5 rounded-full`,hd[e])}),i]}),vd=({label:e,current:t,others:n,rowClassName:r,onSwitch:i})=>(0,z.jsxs)(`div`,{className:`border-b py-1`,role:`group`,"aria-label":e,children:[t&&(0,z.jsxs)(`div`,{className:g(r,`text-foreground hover:bg-transparent`),"aria-current":`true`,children:[(0,z.jsx)(xi,{className:`size-4`}),(0,z.jsx)(`span`,{className:`truncate`,children:t.label})]}),n.map(e=>(0,z.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>i(e.id),className:r,children:[(0,z.jsx)(`span`,{className:`size-4`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))]}),yd=()=>[{value:`light`,label:Pu(`light`),icon:fte},{value:`dark`,label:Pu(`dark`),icon:cte},{value:`system`,label:Pu(`system`),icon:Ha}],bd=({theme:e,className:t})=>(0,z.jsxs)(`div`,{className:t,children:[(0,z.jsx)(dte,{className:`size-4`}),(0,z.jsx)(`span`,{className:`flex-1`,children:Pu(`theme`)}),(0,z.jsx)(f,{label:Pu(`theme`),iconOnly:!0,value:e.preference,options:yd(),onChange:e.onChange})]}),xd=`flex min-h-11 w-full items-center gap-2.5 px-3 py-1.5 text-left text-muted-foreground hover:bg-muted md:min-h-0`,Sd=({user:e,compact:t,open:n,items:r=[],onNavigate:i,onSignOut:a,organizations:o,roles:s,theme:c})=>{let l=s?.roles.find(e=>e.name===s.active),[u,d]=(0,L.useState)(!1),f=n??u,p=(0,L.useRef)(null),[m,h]=(0,L.useState)();return(0,L.useEffect)(()=>{if(!f||n!==void 0)return;let e=e=>{(e instanceof KeyboardEvent?e.key===`Escape`:!p.current?.contains(e.target))&&d(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[f,n]),(0,z.jsxs)(`div`,{ref:p,className:`relative`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-2.5 rounded-md p-1 text-left hover:bg-muted md:min-h-0`,"aria-label":Pu(`profileMenu`),"aria-haspopup":`menu`,"aria-expanded":f,onClick:()=>{let e=p.current?.getBoundingClientRect();e&&h({left:e.left,bottom:window.innerHeight-e.top+8}),d(!u)},children:[(0,z.jsx)(cd,{initials:e.initials,hue:e.hue,size:`md`,className:`ring-0`}),!t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1 leading-tight`,children:[(0,z.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,z.jsx)(_d,{tone:e.roleTone,dot:!1,className:`mt-0.5 h-4 px-1.5 text-[10px]`,children:e.role})]}),(0,z.jsx)(ki,{className:`size-3.5 shrink-0 text-faint-foreground`})]})]}),f&&(0,z.jsxs)(`div`,{role:`menu`,className:n===void 0?`fixed z-[60] w-56 overflow-hidden rounded-lg border bg-background py-1 shadow-pop`:`absolute bottom-full left-0 z-50 mb-2 w-56 overflow-hidden rounded-lg border bg-background py-1 shadow-pop`,style:n===void 0&&m?{left:m.left,bottom:m.bottom}:void 0,children:[(0,z.jsxs)(`div`,{className:`border-b px-3 pb-2 pt-1.5`,children:[(0,z.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.email})]}),o&&(o.current||o.others.length>0)&&(0,z.jsx)(vd,{label:Pu(`organizations`),...o.current&&{current:{id:o.current.id,label:o.current.name}},others:o.others.map(({id:e,name:t})=>({id:e,label:t})),rowClassName:xd,onSwitch:e=>{d(!1),o.onSwitch(e)}}),s&&s.roles.length>1&&(0,z.jsx)(vd,{label:Pu(`roles`),...l&&{current:{id:l.name,label:l.label}},others:s.roles.filter(e=>e!==l).map(({name:e,label:t})=>({id:e,label:t})),rowClassName:xd,onSwitch:e=>{d(!1),s.onSwitch(e)}}),r.length>0&&(0,z.jsx)(`div`,{className:g((c||a)&&`border-b`),children:r.map(e=>{let t=e.icon;return(0,z.jsxs)(`a`,{role:`menuitem`,href:e.href,"aria-current":e.active?`page`:void 0,...e.external?{target:`_blank`,rel:`noreferrer`}:{},onClick:t=>{d(!1),!e.external&&i&&(t.preventDefault(),i(e.href))},className:g(xd,e.active&&`bg-muted text-foreground`),children:[(0,z.jsx)(t,{className:`size-4`}),e.label]},e.id)})}),c&&(0,z.jsx)(`div`,{className:g(a&&`border-b`),children:(0,z.jsx)(bd,{theme:c,className:g(xd,`hover:bg-transparent`)})}),a&&(0,z.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:a,className:xd,children:[(0,z.jsx)(Aa,{className:`size-4`}),Pu(`signOut`)]})]})]})},Cd=`protobase:nav-open:`,wd=e=>`${Cd}${e}`,Td=(e,t)=>u(()=>e.getItem(t)!==`false`,!0),Ed=(e,t,n)=>u(()=>n?e.removeItem(t):e.setItem(t,`false`),void 0),Dd=({label:e,side:t=`right`,visible:n,children:r})=>(0,z.jsxs)(`span`,{className:`group/tooltip relative inline-flex`,children:[r,(0,z.jsx)(`span`,{role:`tooltip`,className:g(`pointer-events-none absolute z-50 whitespace-nowrap rounded-md bg-foreground px-2 py-1 text-xs font-medium text-background opacity-0 shadow-md transition-opacity group-hover/tooltip:opacity-100`,n&&`opacity-100`,t===`right`&&`left-full top-1/2 ml-2 -translate-y-1/2`,t===`top`&&`bottom-full left-1/2 mb-2 -translate-x-1/2`,t===`bottom`&&`left-1/2 top-full mt-2 -translate-x-1/2`),children:e})]}),Od=e=>e===`text-large`||e===`text-small`||e===`icon-expand`,kd=e=>e===`text-large`||e===`text-small`,Ad={"text-large":`w-60`,"text-small":`w-52`,icon:`w-14`,"icon-label":`w-[76px]`,"icon-tooltip":`w-14`,"icon-expand":`w-14`},jd={"text-large":`h-9 gap-3 px-3 text-sm`,"text-small":`h-7 gap-2.5 px-2.5 text-body`,icon:`size-9 justify-center`,"icon-label":`w-full flex-col gap-0.5 py-1.5 text-[10px]`,"icon-tooltip":`size-9 justify-center`,"icon-expand":`h-8 gap-3 px-3`},Md=({item:e,mode:t,active:n,onNavigate:r,className:i})=>{let a=e.icon,o=(0,z.jsxs)(`a`,{onClick:r&&(t=>{t.preventDefault(),r(e.href??`#${e.id}`)}),href:e.href??`#${e.id}`,"aria-label":e.problem?`${e.label}: ${e.problem}`:e.label,"aria-current":n?`page`:void 0,title:e.problem,className:g(`flex shrink-0 items-center rounded-md font-medium transition-colors`,jd[t],n?`bg-primary-soft text-primary-text`:`text-muted-foreground hover:bg-muted hover:text-foreground`,i),children:[(0,z.jsx)(a,{className:g(`shrink-0`,t===`text-small`?`size-4`:`size-[18px]`),strokeWidth:n?2.2:1.9}),(Od(t)||t===`icon-label`)&&(0,z.jsx)(`span`,{className:`whitespace-nowrap`,children:e.label}),kd(t)&&e.count&&(0,z.jsx)(`span`,{className:`ml-auto rounded bg-muted px-1.5 text-[11px] tabular-nums text-muted-foreground`,children:e.count}),kd(t)&&e.problem&&(0,z.jsx)(Jo,{"aria-hidden":!0,className:`ml-auto size-3.5 shrink-0 text-warning-text`})]});return t===`icon-tooltip`?(0,z.jsx)(Dd,{label:e.label,children:o}):o},Nd={neutral:`bg-faint-foreground`,info:`bg-primary`,success:`bg-success`,warning:`bg-warning`,danger:`bg-danger`},Pd=({tone:e,pulse:t=!1,className:n})=>(0,z.jsxs)(`span`,{"aria-hidden":!0,className:g(`relative flex size-2 shrink-0`,n),"data-tone":e,"data-pulse":t||void 0,children:[t&&(0,z.jsx)(`span`,{className:g(`absolute inset-0 animate-ping rounded-full opacity-60 motion-reduce:animate-none`,Nd[e])}),(0,z.jsx)(`span`,{className:g(`relative size-2 rounded-full`,Nd[e])})]}),Fd={"text-large":`h-8 gap-2.5 px-2.5`,"text-small":`h-7 gap-2 px-2 text-body`},Id={"text-large":`ml-[20px]`,"text-small":`ml-[17px]`},Ld=({item:e,recent:t,mode:n,active:r,onNavigate:i})=>{let a=wd(e.id),[o,s]=(0,L.useState)(()=>Td(localStorage,a)),c=(0,L.useId)(),l=e.href??`#${e.id}`,u=()=>{Ed(localStorage,a,!o),s(!o)},d=e=>({href:e,onClick:i&&(t=>{t.preventDefault(),i(e)})});return(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(Md,{item:e,mode:n,active:r,onNavigate:i,className:`pr-8`}),(0,z.jsx)(`button`,{type:`button`,"aria-expanded":o,"aria-controls":c,"aria-label":Pu(`recent`,e.label.toLowerCase()),onClick:u,className:`absolute right-1 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground`,children:(0,z.jsx)(Di,{className:g(`size-3.5 transition-transform`,o&&`rotate-90`)})})]}),o&&(0,z.jsxs)(`ul`,{id:c,"aria-label":Pu(`recent`,e.label.toLowerCase()),className:g(`flex flex-col gap-0.5 border-l pl-1.5`,Id[n]),children:[t.state===`loading`&&(0,z.jsx)(`li`,{className:g(`flex items-center text-faint-foreground`,Fd[n]),children:Pu(`loading`)}),t.state===`error`&&(0,z.jsx)(`li`,{className:g(`flex items-center text-faint-foreground`,Fd[n]),children:Pu(`couldNotLoad`)}),t.state===`ready`&&t.records.map(e=>(0,z.jsx)(`li`,{children:(0,z.jsxs)(`a`,{...d(e.href),"aria-label":`${e.label}, ${e.status}`,title:`${e.label} (${e.status})`,"aria-current":e.active?`page`:void 0,className:g(`flex min-w-0 items-center rounded-md font-medium transition-colors`,Fd[n],e.active?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,z.jsx)(Pd,{tone:e.tone,pulse:e.pulse}),(0,z.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.id)),(0,z.jsx)(`li`,{children:(0,z.jsx)(`a`,{...d(l),className:g(`flex items-center rounded-md text-faint-foreground transition-colors hover:bg-muted hover:text-foreground`,Fd[n]),children:Pu(`viewAll`)})})]})]})},Rd=({mode:e,activeItem:t,user:n,workspace:r,appName:i,appIcon:a,forceExpanded:o,profileMenuOpen:s,groups:c=od,userMenu:l,onNavigate:u,onSignOut:d,signIn:f,organizations:p,roles:m,theme:h,sticky:_,logo:v=ad})=>{let y=e===`icon-expand`,b=y&&o,x=kd(e)||y;return(0,z.jsx)(`nav`,{"aria-label":Pu(`resources`),className:g(_?`sticky top-0 h-dvh self-start`:`relative`,`z-30 shrink-0`,Ad[e]),children:(0,z.jsxs)(`div`,{className:g(`group/side absolute inset-y-0 left-0 flex flex-col overflow-hidden border-r bg-sidebar`,y?`w-14 transition-[width,box-shadow] duration-150 hover:w-60 hover:shadow-pop focus-within:w-60 focus-within:shadow-pop`:`w-full`,b&&`w-60 shadow-pop`),children:[(0,z.jsx)(`div`,{className:g(`flex h-12 shrink-0 items-center px-3.5`,e===`icon-label`&&`justify-center px-0`),children:(0,z.jsx)(v,{compact:!x,workspace:r,appName:i,appIcon:a})}),(0,z.jsx)(`div`,{className:g(`flex-1 overflow-y-auto overflow-x-hidden pb-2`,`px-2`),children:c.map((n,r)=>(0,z.jsxs)(`div`,{className:g(`flex flex-col gap-0.5`,r>0&&`mt-3`),children:[x?(0,z.jsx)(`div`,{className:g(`px-3 pb-1 pt-1 text-xs font-medium uppercase tracking-wide text-faint-foreground`,y&&`h-4 whitespace-nowrap py-0 opacity-0 transition-opacity group-hover/side:opacity-100 group-focus-within/side:opacity-100`,b&&`opacity-100`),children:n.label}):r>0&&(0,z.jsx)(`div`,{className:`mx-auto mb-1 h-px w-6 bg-border`}),n.items.map(n=>n.recent&&kd(e)?(0,z.jsx)(Ld,{item:n,recent:n.recent,mode:e,active:n.id===t,onNavigate:u},n.id):(0,z.jsx)(Md,{item:n,mode:e,active:n.id===t,onNavigate:u},n.id))]},n.label))}),(0,z.jsx)(`div`,{className:g(`shrink-0 border-t p-2`,e!==`text-large`&&e!==`text-small`&&!y&&`flex justify-center`),children:n?(0,z.jsx)(Sd,{user:n,compact:!x,open:s,items:l,onNavigate:u,onSignOut:d,organizations:p,roles:m,theme:h}):(0,z.jsxs)(z.Fragment,{children:[h&&x&&(0,z.jsx)(bd,{theme:h,className:`flex min-h-11 w-full items-center gap-2.5 whitespace-nowrap p-1.5 text-muted-foreground md:min-h-0`}),f&&(0,z.jsxs)(Qu,{to:f,"aria-label":Pu(`signIn`),className:`flex min-h-11 w-full items-center gap-2.5 rounded-md p-1.5 text-left font-medium text-muted-foreground hover:bg-muted hover:text-foreground md:min-h-0`,children:[(0,z.jsx)(Oa,{className:`size-4 shrink-0`}),x&&(0,z.jsx)(`span`,{className:`whitespace-nowrap`,children:Pu(`signIn`)})]})]})})]})})},zd=(0,L.createContext)(null),Bd=()=>(0,L.useContext)(zd),Vd=e=>{let t=e.at(-2);if(typeof t==`object`&&t.href&&!t.loading)return{label:t.label,href:t.href}},Hd=(0,L.createContext)(void 0),Ud=()=>{let e=(0,L.useContext)(Hd);return e?{id:e.id,name:e.name,"aria-describedby":e.describedBy,"aria-invalid":e.invalid||void 0,"aria-required":e.required||void 0}:{}},Wd=({leading:e,trailing:t,invalid:n,className:r,wrapperClassName:i,...a})=>{let o=Ud();return(0,z.jsxs)(`span`,{className:g(`flex h-8 items-center gap-2 rounded-md border bg-background px-2.5 text-muted-foreground shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20`,n?`border-danger`:`border-border-strong`,i),children:[e,(0,z.jsx)(`input`,{className:g(`min-w-0 flex-1 bg-transparent text-body text-foreground outline-none placeholder:text-faint-foreground`,r),...o,...n&&{"aria-invalid":!0},...a}),t]})},Gd=({children:e})=>(0,z.jsx)(`kbd`,{className:`inline-flex h-5 items-center rounded border border-border-strong bg-background px-1.5 font-sans text-[11px] font-medium text-muted-foreground`,children:e}),Kd=a({en:{close:`Close`,loading:`Loading`,remove:e=>`Remove ${e}`},nl:{close:`Sluiten`,loading:`Laden`,remove:e=>`${e} verwijderen`}}),qd=({className:e})=>(0,z.jsx)(ote,{"aria-label":Kd(`loading`),className:g(`size-4 animate-spin`,e)}),Jd=(e,t,n)=>t===0?-1:e<0?n===1?0:t-1:(e+n+t)%t,Yd=e=>e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0,Xd=({search:e,className:t=`w-96`,autoFocus:n,showShortcut:r=!0,ref:i})=>{let a=(0,L.useId)(),o=(0,L.useRef)(null),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(-1),d=e.groups.flatMap(e=>e.hits),f=s&&(e.query!==``||e.loading),p=e=>`${a}-${e}`,m=e=>{o.current=e,typeof i==`function`?i(e):i&&(i.current=e)},h=t=>{e.onSelect(t),u(-1),o.current?.blur()},_=()=>{e.onTextChange(``),u(-1),o.current?.focus()},v=t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`)t.preventDefault(),u(e=>Jd(e,d.length,t.key===`ArrowDown`?1:-1));else if(t.key===`Enter`){let e=d[l]??d[0];if(!e)return;t.preventDefault(),h(e.href)}else t.key===`Escape`&&(e.text?e.onTextChange(``):t.currentTarget.blur(),u(-1))},y=-1;return(0,z.jsxs)(`div`,{className:g(`relative`,t),children:[(0,z.jsx)(Wd,{ref:m,wrapperClassName:`w-full bg-surface shadow-none`,leading:e.loading?(0,z.jsx)(qd,{className:`size-4`}):(0,z.jsx)(_o,{className:`size-4`}),trailing:e.text?(0,z.jsx)(`button`,{type:`button`,"aria-label":Pu(`clearSearch`),className:`-mr-1 inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground`,onMouseDown:e=>e.preventDefault(),onClick:_,children:(0,z.jsx)(ss,{className:`size-3.5`})}):r?(0,z.jsx)(`span`,{className:`hidden md:inline-flex`,children:(0,z.jsx)(Gd,{children:`⌘K`})}):void 0,placeholder:e.placeholder,"aria-label":Pu(`globalSearch`),role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":f,"aria-controls":a,"aria-activedescendant":f&&d[l]?p(l):void 0,autoFocus:n,value:e.text,onChange:t=>{e.onTextChange(t.target.value),u(-1)},onFocus:()=>c(!0),onBlur:()=>c(!1),onKeyDown:v}),f&&(0,z.jsxs)(`div`,{id:a,role:`listbox`,"aria-label":Pu(`searchResults`),className:`absolute right-0 top-full z-40 mt-1 max-h-96 w-full min-w-72 overflow-y-auto rounded-lg border bg-background py-1 shadow-pop`,children:[e.groups.length===0&&(0,z.jsx)(`p`,{className:`px-3 py-2 text-muted-foreground`,children:e.loading?Pu(`searching`):Pu(`noMatches`,e.query)}),e.groups.map(e=>(0,z.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,z.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[11px] font-medium uppercase tracking-wide text-faint-foreground`,children:e.label}),e.failed&&(0,z.jsx)(`p`,{className:`px-3 py-1.5 text-danger-text`,children:Pu(`couldNotSearch`,e.label)}),e.hits.map(e=>{y+=1;let t=y;return(0,z.jsxs)(`a`,{id:p(t),href:e.href,tabIndex:-1,role:`option`,"aria-selected":t===l,className:g(`block px-3 py-1.5`,t===l?`bg-primary-soft text-primary-text`:`hover:bg-muted`),onMouseDown:e=>e.preventDefault(),onClick:t=>{Yd(t)||(t.preventDefault(),h(e.href))},onMouseEnter:()=>u(t),children:[(0,z.jsx)(`span`,{className:`block truncate font-semibold`,children:e.title}),e.subtitle&&(0,z.jsx)(`span`,{className:g(`block truncate text-xs`,t===l?`text-primary-text/80`:`text-muted-foreground`),children:e.subtitle})]},e.id)})]},e.id))]})]})},Zd=({breadcrumb:e,onNavigate:t,actions:n,onMenu:r,menuOpen:i,menuControls:a,search:o,sticky:s,slotRef:c,ref:l})=>{let[u,d]=(0,L.useState)(!1),f=Vd(e),p=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(!o)return;let e=e=>{if(e.key.toLowerCase()!==`k`||!(e.metaKey||e.ctrlKey))return;e.preventDefault();let t=p.current;t&&t.offsetParent!==null?t.focus():d(!0)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]),(0,z.jsxs)(`header`,{ref:l,className:g(s?`sticky top-0 z-30`:`relative`,`flex h-12 shrink-0 items-center gap-1 border-b bg-background pl-4 pr-2 md:gap-4 md:px-5`),children:[r&&(0,z.jsx)(`button`,{type:`button`,"aria-label":Pu(`openNavigation`),"aria-expanded":!!i,"aria-controls":a,onClick:r,className:g(`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden`,`-ml-3`),children:(0,z.jsx)(Ra,{className:`size-5`})}),f&&(0,z.jsx)(`a`,{href:f.href,"aria-label":Pu(`backTo`,f.label),onClick:e=>{t&&Xu(e)&&(e.preventDefault(),t(f.href))},className:g(`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden`,!r&&`-ml-3`),children:(0,z.jsx)(Ti,{className:`size-5`})}),(0,z.jsx)(Zu,{parts:e,onNavigate:t}),(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1 md:gap-3`,children:[o&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`hidden md:block`,children:(0,z.jsx)(Xd,{ref:p,search:o})}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Pu(`search`),"aria-expanded":u,onClick:()=>d(!0),className:`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden`,children:(0,z.jsx)(_o,{className:`size-5`})})]}),n,(0,z.jsx)(`div`,{ref:c,className:`contents md:hidden`})]}),o&&u&&(0,z.jsxs)(`div`,{className:`absolute inset-0 z-20 flex items-center gap-1 bg-background px-3 md:hidden`,children:[(0,z.jsx)(Xd,{className:`min-w-0 flex-1`,autoFocus:!0,showShortcut:!1,search:{...o,onSelect:e=>{o.onSelect(e),d(!1)}}}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Pu(`closeSearch`),onClick:()=>d(!1),className:`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden`,children:(0,z.jsx)(ss,{className:`size-5`})})]})]})},Qd=`app-drawer`,$d=({sidebarMode:e,activeItem:t,breadcrumb:n,user:r,workspace:i,appName:a,appIcon:o,logo:s,actions:c,rightPanel:l,forceExpanded:u,profileMenuOpen:d,navGroups:f,userMenu:p,bottomBar:m,onNavigate:h,onSignOut:_,signIn:v,organizations:y,roles:b,theme:x,search:S,pageScroll:C=!1,className:w,children:T})=>{let E=Mu(),[D,O]=(0,L.useState)(!1);(0,L.useEffect)(()=>{E&&O(!1)},[E]);let k=!E&&m&&m.length>0?m:void 0,[A,j]=(0,L.useState)(),M=A??C,N=(0,L.useRef)(null),[P,ee]=(0,L.useState)(null),te=(0,L.useRef)(null);Ju(M,N,te,!!k),Ku(M);let ne=(e,n=!1)=>(0,z.jsx)(Rd,{mode:e,sticky:n,activeItem:t,user:r,workspace:i,appName:a,appIcon:o,forceExpanded:u,profileMenuOpen:d,groups:f,userMenu:p,onNavigate:h,onSignOut:_,signIn:v,organizations:y,roles:b,theme:x,logo:s});return(0,z.jsx)(Wu.Provider,{value:j,children:(0,z.jsxs)(`div`,{className:g(M?`flex min-h-full w-full overflow-x-clip bg-background`:`relative flex h-full min-h-0 w-full overflow-hidden bg-background`,w),children:[E?ne(e,M):(0,z.jsx)(Uu,{id:Qd,open:D,onClose:()=>O(!1),children:ne(`text-large`)}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(Zd,{ref:N,slotRef:ee,sticky:M,breadcrumb:n,onNavigate:h,actions:c,onMenu:E||k?void 0:()=>O(!0),menuOpen:D,menuControls:Qd,search:S}),(0,z.jsx)(`main`,{className:M?`flex flex-1 flex-col`:`flex min-h-0 flex-1 flex-col`,children:(0,z.jsx)(zd.Provider,{value:P,children:T})}),k&&(0,z.jsx)(Lu,{ref:te,sticky:M,tabs:k,onNavigate:h,onMore:()=>O(!0),moreOpen:D,moreControls:Qd})]}),l&&(0,z.jsx)(`div`,{className:M?`sticky top-0 flex h-dvh shrink-0 self-start`:`flex shrink-0`,children:l})]})})},ef=({title:e,subtitle:t,actions:n})=>(0,z.jsxs)(`div`,{className:`flex flex-col gap-x-4 gap-y-2 md:flex-row md:items-end md:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 break-words md:flex-1`,children:[(0,z.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:e}),t&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:t})]}),n&&(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 md:justify-end`,children:n})]}),tf=a({en:{tooManyRequests:`Too many attempts. Wait a minute and try again.`,passkeyClosed:`The passkey prompt closed before it finished. Try again.`,wrongEmailOrPassword:`The email or password is not right.`,wrongPassword:`The password is not right.`,wrongCode:`The code is not right.`,codeExpired:`The code has expired. Ask for a new one.`,tooManyCodes:`Too many wrong codes. Ask for a new one.`,wrongBackupCode:`The backup code is not right, or was used before.`,tooManyCodesSignIn:`Too many wrong codes. Sign in again.`,locked:`Too many wrong codes. Wait 15 minutes and try again.`,tooSlow:`This sign-in took too long. Sign in again.`,passkeyNotFound:`This passkey is not registered for an account here.`,passkeyFailed:`The passkey could not be checked. Try again.`,passkeyAdded:`This passkey is added already.`,notFresh:`For this change, sign out and sign in again first.`,staffPermissionMissing:`Your staff account has no permission to sign in as people here.`,staffNotStrong:`Sign in to your staff account with a passkey or a second step, then try again.`,staffStale:`Your staff sign-in is too old. Sign in to your staff account again.`,staffExpired:`This staff sign-in took too long or was used already. Start again.`,staffProviderFailed:`The staff sign-in did not go through at the provider. Try again.`,staffUserUnavailable:`There is no account with this address, or it is disabled.`,staffReasonRequired:`Say why you sign in as this person, in at least 10 characters.`,staffForbidden:`Staff sign-in is turned off for this app.`,untrustedCallback:`This page is not on an address the server trusts.`,staffFailed:`The staff sign-in did not go through. Try again.`},nl:{tooManyRequests:`Te veel pogingen. Wacht een minuut en probeer het opnieuw.`,passkeyClosed:`De passkey-vraag sloot voordat die klaar was. Probeer het opnieuw.`,wrongEmailOrPassword:`Het e-mailadres of wachtwoord klopt niet.`,wrongPassword:`Het wachtwoord klopt niet.`,wrongCode:`De code klopt niet.`,codeExpired:`De code is verlopen. Vraag een nieuwe aan.`,tooManyCodes:`Te veel verkeerde codes. Vraag een nieuwe aan.`,wrongBackupCode:`De back-upcode klopt niet, of is al eerder gebruikt.`,tooManyCodesSignIn:`Te veel verkeerde codes. Log opnieuw in.`,locked:`Te veel verkeerde codes. Wacht 15 minuten en probeer het opnieuw.`,tooSlow:`Deze inlogpoging duurde te lang. Log opnieuw in.`,passkeyNotFound:`Deze passkey hoort hier bij geen enkel account.`,passkeyFailed:`De passkey kon niet worden gecontroleerd. Probeer het opnieuw.`,passkeyAdded:`Deze passkey is al toegevoegd.`,notFresh:`Log voor deze wijziging eerst uit en opnieuw in.`,staffPermissionMissing:`Je medewerkersaccount mag hier niet als iemand anders inloggen.`,staffNotStrong:`Log in op je medewerkersaccount met een passkey of een tweede stap, en probeer het dan opnieuw.`,staffStale:`Je inlog als medewerker is te oud. Log opnieuw in op je medewerkersaccount.`,staffExpired:`Deze inlog als medewerker duurde te lang of is al gebruikt. Begin opnieuw.`,staffProviderFailed:`De inlog als medewerker lukte niet bij de provider. Probeer het opnieuw.`,staffUserUnavailable:`Er is geen account met dit adres, of het is uitgeschakeld.`,staffReasonRequired:`Zeg in minstens 10 tekens waarom je als deze persoon inlogt.`,staffForbidden:`Inloggen als medewerker staat uit voor deze app.`,untrustedCallback:`Deze pagina staat niet op een adres dat de server vertrouwt.`,staffFailed:`De inlog als medewerker lukte niet. Probeer het opnieuw.`}}),nf=a({en:{signupDisabled:e=>`No account here belongs to this ${e} account. Ask an admin to add you, or sign in another way.`,notLinked:e=>`Your ${e} account is not linked to your account here. Sign in another way, then connect ${e} on the Sign-in & security page.`,linkedToOther:e=>`This ${e} account is linked to someone else here already.`,couldNotLink:e=>`Your ${e} account could not be linked. Try again.`,accessDenied:e=>`${e} did not let you in, or you cancelled.`,domainNotAllowed:e=>`${e} signed you in with an address this app does not accept from it. Sign in another way.`,providerFailed:e=>`Signing in with ${e} did not go through. Try again.`},nl:{signupDisabled:e=>`Geen account hier hoort bij dit ${e}-account. Vraag een beheerder om je toe te voegen, of log op een andere manier in.`,notLinked:e=>`Je ${e}-account is niet gekoppeld aan je account hier. Log op een andere manier in en koppel ${e} dan op de pagina Inloggen en beveiliging.`,linkedToOther:e=>`Dit ${e}-account is hier al aan iemand anders gekoppeld.`,couldNotLink:e=>`Je ${e}-account kon niet worden gekoppeld. Probeer het opnieuw.`,accessDenied:e=>`${e} liet je niet binnen, of je hebt geannuleerd.`,domainNotAllowed:e=>`${e} logde je in met een adres dat deze app daarvan niet accepteert. Log op een andere manier in.`,providerFailed:e=>`Inloggen met ${e} lukte niet. Probeer het opnieuw.`}}),rf={INVALID_EMAIL_OR_PASSWORD:`wrongEmailOrPassword`,INVALID_PASSWORD:`wrongPassword`,INVALID_OTP:`wrongCode`,OTP_EXPIRED:`codeExpired`,TOO_MANY_ATTEMPTS:`tooManyCodes`,INVALID_CODE:`wrongCode`,INVALID_BACKUP_CODE:`wrongBackupCode`,TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:`tooManyCodesSignIn`,ACCOUNT_TEMPORARILY_LOCKED:`locked`,INVALID_TWO_FACTOR_COOKIE:`tooSlow`,AUTH_CANCELLED:`passkeyClosed`,ERROR_CEREMONY_ABORTED:`passkeyClosed`,REGISTRATION_CANCELLED:`passkeyClosed`,PASSKEY_NOT_FOUND:`passkeyNotFound`,AUTHENTICATION_FAILED:`passkeyFailed`,PREVIOUSLY_REGISTERED:`passkeyAdded`,ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED:`passkeyAdded`,SESSION_NOT_FRESH:`notFresh`},af=(e,t)=>{let n=t?e[t]:void 0;return n&&tf(n)},of=e=>af(rf,e.code),sf=e=>of(e)??(e.status===429?tf(`tooManyRequests`):e.message),cf=e=>of(e)??(e.status===429?tf(`tooManyRequests`):e.status===401?tf(`wrongEmailOrPassword`):e.message),lf={STAFF_PERMISSION_MISSING:`staffPermissionMissing`,STAFF_SIGN_IN_NOT_STRONG:`staffNotStrong`,STAFF_SIGN_IN_STALE:`staffStale`,STAFF_SIGN_IN_EXPIRED:`staffExpired`,STAFF_SIGN_IN_FAILED:`staffProviderFailed`,STAFF_USER_UNAVAILABLE:`staffUserUnavailable`,STAFF_REASON_REQUIRED:`staffReasonRequired`,SIGN_IN_METHOD_FORBIDDEN:`staffForbidden`,INVALID_CALLBACK_URL:`untrustedCallback`},uf=e=>af(lf,typeof e==`string`?e:e.code)||(typeof e==`string`?tf(`staffFailed`):e.status===429?tf(`tooManyRequests`):e.message),df={signup_disabled:e=>nf(`signupDisabled`,e),account_not_linked:e=>nf(`notLinked`,e),account_already_linked_to_different_user:e=>nf(`linkedToOther`,e),unable_to_link_account:e=>nf(`couldNotLink`,e),access_denied:e=>nf(`accessDenied`,e),EMAIL_DOMAIN_NOT_ALLOWED:e=>nf(`domainNotAllowed`,e)},ff=(e,t)=>df[e]?.(t)??nf(`providerFailed`,t),pf=`sign-in`,mf=`error`,hf=e=>{let t=new URL(e).searchParams;if(!t.has(mf))return t.get(`sign-in`)||void 0},gf=e=>new URL(e).searchParams.get(mf)||void 0,_f=e=>{let t=new URL(e);for(let e of[pf,mf])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},vf={github:`GitHub`,gitlab:`GitLab`,google:`Google`,microsoft:`Microsoft`,apple:`Apple`},yf=(e,t)=>t?.provider===e?t.name:vf[e]??e.charAt(0).toUpperCase()+e.slice(1),B=a({en:{loading:`Loading`,cannotReach:e=>`Cannot reach the server: ${e}`,tryAgain:`Try again`,passwordChanged:`Your password is changed. Sign in with the new one.`,noAnswer:`The server did not answer`,code:`Code`,backupCode:`Backup code`,email:`Email`,password:`Password`,passwordOptional:`Password (optional)`,signIn:`Sign in`,signOut:`Sign out`,continue:`Continue`,backToSignIn:`Back to sign in`,useAnotherAddress:`Use another address`,checkEmail:`Check your email`,newCodeSent:`A new code is on its way. Only the newest one works.`,sendNewCode:`Send a new code`,sendNewCodeIn:e=>`Send a new code in ${e}s`,signInCodeDescription:`Enter the code we sent to sign in.`,signInCodeSent:`If {} has an account, a 6-digit code is on its way. It works for 5 minutes, once.`,signUpCodeDescription:`Enter the code we sent to create your account.`,signUpCodeSent:`A 6-digit code is on its way to {}. It works for 5 minutes, once. If the address has an account already, the email says so instead.`,noAdminTitle:`No admin yet`,noAdminDescription:`This Protobase has no users to sign in with.`,noAdminExplanation:`Run this in the terminal where Protobase runs, then reload. The first admin is created on the server, not in the browser, so nobody else can claim a fresh URL.`,copyCommand:`Copy command`,reload:`Reload`,tooManyRequests:`Too many requests. Wait a minute and try again.`,tooManyAttempts:`Too many attempts. Wait a minute and try again.`,resetTitle:`Reset your password`,resetDescription:`We email you a link to choose a new one.`,sendResetLink:`Send reset link`,resetSent:`If {} has an account, an email with a link to choose a new password is on its way. The link works once, for a limited time.`,linkExpiredTitle:`This link no longer works`,linkExpiredExplanation:`A reset link works once, for a limited time. Ask for a new one to choose your password.`,sendNewLink:`Send a new link`,passwordsDiffer:`The passwords are not the same.`,choosePassword:`Choose a new password`,atLeast:e=>`At least ${e} characters.`,useAtLeast:e=>`Use at least ${e} characters.`,passwordTooLong:`That password is too long.`,newPassword:`New password`,repeatPassword:`Repeat new password`,setPassword:`Set new password`,signingInWith:e=>`Signing in with ${e}`,takingYouTo:e=>`Taking you to ${e}…`,providerNotOffered:e=>`Signing in with ${e} is not offered here. Sign in another way.`,turnOnTwoFactor:`Turn on two-factor authentication`,addPasskey:`Add a passkey`,requiredForEveryAccount:`This app requires it for every account.`,passkeyExplanation:`A passkey signs you in with Face ID, Touch ID, Windows Hello, your phone or a security key. Your browser asks which one to use.`,couldNotReadAccount:`Could not read your account`,signInTitle:`Sign in to Protobase`,continueWith:e=>`Continue with ${e}`,signInWithPasskey:`Sign in with a passkey`,passkeyFor:e=>`Use a passkey made for ${e}`,or:`or`,emailSignInCode:`Email me a sign-in code`,forgotPassword:`Forgot password?`,newHere:`New here?`,haveAccount:`Have an account?`,createAnAccount:`Create an account`,browse:`Continue without signing in`,notNow:`Not now`,detailsTitle:`Your details`,detailsDescription:`One last step to create your account.`,yourName:`Your name`,codeWasRight:`The code was right: the account is for {}.`,withoutPassword:` Without one, you sign in with a code we email you.`,createAccount:`Create account`,codeToConfirm:`We email you a code to make sure the address is yours.`,emailCode:`Email me a code`,browseWithoutAccount:`Continue without an account`,staffTitle:`Staff sign-in`,staffUnavailable:`Staff of the team that runs this app cannot sign in as people here.`,signInAsPerson:`Sign in as a person`,forStaffOf:e=>`For staff of ${e}, to help someone with this app.`,theirEmail:`Their email`,reason:`Reason`,reasonExample:`Ticket 4211: the invoice totals look wrong`,staffExplanation:e=>`You sign in at ${e} with a passkey or a second step. The session is short, shows a banner, and cannot change their sign-in. The app's admins see who signed in as whom, and why.`,totpInstruction:`Enter the 6-digit code from your authenticator app.`,otpInstruction:`Enter the 6-digit code we emailed you. It works for 5 minutes.`,backupInstruction:`Enter one of the backup codes you saved when you set up the authenticator app. Each works once.`,twoFactorTitle:`Two-factor authentication`,twoFactorDescription:`One more step to sign in.`,codeToFinish:`We email you a code to finish signing in.`,trustBrowser:`Trust this browser`,trustBrowserFor:`Don't ask again in this browser for 30 days`,verify:`Verify`,useAuthenticator:`Use the authenticator app`,emailCodeInstead:`Email me a code instead`,useBackupCode:`Use a backup code`,admin:`Admin`},nl:{loading:`Laden`,cannotReach:e=>`Kan de server niet bereiken: ${e}`,tryAgain:`Opnieuw proberen`,passwordChanged:`Je wachtwoord is gewijzigd. Log in met het nieuwe.`,noAnswer:`De server antwoordde niet`,code:`Code`,backupCode:`Back-upcode`,email:`E-mailadres`,password:`Wachtwoord`,passwordOptional:`Wachtwoord (optioneel)`,signIn:`Inloggen`,signOut:`Uitloggen`,continue:`Doorgaan`,backToSignIn:`Terug naar inloggen`,useAnotherAddress:`Een ander adres gebruiken`,checkEmail:`Kijk in je e-mail`,newCodeSent:`Er is een nieuwe code onderweg. Alleen de nieuwste werkt.`,sendNewCode:`Nieuwe code sturen`,sendNewCodeIn:e=>`Nieuwe code sturen over ${e}s`,signInCodeDescription:`Vul de code in die we stuurden om in te loggen.`,signInCodeSent:`Als {} een account heeft, is er een code van 6 cijfers onderweg. Die werkt 5 minuten, één keer.`,signUpCodeDescription:`Vul de code in die we stuurden om je account te maken.`,signUpCodeSent:`Er is een code van 6 cijfers onderweg naar {}. Die werkt 5 minuten, één keer. Heeft het adres al een account, dan staat dat in de e-mail.`,noAdminTitle:`Nog geen beheerder`,noAdminDescription:`Deze Protobase heeft geen gebruikers om mee in te loggen.`,noAdminExplanation:`Voer dit uit in de terminal waar Protobase draait en laad de pagina daarna opnieuw. De eerste beheerder wordt op de server gemaakt, niet in de browser, zodat niemand anders een nieuwe URL kan opeisen.`,copyCommand:`Opdracht kopiëren`,reload:`Opnieuw laden`,tooManyRequests:`Te veel verzoeken. Wacht een minuut en probeer het opnieuw.`,tooManyAttempts:`Te veel pogingen. Wacht een minuut en probeer het opnieuw.`,resetTitle:`Je wachtwoord herstellen`,resetDescription:`We mailen je een link om een nieuw te kiezen.`,sendResetLink:`Herstellink sturen`,resetSent:`Als {} een account heeft, is er een e-mail onderweg met een link om een nieuw wachtwoord te kiezen. De link werkt één keer, een beperkte tijd.`,linkExpiredTitle:`Deze link werkt niet meer`,linkExpiredExplanation:`Een herstellink werkt één keer, een beperkte tijd. Vraag een nieuwe aan om je wachtwoord te kiezen.`,sendNewLink:`Nieuwe link sturen`,passwordsDiffer:`De wachtwoorden zijn niet hetzelfde.`,choosePassword:`Kies een nieuw wachtwoord`,atLeast:e=>`Minstens ${e} tekens.`,useAtLeast:e=>`Gebruik minstens ${e} tekens.`,passwordTooLong:`Dat wachtwoord is te lang.`,newPassword:`Nieuw wachtwoord`,repeatPassword:`Nieuw wachtwoord herhalen`,setPassword:`Nieuw wachtwoord instellen`,signingInWith:e=>`Inloggen met ${e}`,takingYouTo:e=>`Je gaat naar ${e}…`,providerNotOffered:e=>`Inloggen met ${e} kan hier niet. Log op een andere manier in.`,turnOnTwoFactor:`Tweestapsverificatie aanzetten`,addPasskey:`Passkey toevoegen`,requiredForEveryAccount:`Deze app vraagt het voor elk account.`,passkeyExplanation:`Met een passkey log je in met Face ID, Touch ID, Windows Hello, je telefoon of een beveiligingssleutel. Je browser vraagt welke je gebruikt.`,couldNotReadAccount:`Kon je account niet lezen`,signInTitle:`Inloggen bij Protobase`,continueWith:e=>`Doorgaan met ${e}`,signInWithPasskey:`Inloggen met een passkey`,passkeyFor:e=>`Een passkey voor ${e} gebruiken`,or:`of`,emailSignInCode:`Mail me een inlogcode`,forgotPassword:`Wachtwoord vergeten?`,newHere:`Nieuw hier?`,haveAccount:`Heb je een account?`,createAnAccount:`Account maken`,browse:`Doorgaan zonder in te loggen`,notNow:`Niet nu`,detailsTitle:`Je gegevens`,detailsDescription:`Nog één stap om je account te maken.`,yourName:`Je naam`,codeWasRight:`De code klopte: het account is voor {}.`,withoutPassword:` Zonder wachtwoord log je in met een code die we je mailen.`,createAccount:`Account maken`,codeToConfirm:`We mailen je een code om te controleren dat het adres van jou is.`,emailCode:`Mail me een code`,browseWithoutAccount:`Doorgaan zonder account`,staffTitle:`Inloggen als medewerker`,staffUnavailable:`Medewerkers van het team dat deze app beheert, kunnen hier niet als iemand anders inloggen.`,signInAsPerson:`Inloggen als iemand anders`,forStaffOf:e=>`Voor medewerkers van ${e}, om iemand met deze app te helpen.`,theirEmail:`Hun e-mailadres`,reason:`Reden`,reasonExample:`Ticket 4211: de factuurtotalen kloppen niet`,staffExplanation:e=>`Je logt in bij ${e} met een passkey of een tweede stap. De sessie is kort, toont een balk en kan hun inlog niet wijzigen. De beheerders van de app zien wie als wie inlogde, en waarom.`,totpInstruction:`Vul de code van 6 cijfers uit je authenticator-app in.`,otpInstruction:`Vul de code van 6 cijfers in die we je mailden. Die werkt 5 minuten.`,backupInstruction:`Vul een van de back-upcodes in die je bewaarde toen je de authenticator-app instelde. Elke code werkt één keer.`,twoFactorTitle:`Tweestapsverificatie`,twoFactorDescription:`Nog één stap om in te loggen.`,codeToFinish:`We mailen je een code om het inloggen af te ronden.`,trustBrowser:`Deze browser vertrouwen`,trustBrowserFor:`Niet meer vragen in deze browser, 30 dagen lang`,verify:`Controleren`,useAuthenticator:`De authenticator-app gebruiken`,emailCodeInstead:`Mail me liever een code`,useBackupCode:`Een back-upcode gebruiken`,admin:`Beheerder`}}),bf=(0,L.createContext)(null),xf=()=>{let e=(0,L.useContext)(bf);if(!e)throw Error(`useAuth must be used inside AuthProvider`);return e},Sf=({session:e,origin:t,children:n})=>{let[r,i]=(0,L.useState)({kind:`loading`}),[a,o]=(0,L.useState)([`password`]),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)([]),[h,g]=(0,L.useState)([]),[_,v]=(0,L.useState)(),[y,b]=(0,L.useState)([]),[x,S]=(0,L.useState)(),[C,w]=(0,L.useState)(),[T,E]=(0,L.useState)(!1),[D,O]=(0,L.useState)([]),[k,A]=(0,L.useState)(),j=(0,L.useCallback)(()=>T?{kind:`visitor`}:{kind:`signed-out`},[T]),M=(0,L.useCallback)(()=>i(e=>e.kind===`signed-in`?{kind:`signed-out`}:e),[]),N=(0,L.useRef)(M);N.current=M;let P=(0,L.useMemo)(()=>e??Su({...t&&{origin:t},onSignedOut:()=>N.current()}),[e,t]),ee=(0,L.useCallback)(async e=>{let[{missing:t},n]=await Promise.all([P.account.signInMethods(),P.staff.current()]);i(t.length>0?{kind:`setup-required`,user:e,missing:t}:{kind:`signed-in`,user:e,...n&&{staff:n}})},[P]),te=(0,L.useCallback)(async e=>e.kind===`two-factor`?i({kind:`two-factor`,methods:e.methods}):ee(e.user),[ee]),ne=(0,L.useCallback)(()=>{i({kind:`loading`}),P.status().then(async e=>{if(o(e.signInMethods),c(e.passwordReset),u(!!e.mcp),f(!!e.signUp),m(e.passkeyDomains??[]),g(e.socialProviders),v(e.platformSignIn),b(e.samlProviders),S(e.staffSignIn),w(e.organizations),E(!!e.anonymous),O(e.plugins??[]),A(e.locale),e.needsAdmin)return i({kind:`needs-admin`});let t=await P.session();return t?ee(t):i({kind:e.anonymous?`visitor`:`signed-out`})}).catch(e=>i({kind:`error`,message:e instanceof Error?e.message:B(`noAnswer`)}))},[P,ee]);(0,L.useEffect)(ne,[ne]);let re=(0,L.useMemo)(()=>({state:r,session:P,signInMethods:a,passwordReset:s,mcp:l,canSignUp:d,passkeyDomains:p,socialProviders:h,signInProviders:[...h.map(e=>({id:e,name:yf(e,_)})),...y],staffSignIn:x,...C&&{organizations:C},markSignedOut:M,recheck:ne,beforeSignIn:D,locale:k,adoptSession:async()=>{let e=await P.session();return e?(await ee(e),!0):!1},...T&&{browse:()=>{i(e=>e.kind===`signed-out`?{kind:`visitor`}:e)}},signIn:async(e,t)=>te(await P.signIn(e,t)),sendSignInCode:e=>P.sendSignInCode(e),signInWithCode:async(e,t)=>te(await P.signInWithCode(e,t)),sendSignUpCode:e=>P.sendSignUpCode(e),verifySignUpCode:(e,t)=>P.verifySignUpCode(e,t),signUp:async e=>ee(await P.signUp(e)),signInWithPasskey:async e=>ee(await P.signInWithPasskey(e)),verifyTwoFactor:async e=>ee(await P.verifyTwoFactor(e)),signInSocial:async e=>{let t=new URL(_f(window.location.href),window.location.href).href,n=y.some(t=>t.id===e);window.location.assign(await(n?P.signInSaml(e,t):P.signInSocial(e,t)))},linkProvider:async e=>{window.location.assign(await P.account.linkProvider(e,new URL(_f(window.location.href),window.location.href).href))},stopStaffSession:async()=>{await P.staff.stop(),i(j())},signOut:async()=>{await P.signOut(),i(j())}}),[r,P,a,s,l,d,p,h,_,y,x,C,T,D,k,j,M,ne,te,ee]);return(0,z.jsx)(bf.Provider,{value:re,children:n})},Cf=/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u115f\u1160\u180e\u200b-\u200f\u2028-\u202e\u2060-\u206f\u3164\ufe00-\ufe0f\ufeff]/g,wf=e=>{let t=(e??``).replace(Cf,` `).replace(/\s+/g,` `).trim();if(t)return t.length>60?`${t.slice(0,59)}…`:t},Tf=e=>{if(!URL.canParse(e))return;let t=new URL(e);return t.protocol===`https:`?t.host:void 0},Ef=new Map,Df=(e,t)=>{let n=l(),r=`${n}|${e}`;return Ef.has(r)||Ef.set(r,t(n)),Ef.get(r)},Of=(e,t)=>Df(`money:${e}:${t??``}`,n=>new Intl.NumberFormat(n,{style:`currency`,currency:e,...t!==void 0&&{minimumFractionDigits:t,maximumFractionDigits:t}})),kf=(e,t=`EUR`,n)=>Of(t,n).format(e/100),Af=a({en:{rows:e=>`${e} rows`,aboutRows:e=>`about ${e} rows`,secondsAgo:e=>`${e} s ago`,minutesAgo:e=>`${e} min ago`,hoursAgo:e=>`${e} h ago`,daysAgo:e=>`${e} d ago`,justNow:`just now`},nl:{rows:e=>`${e} rijen`,aboutRows:e=>`ongeveer ${e} rijen`,secondsAgo:e=>`${e} s geleden`,minutesAgo:e=>`${e} min geleden`,hoursAgo:e=>`${e} u geleden`,daysAgo:e=>`${e} d geleden`,justNow:`zojuist`}}),jf=()=>Df(`grouped`,e=>new Intl.NumberFormat(e)),Mf=e=>jf().format(e),Nf=e=>e>0?`+${jf().format(e)}`:jf().format(e).replace(`-`,`−`),Pf=e=>`${e}%`,Ff=e=>{if(e<1e4)return Af(`rows`,Mf(e));let t=10**(Math.floor(Math.log10(e))-3);return Af(`aboutRows`,Mf(Math.round(e/t)*t))},If=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,Lf=new Map,Rf=e=>{let t=Lf.get(e);if(t)return t;let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`});return Lf.set(e,n),n},zf=(e,t)=>{let n=Object.fromEntries(Rf(t).formatToParts(e).map(e=>[e.type,e.value]));return{year:Number(n.year),month:Number(n.month),day:Number(n.day),hour:Number(n.hour),minute:Number(n.minute),second:Number(n.second)}},Bf=(e,t)=>{let n=zf(e,t);return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-Math.floor(e/1e3)*1e3},Vf=e=>String(e).padStart(2,`0`),Hf=(e,t)=>{let n=zf(e,t);return`${n.year}-${Vf(n.month)}-${Vf(n.day)}`},Uf=(e,t)=>e-Bf(e-Bf(e,t),t),Wf=(e,t)=>Uf(Date.parse(`${e}T00:00:00Z`),t),Gf=(e,t)=>{let n=Df(`zoneName:${t}`,e=>new Intl.DateTimeFormat(e,{timeZone:t,timeZoneName:`shortOffset`})).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??t;return t===`UTC`||t===`Etc/UTC`?`UTC`:`${t} (${n})`},Kf=(e,t)=>()=>Df(`date:${e}`,e=>new Intl.DateTimeFormat(e,{...t,timeZone:`UTC`})),qf=Kf(`day`,{day:`numeric`,month:`short`,year:`numeric`}),Jf=Kf(`dayShort`,{day:`numeric`,month:`short`}),Yf=Kf(`month`,{month:`long`,year:`numeric`}),Xf=Kf(`monthName`,{month:`long`}),Zf=Kf(`weekday`,{weekday:`short`}),Qf=Kf(`weekdayDate`,{weekday:`long`,day:`numeric`,month:`short`,year:`numeric`}),$f=e=>qf().format(e),ep=e=>Jf().format(e),tp=e=>Df(`zoned:${e}`,t=>({day:new Intl.DateTimeFormat(t,{day:`numeric`,month:`short`,year:`numeric`,timeZone:e}),time:new Intl.DateTimeFormat(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1,timeZone:e})})),np=(e,t=If())=>{let n=tp(t);return`${n.day.format(e)}, ${n.time.format(e)}`},rp=e=>Yf().format(e),ip=e=>Xf().format(e),ap=(e,t)=>Yf().formatRange(e,t),op=e=>Zf().format(e),sp=e=>Qf().format(e),cp=(e,t)=>qf().formatRange(e,t),lp=(e,t=If())=>tp(t).time.format(e),up=e=>e<60?Af(`secondsAgo`,e):e<3600?Af(`minutesAgo`,Math.floor(e/60)):e<86400?Af(`hoursAgo`,Math.floor(e/3600)):Af(`daysAgo`,Math.floor(e/86400)),dp=()=>Df(`relative`,e=>new Intl.RelativeTimeFormat(e,{numeric:`auto`})),fp=[[`year`,31536e3],[`month`,2592e3],[`day`,86400],[`hour`,3600],[`minute`,60]],pp=e=>{let t=Math.abs(e),[n,r]=fp.find(([,e])=>t>=e)??[`second`,1];return n===`second`&&t<45?Af(`justNow`):dp().format(-Math.sign(e)*Math.floor(t/r),n)},mp={primary:`bg-primary text-primary-foreground hover:bg-primary-hover shadow-sm`,secondary:`bg-background text-foreground border border-border-strong hover:bg-muted shadow-sm`,ghost:`text-muted-foreground hover:bg-muted hover:text-foreground`,danger:`bg-background text-danger-text border border-border-strong hover:bg-danger-soft shadow-sm`},hp={sm:`h-7 px-2.5 text-body gap-1.5`,md:`h-8 px-3 text-body gap-2`},gp=({variant:e=`secondary`,size:t=`md`}={})=>g(`inline-flex shrink-0 items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:opacity-60 disabled:cursor-default`,mp[e],hp[t]),V=({variant:e=`secondary`,size:t=`md`,loading:n,className:r,children:i,disabled:a,...o})=>(0,z.jsxs)(`button`,{type:`button`,disabled:a||n,className:g(gp({variant:e,size:t}),r),...o,children:[n&&(0,z.jsx)(qd,{className:`size-3.5`}),i]}),_p=({title:e,description:t,onClose:n,actions:r,children:i,wide:a=!1})=>{let o=(0,L.useRef)(null);return Hu(o,!0,n),(0,z.jsx)(`div`,{className:`fixed inset-0 z-[90] flex items-center justify-center bg-backdrop/30 p-4`,onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,z.jsxs)(`div`,{ref:o,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,className:g(`outline-none max-h-[90vh] w-full overflow-y-auto rounded-lg border bg-background p-4 shadow-pop sm:p-5`,a?`max-w-3xl`:`max-w-md`),children:[(0,z.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:e}),t&&(0,z.jsx)(`p`,{className:`mt-1.5 text-muted-foreground`,children:t}),i&&(0,z.jsx)(`div`,{className:`mt-4`,children:i}),(0,z.jsx)(`div`,{className:`mt-5 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end [&>*]:min-h-11 sm:[&>*]:min-h-0`,children:r})]})})},vp=({title:e,status:t,description:n,children:r})=>(0,z.jsxs)(`section`,{"aria-label":e,className:`rounded-lg border bg-background p-4 sm:p-5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:e}),t]}),(0,z.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}),r&&(0,z.jsx)(`div`,{className:`mt-4`,children:r})]}),yp=({message:e})=>e?(0,z.jsx)(`p`,{role:`alert`,className:`mb-3 text-body font-medium text-danger-text`,children:e}):null,bp=e=>wf(e.name)??`An unnamed app`,xp=e=>e.access.map(({role:e,organization:t})=>`as ${e||`no role`}${t?` in ${t}`:``}`).join(`, `),Sp=({apps:e,onDisconnect:t})=>{let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(),[o,s]=(0,L.useState)(),c=async e=>{r(!0),a(void 0);try{await t(e.clientId),s(void 0)}catch(e){if(!(e instanceof Oc))throw e;a(sf(e))}r(!1)};return(0,z.jsxs)(vp,{title:`Connected apps`,description:`AI assistants and other apps you allowed to act as you here. Disconnecting one stops it within 15 minutes; it has to ask you again to come back.`,children:[(0,z.jsx)(yp,{message:o?void 0:i}),e.length===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`No apps are connected. Add this app's MCP address to an AI assistant to connect one.`}):(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>{let t=Tf(e.clientId);return(0,z.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,z.jsx)(Lee,{className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`bdi`,{className:`block truncate font-medium`,children:bp(e)}),(0,z.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t&&`Published by ${t} · `,`Allowed `,$f(Date.parse(e.allowedAt)),` · `,xp(e)]})]}),(0,z.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>s(e),children:`Disconnect`})]},e.clientId)})}),o&&(0,z.jsx)(_p,{title:`Disconnect ${bp(o)}?`,description:`It can no longer read or change anything as you. What it already started may keep working for up to 15 minutes.`,onClose:()=>s(void 0),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:()=>s(void 0),children:`Cancel`}),(0,z.jsx)(V,{variant:`danger`,loading:n,onClick:()=>void c(o),children:`Disconnect`})]}),children:i&&(0,z.jsx)(yp,{message:i})})]})},Cp={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},wp=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(),[l,u]=(0,L.useState)(),[d,f]=(0,L.useState)(``),p=e===`required`&&t.length<=1,m=async e=>{o(!0),c(void 0);try{await e(),u(void 0)}catch(e){if(!(e instanceof Oc))throw e;c(sf(e))}o(!1)};return(0,z.jsxs)(vp,{title:R(`passkeys`),status:e===`required`&&(0,z.jsx)(_d,{tone:`blue`,children:R(`required`)}),description:R(Cp[e]),children:[(0,z.jsx)(yp,{message:l?void 0:s}),t.length>0&&(0,z.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,z.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,z.jsx)(fa,{className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??R(`passkey`)}),(0,z.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?R(`addedOn`,$f(Date.parse(e.createdAt))):R(`addedEarlier`),` · `,e.backedUp?R(`synced`):R(`oneDevice`)]})]}),(0,z.jsxs)(`span`,{className:`flex gap-1`,children:[(0,z.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>{f(e.name??``),u({kind:`rename`,passkey:e})},children:R(`rename`)}),(0,z.jsx)(V,{size:`sm`,variant:`ghost`,disabled:p,title:p?R(`keepLastPasskey`):void 0,onClick:()=>u({kind:`remove`,passkey:e}),children:R(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,z.jsxs)(V,{loading:a&&!l,onClick:()=>void m(n),children:[(0,z.jsx)(no,{className:`size-3.5`}),R(`addPasskey`)]}),l?.kind===`rename`&&(0,z.jsxs)(_p,{title:R(`renamePasskey`),description:R(`renamePasskeyDescription`),onClose:()=>u(void 0),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:()=>u(void 0),children:R(`cancel`)}),(0,z.jsx)(V,{variant:`primary`,loading:a,disabled:!d.trim(),onClick:()=>void m(()=>r(l.passkey.id,d.trim())),children:R(`save`)})]}),children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[R(`name`),(0,z.jsx)(Wd,{autoFocus:!0,value:d,maxLength:60,onChange:e=>f(e.target.value)})]}),(0,z.jsx)(yp,{message:s})]}),l?.kind===`remove`&&(0,z.jsx)(_p,{title:R(`removePasskey`),description:R(`removePasskeyDescription`,l.passkey.name??R(`thisPasskey`)),onClose:()=>u(void 0),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:()=>u(void 0),children:R(`cancel`)}),(0,z.jsx)(V,{variant:`danger`,loading:a,onClick:()=>void m(()=>i(l.passkey.id)),children:R(`remove`)})]}),children:s&&(0,z.jsx)(yp,{message:s})})]})},Tp=({providers:e,linked:t,onConnect:n,error:r})=>{let[i,a]=(0,L.useState)(),[o,s]=(0,L.useState)(r),c=async e=>{a(e),s(void 0);try{await n(e)}catch(e){if(!(e instanceof Oc))throw e;s(sf(e)),a(void 0)}};return(0,z.jsxs)(vp,{title:R(`connectedAccounts`),description:R(`connectedAccountsDescription`),children:[(0,z.jsx)(yp,{message:o}),(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,z.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,z.jsx)(Ca,{className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),t.includes(e.id)?(0,z.jsx)(_d,{tone:`green`,children:R(`connected`)}):(0,z.jsx)(V,{size:`sm`,loading:i===e.id,disabled:i!==void 0,onClick:()=>void c(e.id),children:R(`connect`,e.name)})]},e.id))})]})},Ep=(e,t,n=`text/plain`)=>{let r=URL.createObjectURL(new Blob([e],{type:n}));Object.assign(document.createElement(`a`),{href:r,download:t}).click(),URL.revokeObjectURL(r)},Dp=({codes:e})=>{let[t,n]=(0,L.useState)(!1),r=`${e.join(`
|
|
7
|
-
`)}\n`;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,z.jsx)(`ul`,{"aria-label":R(`backupCodes`),className:`grid grid-cols-2 gap-x-4 gap-y-1 rounded-md border bg-surface p-3 font-mono`,children:e.map(e=>(0,z.jsx)(`li`,{children:e},e))}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(V,{size:`sm`,onClick:()=>{navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},children:[t?(0,z.jsx)(xi,{className:`size-3.5 text-success`}):(0,z.jsx)(Li,{className:`size-3.5`}),R(t?`copied`:`copy`)]}),(0,z.jsxs)(V,{size:`sm`,onClick:()=>Ep(r,`backup-codes.txt`),children:[(0,z.jsx)(Ui,{className:`size-3.5`}),R(`download`)]})]})]})},Op=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:o})=>{let[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(),p=async()=>{u(!0),f(void 0);try{await a(i?s:void 0)}catch(e){if(!(e instanceof Oc))throw e;f(sf(e)),u(!1)}};return(0,z.jsxs)(_p,{title:e,description:t,onClose:o,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:o,children:R(`cancel`)}),(0,z.jsx)(V,{variant:r?`danger`:`primary`,loading:l,disabled:i&&!s,onClick:()=>void p(),children:n})]}),children:[i&&(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[R(`yourPassword`),(0,z.jsx)(Wd,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:s,invalid:!!d,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&s&&void p()})]}),d&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:d})]})},kp=(e,t)=>e.replace(/\D/g,``).slice(0,t),Ap=(e,t,n)=>{let r=kp(t??``,n);return r.length===n?r:kp(e,n)},jp=(e,t,n,r)=>{let i=t.replace(/\D/g,``);return i.length>=r?i.slice(0,r):kp(e.slice(0,n)+i+e.slice(n+i.length),r)},Mp=({value:e,onChange:t,onComplete:n,length:r=6,invalid:i,disabled:a,className:o,ref:s,onFocus:c,onBlur:l,onSelect:u,onKeyDown:d,onClick:f,onPaste:p,...m})=>{let h=(0,L.useRef)(null),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(e.length),x=e.slice(0,r),S=Math.min(y,r-1),C=e=>{h.current=e,typeof s==`function`?s(e):s&&(s.current=e)},w=e=>{e!==x&&(t(e),e.length===r&&n?.(e))},T=e=>{let t=h.current;if(!t)return;let n=Math.max(0,Math.min(e,x.length));t.setSelectionRange(n,n<x.length?n+1:n),b(n)},E=e=>{if(d?.(e),e.defaultPrevented||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey)return;let t=e.currentTarget.selectionStart??x.length,n={ArrowLeft:t-1,ArrowRight:t+1,Home:0,End:x.length}[e.key];n!==void 0&&(e.preventDefault(),T(n))},D=e=>{f?.(e);let t=e.currentTarget.getBoundingClientRect();e.clientX<=t.left||e.clientX>=t.right||T(Math.floor((e.clientX-t.left)/t.width*r))};return(0,z.jsxs)(`div`,{className:g(`relative`,a&&`opacity-50`,o),children:[(0,z.jsx)(`div`,{"aria-hidden":!0,className:`flex justify-center gap-2`,children:Array.from({length:r},(e,t)=>{let n=_&&t===S;return(0,z.jsx)(`div`,{"data-slot":t,"data-digit":x[t],className:g(`flex h-12 min-w-0 max-w-12 flex-1 items-center justify-center rounded-md border bg-background font-mono text-xl font-semibold text-foreground shadow-sm transition-colors before:content-[attr(data-digit)]`,i?`border-danger`:n?`border-primary`:`border-border-strong`,n&&(i?`ring-2 ring-danger/20`:`ring-2 ring-primary/20`)),children:x[t]===void 0&&(n?(0,z.jsx)(`span`,{className:`h-6 w-px animate-pulse bg-foreground`}):(0,z.jsx)(`span`,{className:`size-1.5 rounded-full bg-border-strong`}))},t)})}),(0,z.jsx)(`input`,{ref:C,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,pattern:`[0-9]{${r}}`,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,"aria-invalid":i||void 0,disabled:a,value:x,className:`absolute inset-0 size-full cursor-text bg-transparent text-transparent caret-transparent outline-none selection:bg-transparent disabled:cursor-not-allowed`,...m,onChange:e=>{let{data:t,dataTransfer:n}=e.nativeEvent;w(Ap(e.target.value,t??n?.getData(`text/plain`),r))},onPaste:e=>{if(p?.(e),e.defaultPrevented)return;e.preventDefault();let t=e.currentTarget,n=jp(x,e.clipboardData.getData(`text`),t.selectionStart??x.length,r);w(n),b(n.length)},onSelect:e=>{u?.(e);let t=e.currentTarget,n=t.selectionStart??x.length;n===t.selectionEnd&&n<t.value.length&&t.setSelectionRange(n,n+1),b(n)},onKeyDown:E,onClick:D,onFocus:e=>{v(!0),c?.(e)},onBlur:e=>{v(!1),l?.(e)}})]})},Np=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(Np||{}),Pp=[0,1],Fp=[1,0],Ip=[2,3],Lp=[3,2],Rp={L:Pp,M:Fp,Q:Ip,H:Lp},zp=/^\d*$/,Bp=/^[A-Z0-9 $%*+./:-]*$/,Vp=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,Hp=1,Up=40,Wp=3,Gp=3,Kp=40,qp=10,Jp=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Yp=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],Xp=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<Hp||e>Up)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,Np.Timing),this.setFunctionModule(e,6,e%2==0,Np.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,Qp(r,e));this.setFunctionModule(8,7,Qp(r,6)),this.setFunctionModule(8,8,Qp(r,7)),this.setFunctionModule(7,8,Qp(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,Qp(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,Qp(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,Qp(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=Qp(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,Np.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,Np.Alignment)}setFunctionModule(e,t,n,r=Np.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==pm(t,n))throw RangeError(`Invalid argument`);let r=Yp[n[0]][t],i=Jp[n[0]][t],a=Math.floor(fm(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=mm(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=hm(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(fm(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=Qp(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=Wp:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Kp),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Kp}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=Wp:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Kp),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Kp}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=Gp)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*qp,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Zp(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function Qp(e,t){return!!(e>>>t&1)}var $p=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},em=[1,10,12,14],tm=[2,9,11,13],nm=[4,8,16,16];function rm(e,t){return e[Math.floor((t+7)/17)+1]}function im(e){let t=[];for(let n of e)Zp(n,8,t);return new $p(nm,e.length,t)}function am(e){if(!cm(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);Zp(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new $p(em,e.length,t)}function om(e){if(!lm(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Vp.indexOf(e.charAt(n))*45;r+=Vp.indexOf(e.charAt(n+1)),Zp(r,11,t)}return n<e.length&&Zp(Vp.indexOf(e.charAt(n)),6,t),new $p(tm,e.length,t)}function sm(e){return e===``?[]:cm(e)?[am(e)]:lm(e)?[om(e)]:[im(dm(e))]}function cm(e){return zp.test(e)}function lm(e){return Bp.test(e)}function um(e,t){let n=0;for(let r of e){let e=rm(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function dm(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function fm(e){if(e<Hp||e>Up)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function pm(e,t){return Math.floor(fm(e)/8)-Jp[t[0]][e]*Yp[t[0]][e]}function mm(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=gm(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=gm(n,2)}return t}function hm(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=gm(t,e))}return n}function gm(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function _m(e,t,n=1,r=40,i=-1,a=!0){if(!(Hp<=n&&n<=r&&r<=Up)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=pm(o,t)*8,i=um(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Fp,Ip,Lp])a&&s<=pm(o,e)*8&&(t=e);let c=[];for(let t of e){Zp(t.mode[0],4,c),Zp(t.numChars,rm(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=pm(o,t)*8;Zp(0,Math.min(4,l-c.length),c),Zp(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Zp(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new Xp(o,t,u,i)}function vm(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?sm(e):Array.isArray(e)?[im(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=_m(c,Rp[n],i,a,o,r),u=ym({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function ym(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=Np.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}var bm=({uri:e,className:t})=>{let{size:n,path:r}=(0,L.useMemo)(()=>{let t=vm(e,{ecc:`M`,border:2}),n=t.data.flatMap((e,t)=>e.flatMap((e,n)=>e?[`M${n} ${t}h1v1h-1z`]:[]));return{size:t.size,path:n.join(``)}},[e]);return(0,z.jsxs)(`svg`,{viewBox:`0 0 ${n} ${n}`,role:`img`,"aria-label":R(`qrCode`),shapeRendering:`crispEdges`,className:t,children:[(0,z.jsx)(`rect`,{width:n,height:n,fill:`#fff`}),(0,z.jsx)(`path`,{d:r,fill:`#000`})]})},xm=e=>(new URL(e).searchParams.get(`secret`)??``).replace(/(.{4})(?=.)/g,`$1 `),Sm=()=>[{value:`app`,label:R(`authenticatorApp`),description:R(`authenticatorAppDescription`)},{value:`email`,label:R(`emailedCode`),description:R(`emailedCodeDescription`)}],Cm=({offerEmailedCodes:e,needsPassword:t,onStartApp:n,onConfirmApp:r,onEmailedCodes:i,onDone:a,onCancel:o})=>{let[s,c]=(0,L.useState)({kind:`choose`}),[l,u]=(0,L.useState)(`app`),[d,f]=(0,L.useState)(``),[p,m]=(0,L.useState)(``),[h,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(),b=e?Sm():Sm().filter(e=>e.value===`app`),x=async e=>{_(!0),y(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;y(sf(e))}_(!1)},S=()=>x(async()=>{let e=t?d:void 0;if(l===`email`)return await i(e),a();c({kind:`scan`,setup:await n(e)})}),C=(e,t=p)=>x(async()=>{await r(t),c({kind:`backup-codes`,codes:e.backupCodes})}),w=v&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:v});return s.kind===`backup-codes`?(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:R(`twoFactorIsOn`)}),(0,z.jsx)(Dp,{codes:s.codes}),(0,z.jsx)(V,{variant:`primary`,onClick:a,className:`min-h-10`,children:R(`savedCodes`)})]}):s.kind===`scan`?(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),C(s.setup)},children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:R(`scanCode`)}),(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,z.jsx)(bm,{uri:s.setup.totpURI,className:`size-44 rounded-md border`}),(0,z.jsxs)(`p`,{className:`text-center text-xs text-muted-foreground`,children:[R(`cannotScan`),(0,z.jsx)(`span`,{className:`mt-1 block break-all font-mono text-body text-foreground`,children:xm(s.setup.totpURI)})]})]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[R(`codeFromApp`),(0,z.jsx)(Mp,{name:`code`,required:!0,autoFocus:!0,value:p,invalid:!!v,onChange:m,onComplete:e=>!h&&void C(s.setup,e)})]}),w,(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:R(`turnOn`)}),o&&(0,z.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:R(`cancel`)})]}):(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,z.jsx)(`div`,{role:`radiogroup`,"aria-label":R(`secondStep`),className:`flex flex-col gap-2`,children:b.map(e=>(0,z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e.value,onClick:()=>u(e.value),className:g(`rounded-md border p-3 text-left transition-colors`,l===e.value?`border-primary bg-primary-soft`:`border-border-strong hover:bg-muted`),children:[(0,z.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,z.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted-foreground`,children:e.description})]},e.value))}),t&&(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[R(`yourPassword`),(0,z.jsx)(Wd,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:d,invalid:!!v,onChange:e=>f(e.target.value),className:`min-h-6`})]}),w,(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:R(`continue`)}),o&&(0,z.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:R(`cancel`)})]})},wm={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},Tm=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,L.useState)(),d=()=>u(void 0),f=n?(0,z.jsx)(_d,{tone:`green`,children:R(`on`)}):t===`required`?(0,z.jsx)(_d,{tone:`amber`,children:R(`required`)}):(0,z.jsx)(_d,{children:R(`off`)}),p=R(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:wm[t]);return l?.kind===`setup`?(0,z.jsx)(vp,{title:R(`twoFactor`),status:f,description:p,children:(0,z.jsx)(`div`,{className:`max-w-sm`,children:(0,z.jsx)(Cm,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,z.jsxs)(vp,{title:R(`twoFactor`),status:f,description:p,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,z.jsx)(V,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:R(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,z.jsx)(V,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:R(`addAuthenticator`)}),n&&r&&(0,z.jsx)(V,{onClick:()=>u({kind:`new-codes`}),children:R(`newBackupCodes`)}),n&&(0,z.jsx)(V,{variant:`danger`,disabled:t===`required`,title:t===`required`?R(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:R(`turnOff`)})]}),l?.kind===`turn-off`&&(0,z.jsx)(Op,{title:R(`turnOffTitle`),description:R(`turnOffDescription`),confirmLabel:R(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,z.jsx)(Op,{title:R(`newCodesTitle`),description:R(`newCodesDescription`),confirmLabel:R(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,z.jsx)(_p,{title:R(`yourNewCodes`),description:R(`keepCodesSafe`),onClose:d,actions:(0,z.jsx)(V,{variant:`primary`,onClick:d,children:R(`savedCodes`)}),children:(0,z.jsx)(Dp,{codes:l.codes})})]})},Em=()=>{let e=gf(window.location.href);return e&&window.history.replaceState(window.history.state,``,_f(window.location.href)),e},Dm=({email:e})=>{let{session:t,signInProviders:n,socialProviders:r,linkProvider:i,mcp:a}=xf(),o=n.filter(e=>r.includes(e.id)),{account:s}=t,[c,l]=(0,L.useState)(),[u,d]=(0,L.useState)(),[f]=(0,L.useState)(Em),p=(0,L.useCallback)(()=>{Promise.all([s.signInMethods(),s.passkeys(),s.linkedProviders(),a?s.connectedApps():[]]).then(([e,t,n,r])=>l({methods:e,passkeys:t,linked:n,apps:r}),e=>d(e instanceof Oc?sf(e):R(`couldNotReadMethods`)))},[s,a]);(0,L.useEffect)(p,[p]);let m=e=>e.then(e=>(p(),e));return(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,z.jsx)(ef,{title:R(`signInSecurity`),subtitle:e}),c?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(wp,{rule:c.methods.policy.passkey,passkeys:c.passkeys,onAdd:()=>m(s.addPasskey()),onRename:(e,t)=>m(s.renamePasskey(e,t)),onRemove:e=>m(s.removePasskey(e))}),(0,z.jsx)(Tm,{rule:c.methods.policy.twoFactor,enabled:c.methods.account.twoFactor,authenticatorApp:c.methods.account.authenticatorApp,mail:c.methods.mail,needsPassword:c.methods.account.password,onStartApp:e=>s.startAuthenticatorApp(e),onConfirmApp:e=>s.confirmAuthenticatorApp(e),onEmailedCodes:e=>s.turnOnEmailedCodes(e),onTurnOff:e=>s.turnOffTwoFactor(e),onNewBackupCodes:e=>s.newBackupCodes(e),onChanged:p}),o.length>0&&(0,z.jsx)(Tp,{providers:o,linked:c.linked,onConnect:i,error:f&&ff(f,o.length===1?o[0].name:R(`theProvider`))}),a&&(0,z.jsx)(Sp,{apps:c.apps,onDisconnect:e=>m(s.disconnectApp(e))})]}):u?(0,z.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:u}):(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,R(`loading`)]})]})},Om={wallet:gte,"file-text":ta,send:xo,ruler:ho,bed:$r,bath:Zr,house:ca,"door-open":Jee,"land-plot":ite,leaf:ya,tag:pte,key:fa,calendar:gi,heart:oa,bell:ti,bookmark:li,"external-link":Yi,ban:Yr,play:lte,stop:ute,power:io,restart:po,terminal:mte,camera:Ree,"hard-drive":tte,server:Co,network:Ga,archive:Fr,copy:Li,"arrow-right-left":zr,download:Ui,upload:Qo,cpu:qee,memory:Ia,plug:eo,wrench:_te},km=e=>e!==void 0&&Object.hasOwn(Om,e)?Om[e]:void 0,Am=(e,t)=>t>=60&&t>Math.abs(e),jm=({title:e,open:t,onClose:n,children:r})=>{let i=(0,L.useRef)(null),a=(0,L.useRef)(void 0);return Hu(i,t,n),t?(0,z.jsxs)(`div`,{className:`fixed inset-0 z-[80]`,children:[(0,z.jsx)(`div`,{className:`absolute inset-0 bg-backdrop/40`,onClick:n,"aria-hidden":!0}),(0,z.jsxs)(`div`,{ref:i,role:`dialog`,"aria-modal":`true`,"aria-label":e,tabIndex:-1,className:`absolute inset-x-0 bottom-0 flex max-h-[85vh] flex-col rounded-t-xl border-t bg-background shadow-pop outline-none`,children:[(0,z.jsxs)(`header`,{className:`relative flex shrink-0 touch-none items-center justify-between border-b px-4`,onPointerDown:e=>{e.pointerType===`touch`&&(a.current={x:e.clientX,y:e.clientY})},onPointerUp:e=>{if(!a.current)return;let t=Am(e.clientX-a.current.x,e.clientY-a.current.y);a.current=void 0,t&&n()},onPointerCancel:()=>a.current=void 0,children:[(0,z.jsx)(`span`,{className:`absolute left-1/2 top-1.5 h-1 w-9 -translate-x-1/2 rounded-full bg-border-strong`,"aria-hidden":!0}),(0,z.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:e}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Kd(`close`),onClick:n,className:`-mr-2 inline-flex size-11 items-center justify-center rounded-md text-muted-foreground hover:bg-muted`,children:(0,z.jsx)(ss,{className:`size-5`})})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-6`,children:r})]})]}):null},Mm=({title:e,description:t,open:n,onClose:r,actions:i,children:a,wide:o})=>{let s=Mu();return n?s?(0,z.jsx)(_p,{title:e,description:t,onClose:r,actions:i,wide:o,children:a}):(0,z.jsx)(jm,{title:e,open:!0,onClose:r,children:(0,z.jsxs)(`div`,{className:`pt-3`,children:[t&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:t}),a&&(0,z.jsx)(`div`,{className:`mt-4`,children:a}),(0,z.jsx)(`div`,{className:`mt-5 flex flex-col-reverse gap-2 [&>*]:min-h-11`,children:i})]})}):null},H=a({en:{notFound:`Not found`,noResource:e=>`There is no resource called ${e}.`,somethingWentWrong:`Something went wrong`,signInSecurity:`Sign-in & security`,signInPolicy:`Sign-in policy`,adminsOnly:`Admins only`,onlyAdminPolicy:`Only an admin can change how people sign in.`,ownersOnly:`Owners and admins only`,onlyOwners:`Only the organization's owners and admins manage its members.`,chooseResource:`Choose a resource`,pickFromSidebar:`Pick one from the sidebar.`,nothingHere:`There is nothing at this address.`,noPage:`There is no page called {}.`,assistant:`Assistant`,operationFailed:(e,t,n)=>`Operation ${e} (${t}) failed: ${n} Nothing was saved.`,nothingSaved:e=>`${e} Nothing was saved.`,admin:`Admin`,new:`New`,loadingRecord:`Loading record`,noComponent:`No component is registered as {}. Export it from protobase.ui.tsx, or load the plugin that provides it.`,choose:`Choose...`,fileMissing:`The file is missing from storage`,chooseFileFor:e=>`Choose a file for ${e}`,notUploaded:`Not uploaded`,uploadingLabel:e=>`Uploading ${e}`,uploading:e=>`Uploading… ${e}%`,replace:`Replace`,remove:`Remove`,dropFile:`Drop a file here or`,chooseFile:`Choose a file`,average:e=>`Average ${e.toLowerCase()}`,pages:`Pages`,account:`Account`,sales:`Sales`,crm:`CRM`,catalog:`Catalog`,inventory:`Inventory`,hr:`HR`,cannotReach:e=>`Cannot reach ${e}`,searchPlural:e=>`Search ${e}`,couldNotLoadOptions:`Could not load the options`,noMatches:`No matches`,loading:`Loading`,leaveTitle:`Leave without saving?`,leaveDescription:`You have unsaved changes on this page. They stay in this browser, and come back when you open the record again.`,stay:`Stay`,leave:`Leave`,show:e=>`Show ${e}`,hide:e=>`Hide ${e}`,couldNotShow:e=>`Could not show the ${e}`,noAnswer:`It did not answer.`,signInRefused:e=>`It did not accept your sign-in: ${e}`,loadingFrom:e=>`Loading from ${e}`,restWorks:`The rest of the app works as before.`,tryAgain:`Try again`,staffSession:`Staff session`,staffSignedIn:`{} is signed in as {} until {}. Reason: {}`,stopStaffSession:`Stop staff session`,open:`Open`,openLabel:e=>`Open ${e}`},nl:{notFound:`Niet gevonden`,noResource:e=>`Er is geen onderdeel met de naam ${e}.`,somethingWentWrong:`Er ging iets mis`,signInSecurity:`Inloggen en beveiliging`,signInPolicy:`Inlogbeleid`,adminsOnly:`Alleen beheerders`,onlyAdminPolicy:`Alleen een beheerder kan wijzigen hoe mensen inloggen.`,ownersOnly:`Alleen eigenaren en beheerders`,onlyOwners:`Alleen de eigenaren en beheerders van de organisatie beheren de leden.`,chooseResource:`Kies een onderdeel`,pickFromSidebar:`Kies er een in de zijbalk.`,nothingHere:`Er is niets op dit adres.`,noPage:`Er is geen pagina met de naam {}.`,assistant:`Assistent`,operationFailed:(e,t,n)=>`Bewerking ${e} (${t}) mislukte: ${n} Er is niets bewaard.`,nothingSaved:e=>`${e} Er is niets bewaard.`,admin:`Beheer`,new:`Nieuw`,loadingRecord:`Record laden`,noComponent:`Er is geen component geregistreerd als {}. Exporteer die uit protobase.ui.tsx, of laad de plug-in die haar levert.`,choose:`Kiezen...`,fileMissing:`Het bestand ontbreekt in de opslag`,chooseFileFor:e=>`Kies een bestand voor ${e}`,notUploaded:`Niet geüpload`,uploadingLabel:e=>`${e} uploaden`,uploading:e=>`Uploaden… ${e}%`,replace:`Vervangen`,remove:`Verwijderen`,dropFile:`Zet hier een bestand neer of`,chooseFile:`Kies een bestand`,average:e=>`${e}, gemiddeld`,pages:`Pagina's`,account:`Account`,sales:`Verkoop`,crm:`CRM`,catalog:`Catalogus`,inventory:`Voorraad`,hr:`HR`,cannotReach:e=>`Kan ${e} niet bereiken`,searchPlural:e=>`${e} zoeken`,couldNotLoadOptions:`Kon de keuzes niet laden`,noMatches:`Niets gevonden`,loading:`Laden`,leaveTitle:`Weggaan zonder te bewaren?`,leaveDescription:`Je hebt niet-bewaarde wijzigingen op deze pagina. Ze blijven in deze browser, en komen terug als je het record weer opent.`,stay:`Blijven`,leave:`Weggaan`,show:e=>`${e} tonen`,hide:e=>`${e} verbergen`,couldNotShow:e=>`Kon ${e} niet tonen`,noAnswer:`Het antwoordde niet.`,signInRefused:e=>`Het accepteerde je inlog niet: ${e}`,loadingFrom:e=>`Laden van ${e}`,restWorks:`De rest van de app werkt zoals eerst.`,tryAgain:`Opnieuw proberen`,staffSession:`Sessie van een medewerker`,staffSignedIn:`{} is ingelogd als {} tot {}. Reden: {}`,stopStaffSession:`Sessie van medewerker stoppen`,open:`Openen`,openLabel:e=>`${e} openen`}}),Nm=(0,L.createContext)(null),Pm=()=>{let e=(0,L.useContext)(Nm);if(!e)throw Error(`useRouter must be used inside Router`);return e},Fm=()=>`${window.location.pathname}${window.location.search}`,Im=e=>new URL(e,`http://local`).pathname,Lm=()=>window.history.state??{},Rm=()=>Lm().protobaseIndex??0,zm=()=>Math.random().toString(36).slice(2),Bm=()=>{let e=Lm();if(e.protobaseEntry)return e.protobaseEntry;let t=zm();return window.history.replaceState({...e,protobaseEntry:t},``),t},Hne=({basePath:e=``,initialUrl:t,children:n})=>{let r=t!==void 0,[i,a]=(0,L.useState)(()=>({url:t??Fm(),entry:r?zm():Bm()})),o=(0,L.useRef)(new Set),s=(0,L.useRef)(i);s.current=i;let c=(0,L.useRef)(r?0:Rm()),l=(0,L.useRef)(!1),u=(0,L.useRef)(!1),d=(0,L.useRef)(void 0),[f,p]=(0,L.useState)();(0,L.useEffect)(()=>{if(r)return;window.history.replaceState({protobaseIndex:c.current,protobaseEntry:s.current.entry},``);let e=()=>{let e=Rm();if(l.current){l.current=!1,c.current=e,d.current!==void 0&&window.history.go(d.current),d.current=void 0;return}let t=e-c.current,n=Im(Fm())!==Im(s.current.url);if(!u.current&&o.current.size>0&&n){l.current=!0,window.history.go(-t),p({kind:`history`,delta:t});return}u.current=!1,c.current=e,a({url:Fm(),entry:Bm()})};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[r]);let m=(0,L.useCallback)((e,t)=>{let n=t?s.current.entry:zm();r||(c.current+=+!t,window.history[t?`replaceState`:`pushState`]({protobaseIndex:c.current,protobaseEntry:n},``,e)),a({url:e,entry:n})},[r]),h=(0,L.useCallback)((t,{replace:n=!1}={})=>{let r=`${e}${t}`;if(Im(r)!==Im(s.current.url)&&o.current.size>0)return p({kind:`link`,full:r,replace:n});m(r,n)},[e,m]),g=(0,L.useCallback)(()=>{let e=Symbol(`guard`);return o.current.add(e),()=>void o.current.delete(e)},[]),_=()=>{if(f){if(p(void 0),f.kind===`link`)return m(f.full,f.replace);u.current=!0,l.current?d.current=f.delta:window.history.go(f.delta)}},v=(0,L.useMemo)(()=>{let t=new URL(i.url,`http://local`);return{path:t.pathname.slice(e.length)||`/`,params:t.searchParams,basePath:e,entry:i.entry,navigate:h,registerGuard:g}},[i,e,h,g]);return(0,z.jsxs)(Nm.Provider,{value:v,children:[n,f&&(0,z.jsx)(_p,{title:H(`leaveTitle`),description:H(`leaveDescription`),onClose:()=>p(void 0),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:()=>p(void 0),children:H(`stay`)}),(0,z.jsx)(V,{variant:`primary`,onClick:_,children:H(`leave`)})]})})]})},Une=({to:e,replace:t,...n})=>{let{navigate:r,basePath:i}=Pm();return(0,z.jsx)(Qu,{to:{href:`${i}${e}`,onFollow:()=>r(e,{replace:t})},...n})},Wne=e=>{let{registerGuard:t}=Pm();(0,L.useEffect)(()=>e?t():void 0,[e,t]),(0,L.useEffect)(()=>{if(!e)return;let t=e=>e.preventDefault();return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e])},Vm=()=>{let{path:e,params:t,basePath:n,navigate:r}=Pm(),i=(0,L.useMemo)(()=>Is(e,t),[e,t]),a=_f(new URL(t.size>0?`${e}?${t}`:e,`http://local`).href),o=i?i.next:a,s=(0,L.useCallback)((e=`sign-in`,t)=>r(Fs({step:e,next:o}),t),[r,o]);return{address:i,next:o,open:s,link:(0,L.useCallback)((e=`sign-in`,t)=>({href:`${n}${Fs({step:e,next:o})}`,onFollow:()=>s(e,t)}),[n,o,s]),leave:(0,L.useCallback)(()=>r(o??`/`,{replace:!0}),[r,o])}},Hm=({benefits:e})=>e&&e.length>0?(0,z.jsx)(`ul`,{className:`flex flex-col gap-2 text-left`,children:e.map(e=>(0,z.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(xi,{className:`mt-0.5 size-4 shrink-0 text-primary`,"aria-hidden":!0}),e]},e))}):null,Um=({prompt:e})=>{let{canSignUp:t}=xf(),{link:n}=Vm(),r=gp({variant:`primary`}),i=e.signUp?(0,z.jsx)(`a`,{href:e.signUp.href,target:`_blank`,rel:`noreferrer`,className:r,children:e.signUp.label}):t&&(0,z.jsx)(Qu,{to:n(`sign-up`),className:r,children:B(`createAnAccount`)});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Qu,{to:n(),className:i?gp():r,children:B(`signIn`)}),i]})},Wm=e=>{let{prompt:t}=e,n=(0,L.useId)();if(e.as===`dialog`)return(0,z.jsx)(Mm,{title:t.title,description:t.description,open:e.open,onClose:e.onClose,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:e.onClose,children:B(`notNow`)}),(0,z.jsx)(Um,{prompt:t})]}),children:(0,z.jsx)(Hm,{benefits:t.benefits})});let r=km(t.icon)??Oa;return(0,z.jsxs)(`section`,{"aria-labelledby":n,className:`mx-auto flex w-full max-w-md flex-col items-center gap-4 px-5 py-10 text-center sm:py-16`,children:[(0,z.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,z.jsx)(r,{className:`size-6`,"aria-hidden":!0})}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`h1`,{id:n,className:`text-lg font-semibold`,children:t.title}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:t.description})]}),(0,z.jsx)(Hm,{benefits:t.benefits}),(0,z.jsx)(`div`,{className:`mt-2 flex w-full flex-col-reverse gap-2 sm:w-auto sm:flex-row sm:justify-center [&>*]:min-h-11 sm:[&>*]:min-h-0`,children:(0,z.jsx)(Um,{prompt:t})})]})},Gm=L.createContext(void 0),Km=e=>{let t=L.useContext(Gm);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Gne=({client:e,children:t})=>(L.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,z.jsx)(Gm.Provider,{value:e,children:t})),Kne={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},qm=new class{#e=Kne;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function qne(e){setTimeout(e,0)}var Jne=typeof window>`u`||`Deno`in globalThis;function Jm(){}function Yne(e,t){return typeof e==`function`?e(t):e}function Ym(e){return typeof e==`number`&&e>=0&&e!==1/0}function Xm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Zm(e,t){return typeof e==`function`?e(t):e}function Qm(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==eh(o,t.options))return!1}else if(!nh(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function $m(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(th(t.options.mutationKey)!==th(a))return!1}else if(!nh(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function eh(e,t){return(t?.queryKeyHashFn||th)(e)}function th(e){return JSON.stringify(e,(e,t)=>oh(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function nh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!nh(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!nh(e[r],t[r]))return!1;return!0}return!1}var Xne=Object.prototype.hasOwnProperty;function rh(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ah(e)&&ah(t);if(!r&&!(oh(e)&&oh(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Xne.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=rh(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function ih(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ah(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function oh(e){if(!sh(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!sh(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function sh(e){return Object.prototype.toString.call(e)===`[object Object]`}function Zne(e){return new Promise(t=>{qm.setTimeout(t,e)})}function ch(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:rh(e,t)}function lh(e){return e}function Qne(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function $ne(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var uh=Symbol();function dh(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===uh?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function fh(e,t){return typeof e==`function`?e(...t):!!e}function ere(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var tre=()=>Jne,ph=()=>tre(),mh=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},hh=new class extends mh{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},nre=qne;function rre(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=nre,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var gh=rre(),_h=new class extends mh{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function ire(e){return Math.min(1e3*2**e,3e4)}function vh(e){return(e??`online`)!==`online`||_h.isOnline()}var yh=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function bh(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(Jm);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new yh(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>hh.isFocused()&&(e.networkMode===`always`||_h.isOnline())&&e.canRun(),p=()=>vh(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(ph()?0:3),a=e.retryDelay??ire,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),Zne(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var xh=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ym(this.gcTime)&&(this.#e=qm.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ph()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(qm.clearTimeout(this.#e),this.#e=void 0)}};function are(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ere(e,()=>t.signal,()=>n=!0)},u=dh(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?$ne:Qne;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Ch:Sh,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Sh(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Sh(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ch(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function ore(e,t){return t?Sh(e,t)!=null:!1}function sre(e,t){return!t||!e.getPreviousPageParam?!1:Ch(e,t)!=null}var cre=class extends xh{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Eh(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Eh(this.options);e.data!==void 0&&(this.setState(Th(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=ch(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Jm).catch(Jm):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Zm(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===uh||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Zm(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Xm(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=dh(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?are(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=bh({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof yh&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof yh){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...wh(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Th(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),gh.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function wh(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:vh(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Th(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Eh(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Dh=class extends mh{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Oh(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return kh(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return kh(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Zm(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!ih(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ah(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||Zm(this.options.enabled,this.#t)!==Zm(t.enabled,this.#t)||Zm(this.options.staleTime,this.#t)!==Zm(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Zm(this.options.enabled,this.#t)!==Zm(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ih(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Jm)),t}#h(e){return!ph()&&Zm(this.options.enabled,this.#t)!==!1&&Ym(e)}#g(){this.#b();let e=Zm(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=Xm(this.#r.dataUpdatedAt,e)+1;this.#u=qm.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return Zm(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=qm.setInterval(()=>{(this.options.refetchIntervalInBackground||hh.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(qm.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(qm.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Oh(e,t),o=i&&Ah(e,n,t,r);(a||o)&&(l={...l,...wh(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=ch(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=ch(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:jh(e,t),refetch:this.refetch,isEnabled:Zm(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),ih(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();gh.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function lre(e,t){return Zm(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Zm(t.retryOnMount,e)!==!1)}function Oh(e,t){return lre(e,t)||e.state.data!==void 0&&kh(e,t,t.refetchOnMount)}function kh(e,t,n){if(Zm(t.enabled,e)!==!1&&Zm(t.staleTime,e)!==`static`){let r=Zm(n,e);return r===`always`||r!==!1&&jh(e,t)}return!1}function Ah(e,t,n,r){return(e!==t||Zm(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&jh(e,n)}function jh(e,t){return Zm(t.enabled,e)!==!1&&e.isStaleByTime(Zm(t.staleTime,e))}var ure=class extends Dh{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ore(t,n.data),hasPreviousPage:sre(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},dre=class extends xh{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Mh(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=bh({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),gh.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Mh(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var fre=class extends mh{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new dre({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Nh(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Nh(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Nh(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Nh(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){gh.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>$m(t,e))}findAll(e={}){return this.getAll().filter(t=>$m(e,t))}notify(e){gh.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return gh.batch(()=>Promise.all(e.map(e=>e.continue().catch(Jm))))}};function Nh(e){return e.options.scope?.id}var pre=class extends mh{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),ih(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&th(t.mutationKey)!==th(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Mh();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){gh.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Ph(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var mre=class extends mh{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,gh.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!ih(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ph(e,n).forEach(e=>{e.destroy()}),Ph(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=rh(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Dh(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&gh.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},hre=class extends mh{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??eh(r,t),a=this.get(i);return a||(a=new cre({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){gh.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Qm(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Qm(e,t)):t}notify(e){gh.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){gh.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){gh.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},gre=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new hre,this.#t=e.mutationCache||new fre,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=hh.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=_h.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Zm(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Yne(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return gh.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;gh.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return gh.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=gh.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Jm).catch(Jm)}invalidateQueries(e,t={}){return gh.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=gh.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Jm)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Jm)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(Zm(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Zm(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Jm).catch(Jm)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Jm).catch(Jm)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return _h.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(th(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{nh(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(th(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{nh(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=eh(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===uh&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Fh=L.createContext(!1),Ih=()=>L.useContext(Fh);Fh.Provider;function _re(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var vre=L.createContext(_re()),Lh=()=>L.useContext(vre),Rh=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?fh(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},zh=e=>{L.useEffect(()=>{e.clearReset()},[e])},Bh=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||fh(n,[e.error,r])),Vh=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Hh=(e,t)=>e?.suspense&&t.isPending,Uh=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Wh({queries:e,...t},n){let r=Km(n),i=Ih(),a=Lh(),o=t.subscribed!==!1,s=L.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:o?`optimistic`:void 0,t}),[e,r,i,o]);s.forEach(e=>{Vh(e);let t=r.getQueryCache().get(e.queryHash);Rh(e,a,t)}),zh(a);let[c]=L.useState(()=>new mre(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;L.useSyncExternalStore(L.useCallback(e=>f?c.subscribe(gh.batchCalls(e)):Jm,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),L.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>Hh(s[t],e))?l.flatMap((e,t)=>{let n=s[t];return n&&Hh(n,e)?Uh(n,new Dh(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=s[t];return n&&Bh({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m)throw m.error;return u(d())}function Gh(e,t,n){let r=Ih(),i=Lh(),a=Km(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Vh(o),Rh(o,i,s),zh(i);let[l]=L.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(L.useSyncExternalStore(L.useCallback(e=>{let t=d?l.subscribe(gh.batchCalls(e)):Jm;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),L.useEffect(()=>{l.setOptions(o)},[o,l]),Hh(o,u))throw Uh(o,l,i);if(Bh({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function Kh(e,t){return Gh(e,Dh,t)}function qh(e,t){let n=Km(t),[r]=L.useState(()=>new pre(n,e));L.useEffect(()=>{r.setOptions(e)},[r,e]);let i=L.useSyncExternalStore(L.useCallback(e=>r.subscribe(gh.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=L.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(Jm)},[r]);if(i.error&&fh(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Jh(e,t){return Gh(e,ure,t)}var yre=()=>{let e=0;return{refetchOnWindowFocus:()=>e>0?!1:`always`,paused:()=>e>0,pause:()=>{e+=1;let t=!1;return()=>{t||(t=!0,--e)}}}},Yh=(0,L.createContext)(null),bre=e=>{let t=(0,L.useContext)(Yh);(0,L.useEffect)(()=>e&&t?t.pause():void 0,[e,t])},xre=e=>{let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),window.addEventListener(`focus`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t),window.removeEventListener(`focus`,t)}},U={meta:[`meta`],sourceMeta:(e,t)=>[`source-meta`,e,t.join(`,`)],sourceMetas:e=>[`source-meta`,e],list:(e,t,n,r,i)=>[`list`,e,t,n,r,i],page:(e,t,n,r,i)=>[`page`,e,t,n,r,i],pages:(e,t,n)=>[`page`,e,t,n],navRecent:(e,t,n,r)=>[`list`,e,t,n,r,`nav-recent`],first:(e,t,n)=>[`first-page`,e,t,n],record:(e,t)=>[`record`,e,t],recordPreview:(e,t)=>[`record-preview`,e,t],history:(e,t,n)=>[`record`,e,t,`history`,n],comments:(e,t)=>[`record`,e,t,`comments`],mentionable:(e,t,n)=>[`record`,e,t,`mentionable`,n],facets:(e,t,n)=>[`facets`,e,t,n],series:(e,t,n,r,i)=>[`series`,e,t,n,r,i],aggregate:(e,t)=>[`aggregate`,e,t],histogram:(e,t,n,r)=>[`histogram`,e,t,n,r],map:(e,t,n,r,i)=>[`map`,e,t,n,r,i],relatedLabel:(e,t)=>[`related-label`,e,t],labels:(e,t)=>[`labels`,e,t],pickedLabels:(e,t)=>[`picked-labels`,e,t],count:(e,t)=>[`count`,e,t],exportCount:(e,t)=>[`list`,e,t,`export-count`],firstRecord:(e,t,n)=>[`first-record`,e,t,n],pathValue:(e,t,n)=>[`path-value`,e,t,n],publicForm:e=>[`public-form`,e]},Xh=(0,L.createContext)(null),Zh=(0,L.createContext)(null),Qh=(0,L.createContext)(null),W=()=>{let e=(0,L.useContext)(Xh);if(!e)throw Error(`useClient must be used inside ApiProvider`);return e},$h=e=>{let t=W();return(0,L.useContext)(Qh)?.(e)??t},Sre=()=>{let e=W(),t=(0,L.useContext)(Qh);return(0,L.useCallback)(n=>t?.(n)??e,[e,t])},Cre=()=>{let e=(0,L.useContext)(Zh);if(!e)throw Error(`useSourceClients must be used inside ApiProvider`);return e},wre=({client:e,resourceClient:t,children:n})=>(0,z.jsx)(Xh.Provider,{value:e,children:(0,z.jsx)(Qh.Provider,{value:t,children:n})}),eg=({baseUrl:e,client:t,sources:n,fetch:r,queryClient:i,token:a,onUnauthenticated:o,children:s})=>{let[c]=(0,L.useState)(yre),[l]=(0,L.useState)(()=>i??new gre({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:c.refetchOnWindowFocus}}}));(0,L.useEffect)(()=>hh.setEventListener(xre),[]);let u=(0,L.useRef)(void 0),d=(0,L.useMemo)(()=>t??fc({baseUrl:e,fetch:r,token:a,onUnauthenticated:o,onMetaVersion:e=>{let t=u.current;u.current=e,t!==void 0&&t!==e&&l.invalidateQueries({queryKey:U.meta},{cancelRefetch:!1})}}),[t,e,r,l,a,o]),f=(0,L.useMemo)(()=>{let e=new Map;return t=>{let i=n?.[t.url]??e.get(t.url);if(i)return i;let o,s=fc({baseUrl:t.url,fetch:r,token:a,onMetaVersion:e=>{let n=o;o=e,n!==void 0&&n!==e&&l.invalidateQueries({queryKey:U.sourceMetas(t.url)},{cancelRefetch:!1})}});return e.set(t.url,s),s}},[n,r,a,l]);return(0,z.jsx)(Gne,{client:l,children:(0,z.jsx)(Xh.Provider,{value:d,children:(0,z.jsx)(Zh.Provider,{value:f,children:(0,z.jsx)(Yh.Provider,{value:c,children:s})})})})},tg=(0,L.createContext)(null),ng={create:!0,update:!0,delete:!0,conditional:[]},rg=()=>{let e=W(),t=Km(),n=(0,L.useContext)(tg),r=Kh({queryKey:U.meta,staleTime:0,refetchOnWindowFocus:`always`,queryFn:async()=>{let n=t.getQueryData(U.meta),r=await e.meta(n?.etag);if(r.status===`unchanged`){if(!n)throw Error(`The server answered 304 to a request without If-None-Match`);return n}return{etag:r.etag,appName:r.meta.appName,...r.meta.appIcon&&{appIcon:r.meta.appIcon},resources:Object.fromEntries(r.meta.resources.map(e=>[e.name,e])),views:Object.fromEntries(r.meta.views.map(e=>[e.resource,e])),pages:Object.fromEntries((r.meta.pages??[]).map(e=>[e.name,e])),permissions:r.meta.permissions??{},...r.meta.userMenu&&{userMenu:r.meta.userMenu},...r.meta.signIn&&{signIn:Object.fromEntries(r.meta.signIn.map(e=>[e.resource,e]))},...r.meta.bottomBar&&{bottomBar:r.meta.bottomBar},...r.meta.assistant&&{assistant:r.meta.assistant},...r.meta.runtime&&{runtime:r.meta.runtime},...r.meta.errorReporting&&{errorReporting:r.meta.errorReporting},...r.meta.maps&&{maps:r.meta.maps},...r.meta.locale&&{locale:r.meta.locale},...r.meta.files&&{files:r.meta.files},...r.meta.plugins&&{plugins:r.meta.plugins},...r.meta.sources&&{sources:r.meta.sources.map(e=>({source:e,state:`loading`}))}}}});return(0,L.useMemo)(()=>n&&r.data?{...r,data:n}:r,[n,r])},Tre=1e4,Ere=e=>e.map(e=>({data:e.data?.meta,error:e.error})),Dre=(e,t)=>{let n=Km(),r=Wh({queries:e.map(e=>{let r=U.sourceMeta(e.url,e.resources);return{queryKey:r,staleTime:0,refetchOnWindowFocus:`always`,queryFn:async()=>{let i=n.getQueryData(r),a=await t(e).meta(i?.etag,{signal:AbortSignal.timeout(Tre)});if(a.status===`unchanged`){if(!i)throw Error(`${e.label} answered 304 to a request without If-None-Match`);return i}return{etag:a.etag,meta:Dc(a.meta,e)}}}}),combine:Ere});return(0,L.useMemo)(()=>e.map((e,t)=>{let{data:n,error:i}=r[t];return n?{source:e,state:`ready`,meta:n}:i?{source:e,state:`error`,error:i}:{source:e,state:`loading`}}),[e,r])},Ore=(e,t)=>{if(t.length===0)return e;let n=t.flatMap(e=>e.state===`ready`?[e.meta]:[]),r=t.map(e=>e.state===`error`?{source:e.source,state:`error`,error:e.error}:{source:e.source,state:e.state});return{...e,resources:{...e.resources,...Object.fromEntries(n.flatMap(e=>e.resources.map(e=>[e.name,e])))},views:{...e.views,...Object.fromEntries(n.flatMap(e=>e.views.map(e=>[e.resource,e])))},permissions:{...e.permissions,...Object.assign({},...n.map(e=>e.permissions))},sources:r}},ig=(e,t)=>e.sources?.find(e=>e.source.resources.includes(t)),ag=({locale:e,children:t})=>{h(e);let n=p();return(0,L.useEffect)(()=>{document.documentElement.lang=n},[n]),(0,z.jsx)(L.Fragment,{children:t},n)},og=a({en:{loading:`Loading`,cannotReach:`Cannot reach the API`,noAnswer:`The server did not answer. Is it running?`},nl:{loading:`Laden`,cannotReach:`De API is niet bereikbaar`,noAnswer:`De server gaf geen antwoord. Draait hij?`}}),G=()=>{let e=(0,L.useContext)(tg);if(!e)throw Error(`useAdminMeta must be used inside MetaGate`);return e},sg=({title:e,children:t})=>(0,z.jsx)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center p-8`,children:(0,z.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,z.jsx)(`h1`,{className:`text-[16px] font-semibold`,children:e}),(0,z.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]})}),kre=({meta:e,children:t})=>{let n=W(),r=Cre(),i=(0,L.useMemo)(()=>(e.sources??[]).map(e=>e.source),[e.sources]),a=Dre(i,r),o=(0,L.useMemo)(()=>Ore(e,a),[e,a]),s=(0,L.useMemo)(()=>{let e=new Map(i.flatMap(e=>e.resources.map(t=>[t,e]))),t=t=>{let n=e.get(t);return n&&r(n)};return{client:mc(n,t),resourceClient:t}},[i,n,r]);return(0,z.jsx)(wre,{client:s.client,resourceClient:s.resourceClient,children:(0,z.jsx)(tg.Provider,{value:o,children:(0,z.jsx)(ag,{locale:e.locale,children:t})})})},Are=({children:e})=>{let t=rg();return t.isPending?(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,og(`loading`)]}):t.error?(0,z.jsx)(sg,{title:og(`cannotReach`),children:Xs(t.error)?t.error.message:og(`noAnswer`)}):(0,z.jsx)(kre,{meta:t.data,children:e})},cg=e=>G().permissions[e]??ng,jre=(e=window)=>e.top!==e.self,Mre=(e,t,n)=>{let r=!1,i,a=e=>{r!==e&&(r=e,n(e))},o=()=>{clearTimeout(i),a(!1)},s=()=>{o(),e.visibilityState===`visible`&&e.hasFocus()&&(i=setTimeout(()=>a(!0),t))},c=()=>e.visibilityState===`visible`?s():o();return e.defaultView?.addEventListener(`focus`,s),e.defaultView?.addEventListener(`blur`,o),e.addEventListener(`visibilitychange`,c),s(),()=>{clearTimeout(i),e.defaultView?.removeEventListener(`focus`,s),e.defaultView?.removeEventListener(`blur`,o),e.removeEventListener(`visibilitychange`,c)}},Nre=()=>{let e=!1;return{down:(t,n=!1)=>{e=t&&!n},take:()=>{let t=e;return e=!1,t}}},Pre=e=>{let[t,n]=(0,L.useState)(!1);return(0,L.useEffect)(()=>Mre(document,e,n),[e]),t},Fre=(e,t)=>{let n=(0,L.useRef)(Nre());return{onPointerDown:()=>n.current.down(e),onKeyDown:t=>n.current.down(e,t.repeat),onClick:()=>{n.current.take()&&t()}}},Ire=[`localhost`,`127.0.0.1`,`[::1]`],lg=[`javascript:`,`data:`,`vbscript:`,`file:`,`blob:`,`about:`],Lre=e=>{if(!URL.canParse(e))return;let t=new URL(e);if(t.protocol===`https:`)return{kind:`site`,host:t.host};if(t.protocol===`http:`)return Ire.includes(t.hostname)?{kind:`this-computer`,port:t.port||`80`}:void 0;if(!lg.includes(t.protocol))return{kind:`device-app`,uri:e.split(`?`)[0].split(`#`)[0]}},Rre=e=>!URL.canParse(e,`http://local`)||!lg.includes(new URL(e,`http://local`).protocol),zre=(e,t)=>{let n=new URL(e,t.origin);if(n.origin===t.origin&&n.pathname===t.pathname)return ks(n.search).oauthQuery},Bre=()=>{let{params:e}=Pm();return(0,L.useMemo)(()=>ks(e.toString()),[e])},Vre={invalid_signature:`This request has expired: connect again from your app.`,STAFF_CANNOT_CONNECT:`Staff signed in as someone cannot allow apps to act for them.`,SIGN_IN_SETUP_REQUIRED:`Set up what this app requires for signing in first, then connect again from your app.`,ADDRESS_NOT_VERIFIED:`Confirm your address first: sign out, then sign in with a code emailed to you, and connect again from your app.`},Hre=e=>{if(!(e instanceof Oc))throw e;return(e.code&&Vre[e.code])??sf(e)},Ure=e=>t=>{if(!Rre(t))throw new Oc(`The app asked to be sent somewhere this page will not go.`,400);e(t)},Wre=({target:e})=>e.kind===`site`?(0,z.jsxs)(z.Fragment,{children:[`the website `,(0,z.jsx)(`strong`,{className:`font-medium text-foreground`,children:e.host})]}):e.kind===`this-computer`?(0,z.jsxs)(z.Fragment,{children:[`an app on this computer (port `,e.port,`)`]}):(0,z.jsxs)(z.Fragment,{children:[`an app on this device that opens `,(0,z.jsx)(`code`,{className:`break-all text-foreground`,children:e.uri})]}),Gre=({asking:e,appName:t,email:n,onAnswer:r,onSignOut:i})=>{let[a,o]=(0,L.useState)(!1),s=Pre(500),c=e=>{o(!0),r(e).finally(()=>o(!1))},l=Fre(s&&!a,()=>c(!0)),u=wf(e.client.client_name),d=Tf(e.client.client_id),{target:f}=e;return(0,z.jsx)(`div`,{className:`mx-auto flex w-full max-w-lg flex-col gap-4 px-4 py-10`,children:(0,z.jsxs)(`section`,{"aria-label":`Allow an app`,className:`rounded-lg border bg-background p-5`,children:[(0,z.jsxs)(`h1`,{className:`text-[16px] font-semibold`,children:[`Allow an app to act as you in `,t,`?`]}),(0,z.jsxs)(`p`,{className:`mt-3`,children:[`An app that calls itself`,` `,(0,z.jsxs)(`bdi`,{className:`inline-block max-w-full truncate align-bottom font-medium`,title:u,children:[`“`,u??`no name`,`”`]}),` `,`asks to act as you here.`]}),d&&(0,z.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Published by `,d,`.`]}),f?(0,z.jsxs)(`p`,{className:`mt-3 text-muted-foreground`,children:[`Allowing sends you on to `,(0,z.jsx)(Wre,{target:f}),`.`]}):(0,z.jsx)(`p`,{role:`alert`,className:`mt-3 text-danger-text`,children:`This app asked to be sent somewhere this page will not go, so it cannot be allowed.`}),(0,z.jsx)(`p`,{className:`mt-3 text-muted-foreground`,children:`It can then read and change what you can, with your current role and organization, until you disconnect it from your account page.`}),(0,z.jsxs)(`div`,{className:`mt-5 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,children:[(0,z.jsx)(V,{disabled:a,onClick:()=>c(!1),children:`Deny`}),f&&(0,z.jsx)(V,{variant:`primary`,loading:a,disabled:!s||a,...l,children:`Allow`})]}),(0,z.jsxs)(`p`,{className:`mt-4 border-t pt-3 text-xs text-muted-foreground`,children:[`Signed in as `,n,`.`,` `,(0,z.jsx)(`button`,{type:`button`,className:`underline underline-offset-2 hover:text-foreground`,onClick:i,children:`Not you? Sign out`})]})]})})},Kre=({oauthQuery:e,appName:t,email:n,assign:r})=>{let{session:i,signOut:a}=xf(),{path:o,basePath:s}=Pm(),c=Ure(r),l=e=>zre(e,{origin:window.location.origin,pathname:`${s}${o}`}),[u,d]=(0,L.useState)({kind:`loading`}),f=e=>d({kind:`failed`,message:Hre(e)});(0,L.useEffect)(()=>{let t=!0;return(async()=>{let{url:n}=await i.connect.resume(e),r=l(n);if(r===void 0)return c(n);let a=new URLSearchParams(r),o=await i.connect.client(a.get(`client_id`)??``);t&&d({kind:`asking`,asking:{oauthQuery:r,client:o,target:Lre(a.get(`redirect_uri`)??``)}})})().catch(e=>t&&f(e)),()=>{t=!1}},[i,e]);let p=async(e,t)=>{try{let{url:n}=await i.connect.answer(e,t.oauthQuery);l(n)!==void 0&&await a(),c(n)}catch(e){f(e)}};return u.kind===`failed`?(0,z.jsx)(sg,{title:`This app cannot be connected`,children:u.message}):u.kind===`loading`?(0,z.jsxs)(`div`,{className:`flex min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` Loading`]}):(0,z.jsx)(Gre,{asking:u.asking,appName:t,email:n,onAnswer:e=>p(e,u.asking),onSignOut:()=>void a()})},qre=({email:e,appName:t,isFramed:n=jre,assign:r=e=>window.location.assign(e)})=>{let[i]=(0,L.useState)(n),{oauthQuery:a}=Bre();return i?(0,z.jsxs)(sg,{title:`This page cannot be used inside another site`,children:[(0,z.jsx)(`a`,{href:window.location.href,target:`_blank`,rel:`noopener`,className:`underline underline-offset-2`,children:`Open it on its own`}),` `,`to go on.`]}):a?(0,z.jsx)(Kre,{oauthQuery:a,appName:t,email:e,assign:r},a):(0,z.jsx)(sg,{title:`Nothing to connect`,children:`Connect again from your app.`})},ug=()=>[{value:`allowed`,label:R(`on`)},{value:`forbidden`,label:R(`off`)}],dg=()=>[{value:`allowed`,label:R(`optional`)},{value:`required`,label:R(`required`)},{value:`forbidden`,label:R(`off`)}],fg=()=>[{method:`password`,label:R(`password`),description:R(`passwordDescription`),rules:ug()},{method:`emailCode`,label:R(`emailedSignInCode`),description:R(`emailedSignInCodeDescription`),rules:ug()},{method:`passkey`,label:R(`passkeys`),description:R(`passkeysPolicyDescription`),rules:dg()},{method:`twoFactor`,label:R(`twoFactor`),description:R(`twoFactorPolicyDescription`),rules:dg()},{method:`staffAccess`,label:R(`staffAccess`),description:R(`staffAccessDescription`),rules:[{value:`allowed`,label:R(`on`)},{value:`notify`,label:R(`emailThePerson`)},{value:`forbidden`,label:R(`off`)}]},{method:`platformSignIn`,label:R(`platformSignIn`),description:R(`platformSignInDescription`),rules:ug()}],Jre=(e,t)=>{let n=fg().find(t=>t.method===e)?.rules.find(e=>e.value===t)?.label;if(n===void 0)throw Error(`No label for the ${t} rule of ${e}`);return n},Yre=({row:e,value:t,onChange:n})=>(0,z.jsx)(`span`,{role:`radiogroup`,"aria-label":e.label,className:`inline-flex h-8 shrink-0 rounded-md bg-muted p-0.5`,children:e.rules.map(e=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t,onClick:()=>n(e.value),className:g(`rounded px-3 text-body font-medium transition-colors`,e.value===t?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value))}),Xre=({method:e},t,{mail:n,effective:r,policy:i})=>{if(e===`emailCode`&&!n)return R(`codeNeedsMail`);if(e===`password`&&!n&&t.password===`forbidden`)return R(`passwordStaysOn`);if(e===`staffAccess`&&!n&&t.staffAccess===`notify`)return R(`staffNeedsMail`);if(e===`platformSignIn`&&t.platformSignIn===`allowed`&&(t.passkey===`required`||t.twoFactor===`required`))return R(`platformOff`);if(t[e]===i[e]&&r[e]!==i[e])return R(`appliesAs`,Jre(e,r[e]))},Zre=({operator:e,platformSignIn:t})=>fg().flatMap(n=>n.method===`staffAccess`&&!e?[]:n.method===`platformSignIn`?t?[{...n,label:R(`platformSignInWith`,t)}]:[]:[n]),Qre=({state:e,onSave:t,busy:n,error:r,notice:i})=>{let[a,o]=(0,L.useState)(e.policy),s=Zre(e),c=s.some(({method:t})=>a[t]!==e.policy[t]);return(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t(a)},children:[(0,z.jsx)(`ul`,{className:`divide-y rounded-lg border bg-background`,children:s.map(t=>{let n=Xre(t,a,e);return(0,z.jsxs)(`li`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`font-semibold`,children:t.label}),(0,z.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t.description}),n&&(0,z.jsx)(`p`,{className:`mt-1.5 text-xs font-medium text-warning-text`,children:n})]}),(0,z.jsx)(Yre,{row:t,value:a[t.method],onChange:e=>o({...a,[t.method]:e})})]},t.method)})}),r&&(0,z.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-body font-medium text-danger-text`,children:r}),i&&!c&&(0,z.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.savedAt?e.savedBy?R(`lastSavedBy`,e.savedBy,np(Date.parse(e.savedAt))):R(`lastSaved`,np(Date.parse(e.savedAt))):R(`neverChanged`)}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[c&&(0,z.jsx)(V,{onClick:()=>o(e.policy),children:R(`reset`)}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:n,disabled:!c,children:R(`save`)})]})]})]})},$re=(e,t)=>e.endedAt?(0,z.jsx)(_d,{tone:`neutral`,children:R(`stopped`,np(Date.parse(e.endedAt)))}):Date.parse(e.expiresAt)<=t?(0,z.jsx)(_d,{tone:`neutral`,children:R(`ended`,np(Date.parse(e.expiresAt)))}):(0,z.jsx)(_d,{tone:`amber`,children:R(`signedInUntil`,np(Date.parse(e.expiresAt)))}),eie=({signIns:e,operator:t,error:n,now:r=Date.now()})=>(0,z.jsxs)(vp,{title:R(`staffSignIns`),description:R(`staffSignInsDescription`,t),children:[(0,z.jsx)(yp,{message:n}),e&&e.length===0&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:R(`noStaffSignIns`)}),e&&e.length>0&&(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,z.jsxs)(`li`,{className:`flex flex-col gap-1.5 p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,z.jsx)(`span`,{className:`font-medium break-all`,children:e.staffName?`${e.staffName} (${e.staff})`:e.staff}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:R(`as`)}),(0,z.jsx)(`span`,{className:`font-medium break-all`,children:e.user})]}),(0,z.jsx)(`p`,{className:`break-words`,children:e.reason}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:np(Date.parse(e.startedAt))}),$re(e,r)]})]},e.id))})]}),tie=({operator:e})=>{let{session:t}=xf(),[n,r]=(0,L.useState)(),[i,a]=(0,L.useState)();return(0,L.useEffect)(()=>{t.staff.log().then(r,e=>a(e instanceof Oc?sf(e):R(`couldNotReadStaffSignIns`)))},[t]),(0,z.jsx)(eie,{operator:e,signIns:n,error:i})},nie=()=>{let{session:e}=xf(),[t,n]=(0,L.useState)(),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(),[s,c]=(0,L.useState)();(0,L.useEffect)(()=>{e.signInPolicy.read().then(n,e=>o(e instanceof Oc?sf(e):R(`couldNotReadPolicy`)))},[e]);let l=async t=>{i(!0),o(void 0),c(void 0);try{n(await e.signInPolicy.save(t)),c(R(`policySaved`))}catch(e){if(!(e instanceof Oc))throw e;o(sf(e))}i(!1)};return(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,z.jsx)(ef,{title:R(`signInPolicy`),subtitle:R(`policySubtitle`)}),t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Qre,{state:t,busy:r,error:a,notice:s,onSave:e=>void l(e)},t.savedAt??`default`),t.operator&&(0,z.jsx)(tie,{operator:t.operator})]}):a?(0,z.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:a}):(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,R(`loading`)]})]})},pg=({title:e,description:t,size:n=`sm`,children:r})=>(0,z.jsx)(`div`,{className:`flex min-h-full w-full items-center justify-center bg-surface px-4 py-10`,children:(0,z.jsxs)(`div`,{className:g(`w-full`,n===`sm`?`max-w-sm`:`max-w-lg`),children:[(0,z.jsxs)(`div`,{className:`mb-6 flex flex-col items-center text-center`,children:[(0,z.jsx)(nd,{className:`size-10`}),(0,z.jsx)(`h1`,{className:`mt-4 text-xl font-semibold tracking-tight`,children:e}),t&&(0,z.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]}),(0,z.jsx)(`div`,{className:`rounded-lg border bg-background p-5 shadow-sm`,children:r})]})}),mg=({onResend:e,cooldown:t=30,disabled:n})=>{let[r,i]=(0,L.useState)(()=>Date.now()+t*1e3),[a,o]=(0,L.useState)(()=>Date.now()),s=Math.max(0,Math.ceil((r-a)/1e3));return(0,L.useEffect)(()=>{if(s===0)return;let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[s]),(0,z.jsx)(V,{variant:`ghost`,disabled:n||s>0,onClick:()=>{let n=Date.now();i(n+t*1e3),o(n),e()},className:`min-h-10`,children:s>0?B(`sendNewCodeIn`,s):B(`sendNewCode`)})},hg=({title:e,description:t,explanation:n,submitLabel:r,onSubmit:i,onResend:a,onChangeAddress:o,changeAddressLabel:s,busy:c,error:l,notice:u,resendCooldown:d})=>{let[f,p]=(0,L.useState)(``);return(0,z.jsxs)(pg,{title:e,description:t,children:[(0,z.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:n}),u&&(0,z.jsx)(`p`,{role:`status`,className:`mb-4 rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:u}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),i(f)},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`code`),(0,z.jsx)(Mp,{name:`code`,required:!0,autoFocus:!0,value:f,invalid:!!l,onChange:p,onComplete:e=>!c&&i(e)})]}),l&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:l}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:c,className:`min-h-10`,children:r}),(0,z.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-x-2 sm:justify-between`,children:[(0,z.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:s}),(0,z.jsx)(mg,{onResend:a,disabled:c,cooldown:d})]})]})]})},gg=(e,...t)=>{let n=e.split(`{}`);if(n.length!==t.length+1)throw Error(`The text "${e}" has ${n.length-1} places for ${t.length} elements`);return(0,z.jsx)(z.Fragment,{children:n.map((e,n)=>(0,z.jsxs)(L.Fragment,{children:[e,n<t.length&&t[n]]},n))})},rie=({email:e,onBack:t,...n})=>(0,z.jsx)(hg,{title:B(`checkEmail`),description:B(`signInCodeDescription`),explanation:(0,z.jsx)(z.Fragment,{children:gg(B(`signInCodeSent`),(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),submitLabel:B(`signIn`),onChangeAddress:t,changeAddressLabel:B(`backToSignIn`),...n}),iie=({email:e,onBack:t})=>{let{signInWithCode:n,sendSignInCode:r}=xf(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(),[c,l]=(0,L.useState)(),u=async e=>{a(!0),s(void 0),l(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;s(sf(e))}a(!1)};return(0,z.jsx)(rie,{email:e,busy:i,error:o,notice:c,onBack:t,onSubmit:t=>void u(()=>n(e,t)),onResend:()=>void u(async()=>{await r(e),l(B(`newCodeSent`))})})},aie=`protobase users create you@example.com`,oie=({command:e=aie,onCheckAgain:t,busy:n})=>{let[r,i]=(0,L.useState)(!1);return(0,z.jsxs)(pg,{title:B(`noAdminTitle`),description:B(`noAdminDescription`),children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`noAdminExplanation`)}),(0,z.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-md border bg-surface py-1.5 pl-3 pr-1.5`,children:[(0,z.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-xs`,children:e}),(0,z.jsx)(`button`,{type:`button`,"aria-label":B(`copyCommand`),onClick:()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)})},className:`inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted pointer-coarse:size-11`,children:r?(0,z.jsx)(xi,{className:`size-4 text-success`}):(0,z.jsx)(Li,{className:`size-4`})})]}),(0,z.jsx)(V,{variant:`primary`,className:`mt-4 min-h-10 w-full`,loading:n,onClick:t,children:B(`reload`)})]})},sie=({onSubmit:e,back:t,busy:n,error:r,sentTo:i})=>{let[a,o]=(0,L.useState)(``);return i?(0,z.jsxs)(pg,{title:B(`checkEmail`),children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:gg(B(`resetSent`),(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:i}))}),(0,z.jsx)(Qu,{to:t,className:g(gp({variant:`primary`}),`mt-4 min-h-10 w-full`),children:B(`backToSignIn`)})]}):(0,z.jsx)(pg,{title:B(`resetTitle`),description:B(`resetDescription`),children:(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(a.trim())},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`email`),(0,z.jsx)(Wd,{type:`email`,name:`email`,autoComplete:`username`,required:!0,autoFocus:!0,value:a,invalid:!!r,onChange:e=>o(e.target.value),className:`min-h-6`})]}),r&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:r}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:n,className:`min-h-10`,children:B(`sendResetLink`)}),(0,z.jsx)(Qu,{to:t,className:g(gp({variant:`ghost`}),`min-h-10`),children:B(`backToSignIn`)})]})})},_g=`password-reset`,cie=e=>{let t=new URL(e);return`${t.origin}${t.pathname}?${_g}`},lie=e=>{let t=new URL(e).searchParams;if(t.has(`password-reset`))return{token:t.get(`token`)||void 0}},uie=e=>{let t=new URL(e);for(let e of[_g,`token`,`error`])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},die=({back:e})=>{let{session:t}=xf(),[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(),[o,s]=(0,L.useState)(),c=async e=>{r(!0),a(void 0);try{await t.requestPasswordReset(e,cie(window.location.href)),s(e)}catch(e){if(!(e instanceof Oc))throw e;a(e.status===429?B(`tooManyRequests`):e.message)}r(!1)};return(0,z.jsx)(sie,{busy:n,error:i,sentTo:o,back:e,onSubmit:e=>void c(e)})},fie=({name:e,workspace:t})=>(0,z.jsx)(pg,{title:B(`signingInWith`,e),description:t,children:(0,z.jsxs)(`p`,{role:`status`,className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,B(`takingYouTo`,e)]})}),pie=({provider:e,workspace:t,onFailed:n})=>{let{signInProviders:r,signInSocial:i}=xf(),a=r.find(t=>t.id===e),o=a?.name??yf(e),s=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{if(!s.current){if(s.current=!0,!a)return n(B(`providerNotOffered`,o));i(e).catch(e=>{if(!(e instanceof Oc))throw e;n(cf(e))})}},[a,o,e,i,n]),(0,z.jsx)(fie,{name:o,workspace:t})},mie=({onSubmit:e,invalidLink:t,onRequestNewLink:n,onBack:r,busy:i,error:a})=>{let[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(!1);if(t)return(0,z.jsxs)(pg,{title:B(`linkExpiredTitle`),children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`linkExpiredExplanation`)}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[n&&(0,z.jsx)(V,{variant:`primary`,className:`min-h-10`,onClick:n,children:B(`sendNewLink`)}),(0,z.jsx)(V,{variant:n?`ghost`:`primary`,className:`min-h-10`,onClick:r,children:B(`backToSignIn`)})]})]});let f=u?B(`passwordsDiffer`):a;return(0,z.jsx)(pg,{title:B(`choosePassword`),description:B(`atLeast`,12),children:(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),d(o!==c),o===c&&e(o)},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`newPassword`),(0,z.jsx)(Wd,{type:`password`,name:`new-password`,autoComplete:`new-password`,required:!0,minLength:12,autoFocus:!0,value:o,invalid:!!f,onChange:e=>s(e.target.value),className:`min-h-6`})]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`repeatPassword`),(0,z.jsx)(Wd,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,required:!0,minLength:12,value:c,invalid:!!f,onChange:e=>l(e.target.value),className:`min-h-6`})]}),f&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:B(`setPassword`)})]})})},hie=e=>e.status===429?B(`tooManyAttempts`):e.code===`PASSWORD_TOO_SHORT`?B(`useAtLeast`,12):e.code===`PASSWORD_TOO_LONG`?B(`passwordTooLong`):e.message,gie=({token:e,onDone:t,onRequestNewLink:n,onBack:r})=>{let{session:i}=xf(),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(),[l,u]=(0,L.useState)(!e),d=async n=>{o(!0),c(void 0);try{await i.resetPassword(e,n),t()}catch(e){if(!(e instanceof Oc))throw e;e.code===`INVALID_TOKEN`?u(!0):c(hie(e)),o(!1)}};return(0,z.jsx)(mie,{busy:a,error:s,invalidLink:l,onRequestNewLink:n,onBack:r,onSubmit:e=>void d(e)})},_ie=e=>B(e===`twoFactor`?`turnOnTwoFactor`:`addPasskey`),vie=({step:e,twoFactor:t,onAddPasskey:n,busy:r,error:i,onSignOut:a})=>(0,z.jsxs)(pg,{title:_ie(e),description:B(`requiredForEveryAccount`),children:[e===`twoFactor`?(0,z.jsx)(Cm,{...t}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`passkeyExplanation`)}),i&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,z.jsxs)(V,{variant:`primary`,loading:r,onClick:n,className:`min-h-10`,children:[(0,z.jsx)(fa,{className:`size-4`}),B(`addPasskey`)]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:underline`,children:B(`signOut`)})]}),yie=({missing:e})=>{let{session:t,recheck:n,signOut:r}=xf(),[i,a]=(0,L.useState)(),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)();(0,L.useEffect)(()=>{t.account.signInMethods().then(a,e=>l(e instanceof Oc?sf(e):B(`couldNotReadAccount`)))},[t]);let u=async()=>{s(!0),l(void 0);try{await t.account.addPasskey(),n()}catch(e){if(!(e instanceof Oc))throw e;l(sf(e)),s(!1)}};return!i&&!c?(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,B(`loading`)]}):(0,z.jsx)(vie,{step:e[0],busy:o,error:c,onAddPasskey:()=>void u(),onSignOut:()=>void r(),twoFactor:{offerEmailedCodes:i?.mail??!1,needsPassword:i?.account.password??!0,onStartApp:e=>t.account.startAuthenticatorApp(e),onConfirmApp:e=>t.account.confirmAuthenticatorApp(e),onEmailedCodes:e=>t.account.turnOnEmailedCodes(e),onDone:n}})},bie=({className:e})=>(0,z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:g(`size-4 shrink-0`,e),"aria-hidden":!0,children:(0,z.jsx)(`path`,{d:`M10.226 17.284c-2.965-.36-5.054-2.493-5.054-5.256 0-1.123.404-2.336 1.078-3.144-.292-.741-.247-2.314.09-2.965.898-.112 2.111.36 2.83 1.01.853-.269 1.752-.404 2.853-.404 1.1 0 1.999.135 2.807.382.696-.629 1.932-1.1 2.83-.988.315.606.36 2.179.067 2.942.72.854 1.101 2 1.101 3.167 0 2.763-2.089 4.852-5.098 5.234.763.494 1.28 1.572 1.28 2.807v2.336c0 .674.561 1.056 1.235.786 4.066-1.55 7.255-5.615 7.255-10.646C23.5 6.188 18.334 1 11.978 1 5.62 1 .5 6.188.5 12.545c0 4.986 3.167 9.12 7.435 10.669.606.225 1.19-.18 1.19-.786V20.63a2.9 2.9 0 0 1-1.078.224c-1.483 0-2.359-.808-2.987-2.313-.247-.607-.517-.966-1.034-1.033-.27-.023-.359-.135-.359-.27 0-.27.45-.471.898-.471.652 0 1.213.404 1.797 1.235.45.651.921.943 1.483.943.561 0 .92-.202 1.437-.719.382-.381.674-.718.944-.943`})}),xie=({id:e,className:t})=>e===`github`?(0,z.jsx)(bie,{className:t}):null,Sie=()=>(0,z.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`h-px flex-1 bg-border`}),B(`or`),(0,z.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),Cie=({onSubmit:e,busy:t,error:n,workspace:r,notice:i,methods:a=[`password`],onSendCode:o,onPasskey:s,passkeyDomains:c=[],forgotPassword:l,providers:u=[],onContinueWith:d,signUp:f,onBrowse:p})=>{let[m,h]=(0,L.useState)(``),[g,_]=(0,L.useState)(``),v=(0,L.useRef)(null),y=a.includes(`password`),b=a.includes(`emailCode`)&&o!==void 0,x=a.includes(`passkey`)&&s!==void 0,S=d?u:[],C=()=>{v.current?.reportValidity()&&o?.(m.trim())};return(0,z.jsxs)(pg,{title:B(`signInTitle`),description:r,children:[i&&(0,z.jsx)(`p`,{role:`status`,className:`mb-4 rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(S.length>0||x)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[S.map(e=>(0,z.jsxs)(V,{onClick:()=>d?.(e.id),disabled:t,className:`min-h-10 w-full`,children:[(0,z.jsx)(xie,{id:e.id}),B(`continueWith`,e.name)]},e.id)),x&&(0,z.jsxs)(V,{onClick:()=>s?.(),disabled:t,className:`min-h-10 w-full`,children:[(0,z.jsx)(fa,{className:`size-4`}),B(`signInWithPasskey`)]}),x&&c.slice(1).map(e=>(0,z.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>s?.(e),disabled:t,className:`w-full`,children:B(`passkeyFor`,e)},e))]}),y||b?(0,z.jsx)(Sie,{}):n&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-4 text-body font-medium text-danger-text`,children:n})]}),(y||b)&&(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),y?e(m.trim(),g):C()},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`email`),(0,z.jsx)(Wd,{ref:v,type:`email`,name:`email`,autoComplete:`username webauthn`,required:!0,autoFocus:!0,value:m,invalid:!!n,onChange:e=>h(e.target.value),className:`min-h-6`})]}),y&&(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`password`),(0,z.jsx)(Wd,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:g,invalid:!!n,onChange:e=>_(e.target.value),className:`min-h-6`})]}),n&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:n}),y&&(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:t,className:`min-h-10`,children:B(`signIn`)}),b&&(0,z.jsxs)(V,{variant:y?`secondary`:`primary`,type:y?`button`:`submit`,onClick:y?C:void 0,loading:t&&!y,disabled:t,className:`min-h-10`,children:[(0,z.jsx)(Ma,{className:`size-4`}),B(`emailSignInCode`)]}),y&&l&&(0,z.jsx)(Qu,{to:l,className:`self-center font-medium text-primary-text hover:underline`,children:B(`forgotPassword`)})]}),f&&(0,z.jsxs)(`p`,{className:`mt-4 text-center text-muted-foreground`,children:[B(`newHere`),` `,(0,z.jsx)(Qu,{to:f,className:`font-medium text-primary-text hover:underline`,children:B(`createAnAccount`)})]}),p&&(0,z.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:B(`browse`)})]})},wie=({workspace:e,notice:t,forgotPassword:n,signUp:r,onBrowse:i,onCodeSent:a,error:o})=>{let{signIn:s,signInSocial:c,signInProviders:l,signInMethods:u,passkeyDomains:d,sendSignInCode:f,signInWithPasskey:p}=xf(),[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(o),v=async(e,t)=>{h(!0),_(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;_(t(e)),h(!1)}};return(0,z.jsx)(Cie,{busy:m,error:g,workspace:e,notice:t,methods:u,forgotPassword:n,signUp:r,onBrowse:i,providers:l,onContinueWith:e=>void v(()=>c(e),cf),passkeyDomains:d,onPasskey:e=>void v(()=>p(e),sf),onSendCode:e=>void v(async()=>{await f(e),a(e)},sf),onSubmit:(e,t)=>void v(()=>s(e,t),cf)})},Tie=({email:e,onBack:t,...n})=>(0,z.jsx)(hg,{title:B(`checkEmail`),description:B(`signUpCodeDescription`),explanation:(0,z.jsx)(z.Fragment,{children:gg(B(`signUpCodeSent`),(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),submitLabel:B(`continue`),onChangeAddress:t,changeAddressLabel:B(`useAnotherAddress`),...n}),Eie=({email:e,onSubmit:t,onBack:n,methods:r,busy:i,error:a})=>{let[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(``),u=(0,L.useId)(),d=r.includes(`password`),f=r.includes(`emailCode`);return(0,z.jsxs)(pg,{title:B(`detailsTitle`),description:B(`detailsDescription`),children:[(0,z.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:gg(B(`codeWasRight`),(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({name:o.trim(),...d&&c&&{password:c}})},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`yourName`),(0,z.jsx)(Wd,{name:`name`,autoComplete:`name`,required:!0,autoFocus:!0,maxLength:200,value:o,onChange:e=>s(e.target.value),className:`min-h-6`})]}),d&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(f?`passwordOptional`:`password`),(0,z.jsx)(Wd,{type:`password`,name:`password`,autoComplete:`new-password`,"aria-describedby":u,required:!f,minLength:12,maxLength:128,value:c,onChange:e=>l(e.target.value),className:`min-h-6`})]}),(0,z.jsxs)(`p`,{id:u,className:`text-xs text-muted-foreground`,children:[B(`atLeast`,12),f&&B(`withoutPassword`)]})]}),a&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:B(`createAccount`)}),(0,z.jsx)(V,{variant:`ghost`,onClick:n,className:`min-h-10`,children:B(`useAnotherAddress`)})]})]})},Die=({onSubmit:e,onSignIn:t,onBrowse:n,busy:r,error:i,workspace:a})=>{let[o,s]=(0,L.useState)(``);return(0,z.jsxs)(pg,{title:B(`createAnAccount`),description:a,children:[(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(o.trim())},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`email`),(0,z.jsx)(Wd,{type:`email`,name:`email`,autoComplete:`email`,required:!0,autoFocus:!0,value:o,invalid:!!i,onChange:e=>s(e.target.value),className:`min-h-6`})]}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`codeToConfirm`)}),i&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,z.jsxs)(V,{variant:`primary`,type:`submit`,loading:r,className:`min-h-10`,children:[(0,z.jsx)(Ma,{className:`size-4`}),B(`emailCode`)]}),(0,z.jsxs)(`p`,{className:`text-center text-muted-foreground`,children:[B(`haveAccount`),` `,(0,z.jsx)(`button`,{type:`button`,onClick:t,className:`font-medium text-primary-text hover:underline`,children:B(`signIn`)})]})]}),n&&(0,z.jsx)(`button`,{type:`button`,onClick:n,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:B(`browseWithoutAccount`)})]})},Oie=({workspace:e,email:t,ticket:n,onCodeSent:r,onVerified:i,onBack:a,onSignIn:o,onBrowse:s})=>{let{signInMethods:c,sendSignUpCode:l,verifySignUpCode:u,signUp:d}=xf(),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(),[g,_]=(0,L.useState)(),v=async e=>{p(!0),h(void 0),_(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;h(sf(e))}p(!1)};return t===void 0?(0,z.jsx)(Die,{workspace:e,busy:f,error:m,onSignIn:o,onBrowse:s,onSubmit:e=>void v(async()=>{await l(e),r(e)})}):n===void 0?(0,z.jsx)(Tie,{email:t,busy:f,error:m,notice:g,onBack:a,onSubmit:e=>void v(async()=>i(await u(t,e))),onResend:()=>void v(async()=>{await l(t),_(B(`newCodeSent`))})}):(0,z.jsx)(Eie,{email:t,methods:c,busy:f,error:m,onBack:a,onSubmit:e=>void v(()=>d({ticket:n,...e}))})},vg=`staff-sign-in`,yg=`staff-error`,kie=e=>{let t=new URL(e).searchParams,n=t.get(yg);if(!t.has(`staff-sign-in`)&&!n)return;let r=t.has(vg);return{email:r&&t.get(`email`)||``,reason:r&&t.get(`reason`)||``,...n&&{error:n}}},bg=e=>{let t=new URL(e);if(t.searchParams.has(`staff-sign-in`))for(let e of[vg,`email`,`reason`])t.searchParams.delete(e);return t.searchParams.delete(yg),`${t.pathname}${t.search}${t.hash}`},Aie=10,jie=({operator:e,email:t=``,reason:n=``,onSubmit:r,onBack:i,busy:a,error:o})=>{let[s,c]=(0,L.useState)(t),[l,u]=(0,L.useState)(n);return e?(0,z.jsx)(pg,{title:B(`signInAsPerson`),description:B(`forStaffOf`,e),children:(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),r(s.trim(),l.trim())},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`theirEmail`),(0,z.jsx)(Wd,{type:`email`,name:`email`,required:!0,autoFocus:!t,value:s,onChange:e=>c(e.target.value),className:`min-h-6`})]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`reason`),(0,z.jsx)(`textarea`,{name:`reason`,required:!0,minLength:Aie,rows:3,value:l,placeholder:B(`reasonExample`),onChange:e=>u(e.target.value),className:g(`resize-y rounded-md border bg-background px-2.5 py-1.5 font-normal shadow-sm outline-none placeholder:text-faint-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`,o?`border-danger`:`border-border-strong`)})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:B(`staffExplanation`,e)}),o&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:o}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:a,className:`min-h-10`,children:B(`continueWith`,e)}),(0,z.jsx)(V,{variant:`ghost`,onClick:i,className:`min-h-10`,children:B(`backToSignIn`)})]})}):(0,z.jsxs)(pg,{title:B(`staffTitle`),description:B(`staffUnavailable`),children:[o&&(0,z.jsx)(`p`,{role:`alert`,className:`mb-4 text-body font-medium text-danger-text`,children:o}),(0,z.jsx)(V,{variant:`primary`,className:`min-h-10 w-full`,onClick:i,children:B(`backToSignIn`)})]})},Mie=({link:e,onBack:t})=>{let{session:n,staffSignIn:r}=xf(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(e.error&&uf(e.error)),c=async(e,t)=>{a(!0),s(void 0);try{let r=`${window.location.origin}${bg(window.location.href)}`;window.location.assign(await n.staff.start({email:e,reason:t,callbackURL:r}))}catch(e){if(!(e instanceof Oc))throw e;s(uf(e)),a(!1)}};return(0,z.jsx)(jie,{operator:r,email:e.email,reason:e.reason,busy:i,error:o,onBack:t,onSubmit:(e,t)=>void c(e,t)})},xg=({checked:e,indeterminate:t,onChange:n,label:r,disabled:i,className:a})=>(0,z.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t?`mixed`:e,"aria-label":r,disabled:i,onClick:()=>n?.(!e),className:g(`relative inline-flex size-4 shrink-0 items-center justify-center rounded border transition-colors after:absolute after:-inset-1 after:content-[""] pointer-coarse:after:-inset-3.5`,e||t?`border-primary bg-primary text-primary-foreground`:`border-border-strong bg-background hover:border-faint-foreground`,a),children:t?(0,z.jsx)(Ba,{className:`size-3`,strokeWidth:3}):e&&(0,z.jsx)(xi,{className:`size-3`,strokeWidth:3})}),Nie={totp:`totpInstruction`,otp:`otpInstruction`,backup:`backupInstruction`},Pie=({methods:e,onVerify:t,onSendCode:n,onBack:r,busy:i,error:a,codeSent:o,initialStep:s})=>{let[c,l]=(0,L.useState)(s??(e.includes(`totp`)?`totp`:`otp`)),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(!1),m=c===`otp`&&!o,h=e=>{l(e),d(``),e===`otp`&&!o&&n()};return(0,z.jsxs)(pg,{title:B(`twoFactorTitle`),description:B(`twoFactorDescription`),children:[m?(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`codeToFinish`)}),a&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,z.jsx)(V,{variant:`primary`,loading:i,onClick:n,className:`min-h-10`,children:B(`emailCode`)})]}):(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({method:c,code:u.trim(),trustDevice:f})},children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(Nie[c])}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(c===`backup`?`backupCode`:`code`),c===`backup`?(0,z.jsx)(Wd,{name:`code`,autoComplete:`off`,spellCheck:!1,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:e=>d(e.target.value),className:`min-h-6 font-mono`}):(0,z.jsx)(Mp,{name:`code`,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:d})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(xg,{checked:f,onChange:p,label:B(`trustBrowser`)}),B(`trustBrowserFor`)]}),a&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:B(`verify`)})]}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col items-center gap-2 border-t pt-4`,children:[c!==`totp`&&e.includes(`totp`)&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>h(`totp`),className:`font-medium text-primary-text hover:underline`,children:B(`useAuthenticator`)}),c!==`otp`&&e.includes(`otp`)&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>h(`otp`),className:`font-medium text-primary-text hover:underline`,children:B(`emailCodeInstead`)}),c!==`backup`&&e.includes(`totp`)&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>h(`backup`),className:`font-medium text-primary-text hover:underline`,children:B(`useBackupCode`)}),(0,z.jsx)(`button`,{type:`button`,onClick:r,className:`font-medium text-muted-foreground hover:underline`,children:B(`backToSignIn`)})]})]})},Fie=({methods:e,onBack:t})=>{let{verifyTwoFactor:n,session:r}=xf(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(),[c,l]=(0,L.useState)(!1),u=async e=>{a(!0),s(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;s(sf(e))}a(!1)};return(0,z.jsx)(Pie,{methods:e,busy:i,error:o,codeSent:c,onBack:t,onVerify:e=>void u(()=>n(e)),onSendCode:()=>void u(async()=>{await r.sendTwoFactorCode(),l(!0)})})},Iie=e=>{let t=new URL(e),n=t.searchParams.get(`token`);return t.pathname.endsWith(`/-/invitation`)&&n?{token:n}:void 0},Lie=e=>`${new URL(e).pathname.slice(0,-13)}/`,K=a({en:{organizations:`Organizations`,organization:`Organization`,members:`Members`,invitations:`Invitations`,owner:`Owner`,admin:`Admin`,member:`Member`,loading:`Loading`,name:`Name`,slug:`Slug`,save:`Save`,cancel:`Cancel`,delete:`Delete`,remove:`Remove`,create:`Create`,current:`Current`,open:`Open`,allOrganizations:`All organizations`,allOrganizationsDescription:`Every organization in the app. Your global roles let you work in any of them, with what those roles allow there. Opening one you are not a member of is written to the audit log.`,findOrganization:`Find an organization`,nameOrSlug:`Name or slug`,cannotChangeRole:`You cannot give or take away this role`,makeAccountToJoin:e=>`Make your account for ${e} to join.`,makeAccount:e=>`Make your account for ${e}.`,yourName:`Your name`,password:`Password`,passwordOptional:e=>`Password (optional, ${e}+ characters)`,passwordRequired:e=>`Password (${e}+ characters)`,createAndJoin:`Create account and join`,createYourAccount:`Create your account`,invalidLink:`This invitation link is not valid`,invitation:`Invitation`,goToApp:`Go to the app`,invitesToApp:(e,t)=>`${e} invites you to join ${t}.`,invitesTo:(e,t,n)=>`${e} invites you to ${t} as ${n}.`,invitesToWith:(e,t,n,r)=>`${e} invites you to ${t} as ${n}, with ${r}.`,join:e=>`Join ${e}`,hasAccount:e=>`${e} has an account already: sign in with it.`,signOut:`Sign out`,signInAs:e=>`Sign in as ${e}`,signInAsToJoin:e=>`Sign in as ${e} to join`,otherAddress:(e,t)=>`This invitation is for ${e}, and you are signed in as ${t}.`,signOutToAccept:`Sign out to accept it`,inviteSomeone:`Invite someone`,inviteDescription:`They get an email with a link to join, or to make an account first. You can give the app roles you hold, and those your roles grant.`,organizationRole:`Organization role`,peopleInvited:e=>`People invited to ${e}.`,notAcceptedYet:`Not accepted yet`,sendingAgain:`Sending again gives a new link, which replaces the earlier one.`,nobodyWaiting:`Nobody is waiting.`,roleOf:e=>`Organization role of ${e}`,couldNotReadMembers:`Could not read the members`,whoWorks:e=>`Who works in ${e}, and with which roles.`,membersDescription:`Owners and admins manage the organization; app roles decide what each member sees and does in the app.`,details:`Details`,detailsEditable:`The name people see, and the slug that names it in links.`,detailsReadOnly:`Owners and admins can change these.`,handOver:`Hand over`,handOverDescription:`Make another member the owner. You stay as an admin.`,newOwner:`New owner`,chooseMember:`Choose a member`,deleteOrganization:`Delete organization`,deleteDescription:`Takes the organization and its members and invitations away. Its records must be deleted first.`,deleteTitle:e=>`Delete ${e}?`,deleteConfirm:`Type its name to confirm. This cannot be undone.`,organizationName:`Organization name`,leave:`Leave`,leaveOwner:`An organization keeps an owner: hand it over before you leave, unless it has another owner.`,leaveMember:`You stop being a member, and lose your roles here.`,leaveName:e=>`Leave ${e}`,noOrganization:`You do not work in an organization now. Choose one under Organizations.`,youAre:e=>`You are ${e} here.`,throughGlobalRoles:`You work here through your global roles, without being a member.`,newOrganization:`New organization`,newOrganizationDescription:`You become its owner, with every role, and work in it once it is made.`,invitationsForYou:`Invitations for you`,invitationsForYouDescription:`Open the link in the invitation email to accept one.`,anOrganization:`An organization`,noAppRoles:`no app roles`,until:e=>`Until ${e}`,organizationsSubtitle:`You work in one organization at a time; what you see follows from your roles there.`,yourOrganizations:`Your organizations`,memberOf:`The organizations you are a member of.`,notMember:`You are not a member of an organization yet.`,couldNotReadOrganizations:`Could not read your organizations`},nl:{organizations:`Organisaties`,organization:`Organisatie`,members:`Leden`,invitations:`Uitnodigingen`,owner:`Eigenaar`,admin:`Beheerder`,member:`Lid`,loading:`Laden`,name:`Naam`,slug:`Slug`,save:`Bewaren`,cancel:`Annuleren`,delete:`Verwijderen`,remove:`Verwijderen`,create:`Maken`,current:`Huidige`,open:`Openen`,allOrganizations:`Alle organisaties`,allOrganizationsDescription:`Elke organisatie in de app. Met je globale rollen kun je in elk ervan werken, met wat die rollen daar toestaan. Wie er een opent waar die geen lid van is, komt in het auditlogboek.`,findOrganization:`Een organisatie zoeken`,nameOrSlug:`Naam of slug`,cannotChangeRole:`Je kunt deze rol niet geven of afnemen`,makeAccountToJoin:e=>`Maak je account voor ${e} om lid te worden.`,makeAccount:e=>`Maak je account voor ${e}.`,yourName:`Je naam`,password:`Wachtwoord`,passwordOptional:e=>`Wachtwoord (optioneel, ${e}+ tekens)`,passwordRequired:e=>`Wachtwoord (${e}+ tekens)`,createAndJoin:`Account maken en lid worden`,createYourAccount:`Je account maken`,invalidLink:`Deze uitnodigingslink is niet geldig`,invitation:`Uitnodiging`,goToApp:`Naar de app`,invitesToApp:(e,t)=>`${e} nodigt je uit voor ${t}.`,invitesTo:(e,t,n)=>`${e} nodigt je uit voor ${t} als ${n}.`,invitesToWith:(e,t,n,r)=>`${e} nodigt je uit voor ${t} als ${n}, met ${r}.`,join:e=>`Lid worden van ${e}`,hasAccount:e=>`${e} heeft al een account: log daarmee in.`,signOut:`Uitloggen`,signInAs:e=>`Inloggen als ${e}`,signInAsToJoin:e=>`Inloggen als ${e} om lid te worden`,otherAddress:(e,t)=>`Deze uitnodiging is voor ${e}, en je bent ingelogd als ${t}.`,signOutToAccept:`Uitloggen om die te accepteren`,inviteSomeone:`Iemand uitnodigen`,inviteDescription:`Die krijgt een e-mail met een link om lid te worden, of om eerst een account te maken. Je kunt de app-rollen geven die je zelf hebt, en die je rollen toekennen.`,organizationRole:`Rol in de organisatie`,peopleInvited:e=>`Mensen uitgenodigd voor ${e}.`,notAcceptedYet:`Nog niet geaccepteerd`,sendingAgain:`Opnieuw sturen geeft een nieuwe link, die de vorige vervangt.`,nobodyWaiting:`Er wacht niemand.`,roleOf:e=>`Rol in de organisatie van ${e}`,couldNotReadMembers:`Kon de leden niet lezen`,whoWorks:e=>`Wie in ${e} werkt, en met welke rollen.`,membersDescription:`Eigenaren en beheerders beheren de organisatie; app-rollen bepalen wat elk lid in de app ziet en doet.`,details:`Gegevens`,detailsEditable:`De naam die mensen zien, en de slug die haar in links noemt.`,detailsReadOnly:`Eigenaren en beheerders kunnen dit wijzigen.`,handOver:`Overdragen`,handOverDescription:`Maak een ander lid eigenaar. Jij blijft beheerder.`,newOwner:`Nieuwe eigenaar`,chooseMember:`Kies een lid`,deleteOrganization:`Organisatie verwijderen`,deleteDescription:`Verwijdert de organisatie met haar leden en uitnodigingen. Haar records moeten eerst worden verwijderd.`,deleteTitle:e=>`${e} verwijderen?`,deleteConfirm:`Typ de naam om te bevestigen. Dit kan niet ongedaan worden gemaakt.`,organizationName:`Naam van de organisatie`,leave:`Verlaten`,leaveOwner:`Een organisatie houdt een eigenaar: draag die rol over voordat je vertrekt, tenzij er nog een eigenaar is.`,leaveMember:`Je bent dan geen lid meer, en verliest je rollen hier.`,leaveName:e=>`${e} verlaten`,noOrganization:`Je werkt nu niet in een organisatie. Kies er een onder Organisaties.`,youAre:e=>`Je bent hier ${e}.`,throughGlobalRoles:`Je werkt hier via je globale rollen, zonder lid te zijn.`,newOrganization:`Nieuwe organisatie`,newOrganizationDescription:`Je wordt de eigenaar, met elke rol, en werkt erin zodra die is gemaakt.`,invitationsForYou:`Uitnodigingen voor jou`,invitationsForYouDescription:`Open de link in de uitnodigingsmail om er een te accepteren.`,anOrganization:`Een organisatie`,noAppRoles:`geen app-rollen`,until:e=>`Tot ${e}`,organizationsSubtitle:`Je werkt in één organisatie tegelijk; wat je ziet volgt uit je rollen daar.`,yourOrganizations:`Je organisaties`,memberOf:`De organisaties waar je lid van bent.`,notMember:`Je bent nog geen lid van een organisatie.`,couldNotReadOrganizations:`Kon je organisaties niet lezen`}}),Sg=`/-/organizations`,Cg=`/-/organization`,wg=`/-/organization/members`,Tg=`/-/organization/invitations`,Rie={[Sg]:`organizations`,[Cg]:`organization`,[wg]:`members`,[Tg]:`invitations`},zie=e=>{let t=Rie[e];return t&&K(t)},Eg=e=>K(e),Dg=(e,t)=>e.find(e=>e.name===t)?.label??t,Og=e=>e?.role===`owner`||e?.role===`admin`,Bie=(e,t,n)=>{let r=(n,r,i,a)=>({id:n,label:r,icon:i,href:`${e}${a}`,active:t===a});return[r(`organizations`,K(`organizations`),Ga,Sg),...n?.organization?[r(`organization`,K(`organization`),mi,Cg)]:[],...Og(n)?[r(`members`,K(`members`),ts,wg),r(`invitations`,K(`invitations`),Ma,Tg)]:[]]},kg=(e,t)=>{let n=[...t?.globalRoles??[],...t?.appRoles??[]],r=e.filter(e=>e.membership).map(e=>e.name);if(n.includes(`admin`))return new Set(r);let i=n.flatMap(t=>e.find(e=>e.name===t)?.grants??[]);return new Set([...n,...i].filter(e=>r.includes(e)))},Ag=()=>{let[e,t]=(0,L.useState)(!1),[n,r]=(0,L.useState)();return{busy:e,error:n,run:async e=>{t(!0),r(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;r(sf(e))}t(!1)},setError:r}},jg=({token:e,preview:t,joins:n,onDone:r})=>{let{session:i,signInMethods:a,recheck:o}=xf(),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(``),{busy:d,error:f,run:p}=Ag(),m=a.includes(`password`),h=a.includes(`emailCode`),g=()=>p(async()=>{await i.organizations.signUpFromInvitation(e,{name:s.trim(),...m&&l&&{password:l}}),r(),o()});return(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:K(n?`makeAccountToJoin`:`makeAccount`,t.email)}),f&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,z.jsx)(Wd,{"aria-label":K(`yourName`),placeholder:K(`yourName`),autoComplete:`name`,value:s,onChange:e=>c(e.target.value)}),m&&(0,z.jsx)(Wd,{"aria-label":K(`password`),type:`password`,autoComplete:`new-password`,placeholder:K(h?`passwordOptional`:`passwordRequired`,12),value:l,onChange:e=>u(e.target.value)}),(0,z.jsx)(V,{type:`submit`,variant:`primary`,loading:d,disabled:!s.trim()||m&&!h&&l.length<12,children:K(n?`createAndJoin`:`createYourAccount`)})]})},Vie=({token:e,onDone:t,signIn:n})=>{let{session:r,state:i,signOut:a,organizations:o}=xf(),[s,c]=(0,L.useState)(),[l,u]=(0,L.useState)(),{busy:d,error:f,run:p}=Ag();if((0,L.useEffect)(()=>{r.organizations.invitation(e).then(c,e=>u(e instanceof Oc?sf(e):K(`invalidLink`)))},[r,e]),l)return(0,z.jsx)(pg,{title:K(`invitation`),description:l,children:(0,z.jsx)(V,{className:`w-full`,onClick:t,children:K(`goToApp`)})});if(!s)return(0,z.jsx)(pg,{title:K(`invitation`),children:(0,z.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,K(`loading`)]})});let m=i.kind===`signed-in`?i.user:void 0,h=m?.email.toLowerCase()===s.email.toLowerCase();if(!s.organization){let r=s.app?.name??``,i=K(`invitesToApp`,s.inviter.name,r);return(0,z.jsx)(pg,{title:K(`join`,r),description:i,children:s.hasAccount?m&&h?(0,z.jsx)(V,{variant:`primary`,className:`w-full`,onClick:t,children:K(`goToApp`)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:K(`hasAccount`,s.email)}),m?(0,z.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:K(`signOut`)}):(0,z.jsx)(Qu,{to:n,className:g(gp({variant:`primary`}),`w-full`),children:K(`signInAs`,s.email)})]}):m?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:K(`otherAddress`,s.email,m.email)}),(0,z.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:K(`signOutToAccept`)})]}):(0,z.jsx)(jg,{token:e,preview:s,joins:!1,onDone:t})})}let _=s.organization,v=s.appRoles.map(e=>Dg(o?.roles??[],e)),y=Eg(s.role).toLowerCase(),b=v.length>0?K(`invitesToWith`,s.inviter.name,_.name,y,v.join(`, `)):K(`invitesTo`,s.inviter.name,_.name,y);return m&&!h?(0,z.jsxs)(pg,{title:K(`join`,_.name),description:b,children:[(0,z.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:K(`otherAddress`,s.email,m.email)}),(0,z.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:K(`signOutToAccept`)})]}):(0,z.jsx)(pg,{title:K(`join`,_.name),description:b,children:m?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,z.jsx)(V,{variant:`primary`,className:`w-full`,loading:d,onClick:()=>void p(async()=>{await r.organizations.accept(e),t()}),children:K(`join`,_.name)})]}):s.hasAccount?(0,z.jsx)(Qu,{to:n,className:g(gp({variant:`primary`}),`w-full`),children:K(`signInAsToJoin`,s.email)}):(0,z.jsx)(jg,{token:e,preview:s,joins:!0,onDone:t})})},Mg,Ng,Hie=({dsn:e,environment:t})=>(Mg??=m(()=>import(`./prod-YZ9ZMG1O.js`).then(n=>{n.init({dsn:e,...t&&{environment:t},integrations:e=>e.filter(e=>e.name!==`BrowserSession`),beforeSend:e=>Cr(e)}),Ng=(e,t)=>n.captureException(e,t?{contexts:{react:{componentStack:t}}}:void 0)}),[]),Mg),Pg=(e,t)=>Ng?.(e,t??void 0),Fg=({children:e})=>(0,z.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-dashed border-warning bg-warning-soft p-3 text-warning-text`,children:e}),Ig=a({en:{notFound:`Not found`,noPage:`There is no page called {}.`,cancel:`Cancel`,couldNotDraw:`{} could not be drawn.`,noComponent:`No component is registered as {}. Export it from protobase.ui.tsx, or load the plugin that provides it.`,unknownBlock:`{} is not a block this version of the app knows.`,somethingWrong:`Something went wrong`,needsRecord:`Needs a record`,cannotChange:`You cannot change this record`,cannotDelete:`You cannot delete this record`,doesNotApply:`Does not apply to this record`,noHandler:e=>`The app has no handler for "${e}"`,noInputComponent:(e,t)=>`The app has no component "${e}" for input "${t}"`,done:e=>`${e}: done`,doneOn:(e,t,n,r)=>[`${e}: done on ${t}`,...n>0?[`skipped ${n} it does not apply to`]:[],...r>0?[`failed on ${r}`]:[]].join(`, `),failed:e=>`${e} failed`,noAction:e=>`No action "${e}"`,couldNotLoad:`Could not load`,nothingYet:`Nothing here yet.`,saved:e=>`${e}: saved`,create:`Create`,save:`Save`,notSaved:`Not saved`,couldNotCount:`Could not count`,required:`Required`,wholeNumber:`A whole number`,number:`A number`,dateFormat:`A date as YYYY-MM-DD`,atMost:e=>`At most ${e} characters`},nl:{notFound:`Niet gevonden`,noPage:`Er is geen pagina met de naam {}.`,cancel:`Annuleren`,couldNotDraw:`{} kon niet worden getekend.`,noComponent:`Er is geen component geregistreerd als {}. Exporteer die uit protobase.ui.tsx, of laad de plug-in die haar levert.`,unknownBlock:`{} is geen blok dat deze versie van de app kent.`,somethingWrong:`Er ging iets mis`,needsRecord:`Vraagt een record`,cannotChange:`Je kunt dit record niet wijzigen`,cannotDelete:`Je kunt dit record niet verwijderen`,doesNotApply:`Geldt niet voor dit record`,noHandler:e=>`De app heeft geen handler voor "${e}"`,noInputComponent:(e,t)=>`De app heeft geen component "${e}" voor invoer "${t}"`,done:e=>`${e}: klaar`,doneOn:(e,t,n,r)=>[`${e}: klaar voor ${t}`,...n>0?[`${n} overgeslagen waarvoor het niet geldt`]:[],...r>0?[`mislukt voor ${r}`]:[]].join(`, `),failed:e=>`${e} mislukt`,noAction:e=>`Geen actie "${e}"`,couldNotLoad:`Kon niet laden`,nothingYet:`Hier staat nog niets.`,saved:e=>`${e}: bewaard`,create:`Maken`,save:`Bewaren`,notSaved:`Niet bewaard`,couldNotCount:`Kon niet tellen`,required:`Verplicht`,wholeNumber:`Een geheel getal`,number:`Een getal`,dateFormat:`Een datum als JJJJ-MM-DD`,atMost:e=>`Hoogstens ${e} tekens`}}),Lg=class extends L.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){Pg(e,t.componentStack)}render(){return this.state.failed?this.props.fallback===void 0?(0,z.jsx)(Fg,{children:gg(Ig(`couldNotDraw`),this.props.name)}):this.props.fallback:this.props.children}},Uie=/^[A-Z][A-Za-z0-9]*$/,Wie=e=>typeof e==`function`||typeof e==`object`&&!!e&&`$$typeof`in e,Rg=e=>{let t=e.default??{},n=Object.entries(e).filter(e=>e[0]!=="default"&&Uie.test(e[0])&&Wie(e[1]));if(n.length===0)return t;for(let[e,r]of n)if(t.components&&Object.hasOwn(t.components,e)&&t.components[e]!==r)throw Error(`The component "${e}" is exported by name and given in components as another one; keep the export`);return{...t,components:{...t.components,...Object.fromEntries(n)}}},zg=class extends Error{name=`UiConflictError`},Gie=e=>Object.keys(e).some(e=>e==="default"||/^[A-Z]/.test(e))?Rg(e):e,Bg=(e,t)=>[...(e.extends??[]).map(Gie).flatMap((e,n)=>Bg(e,e.name??`${t} extends[${n}]`)),{ui:e,label:t}],Vg=(e,t,n)=>{let r={},i=new Map;for(let{ui:a,label:o}of t)for(let[t,s]of Object.entries(n(a)??{})){if(Object.hasOwn(r,t)&&r[t]!==s)throw new zg(`${e} "${t}" is defined twice, by ${i.get(t)} and by ${o}; rename one of them`);r[t]=s,i.set(t,i.get(t)??o)}return r},Hg=e=>e.length<=1?e[0]:()=>e.map((e,t)=>(0,z.jsx)(e,{},t)),Kie=e=>e.length<=1?e[0]:({children:t,...n})=>e.reduceRight((e,t)=>(0,z.jsx)(t,{...n,children:e}),t),Ug=(...e)=>{let t=e.flatMap((e,t)=>Bg(e,e.name??`UI config ${t+1}`)),n=Vg(`The component`,t,e=>e.components),r=Vg(`The action handler`,t,e=>e.actions),i=Vg(`The field type`,t,e=>e.fields),a=Vg(`The drop rule`,t,e=>e.dropRules),o=Vg(`The board drop`,t,e=>e.boardDrops),s=Hg(t.flatMap(({ui:e})=>e.shell?.actions?[e.shell.actions]:[])),c=Hg(t.flatMap(({ui:e})=>e.shell?.rightPanel?[e.shell.rightPanel]:[])),l=t.findLast(({ui:e})=>e.shell?.logo)?.ui.shell?.logo,u=Kie(t.flatMap(({ui:e})=>e.beforeSignIn?[e.beforeSignIn]:[])),d=e.at(-1)?.name;return{...d&&{name:d},components:n,actions:r,...Object.keys(i).length>0&&{fields:i},...Object.keys(a).length>0&&{dropRules:a},...Object.keys(o).length>0&&{boardDrops:o},...(s||c||l)&&{shell:{...s&&{actions:s},...c&&{rightPanel:c},...l&&{logo:l}}},...u&&{beforeSignIn:u}}},Wg=(e,t)=>{let n=Ug(e??{}),r=[],i=[];for(let e of t){if(e.kind===`off`){i.push(e);continue}try{Ug(...r,e.ui,n),r.push(e.ui)}catch(t){if(!(t instanceof zg))throw t;i.push({kind:`off`,url:e.plugin.url,name:e.plugin.name,reason:t.message})}}return{ui:r.length===0?n:Ug(...r,n),off:i}},Gg=a({en:{loading:`Loading`,pluginsOff:`Plugins off`,pluginOff:`The plugin {} is off: {}.`,dismiss:`Dismiss`,answered:e=>`its plugin.json answered ${e}`,couldNotLoad:e=>`it could not be loaded: ${e}`,notObject:`its plugin.json is not an object`,noName:`its plugin.json names no plugin`,noApi:`its plugin.json names no plugin API`,noVersions:`its plugin.json names no Protobase versions`,noModule:`its plugin.json names no module`,badStylesheet:`its plugin.json names a stylesheet that is no URL`,badVersion:`its plugin.json has a version that is no text`},nl:{loading:`Laden`,pluginsOff:`Plug-ins uit`,pluginOff:`De plug-in {} staat uit: {}.`,dismiss:`Sluiten`,answered:e=>`de plugin.json antwoordde ${e}`,couldNotLoad:e=>`hij kon niet worden geladen: ${e}`,notObject:`de plugin.json is geen object`,noName:`de plugin.json noemt geen plug-in`,noApi:`de plugin.json noemt geen plug-in-API`,noVersions:`de plugin.json noemt geen Protobase-versies`,noModule:`de plugin.json noemt geen module`,badStylesheet:`de plugin.json noemt een stylesheet die geen URL is`,badVersion:`de plugin.json heeft een versie die geen tekst is`}}),Kg=e=>typeof e==`string`&&e.trim()!==``,qie=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return{problem:Gg(`notObject`)};let{name:t,version:n,api:r,protobase:i,entry:a,css:o}=e;return Kg(t)?Number.isInteger(r)?Kg(i)?Kg(a)?o!==void 0&&!Kg(o)?{problem:Gg(`badStylesheet`)}:n!==void 0&&!Kg(n)?{problem:Gg(`badVersion`)}:{manifest:{name:t,api:r,protobase:i,entry:a,...n!==void 0&&{version:n},...o!==void 0&&{css:o}}}:{problem:Gg(`noModule`)}:{problem:Gg(`noVersions`)}:{problem:Gg(`noApi`)}:{problem:Gg(`noName`)}},qg=(0,L.createContext)(null),Jie=qg.Provider,Yie=()=>{let e=(0,L.useContext)(qg);if(!e)throw Error(`usePlugin is for the components of a plugin the app loaded`);return e},Jg=(e,t,n)=>{let r=n=>(0,z.jsx)(Jie,{value:e,children:(0,z.jsx)(t,{...n})});return r.displayName=`${e.name}:${n}`,r},Xie=(e,t,n)=>({of:n.of,display:Jg(e,n.display,`fields.${t}.display`),...n.editor&&{editor:Jg(e,n.editor,`fields.${t}.editor`)},...n.cell&&{cell:Jg(e,n.cell,`fields.${t}.cell`)}}),Zie=(e,t)=>{let n=Ug({...Rg(t),name:e.name}),r=Object.fromEntries(Object.entries(n.components??{}).map(([t,n])=>[t,Jg(e,n,t)])),i=n.fields&&Object.fromEntries(Object.entries(n.fields).map(([t,n])=>[t,Xie(e,t,n)])),a=n.shell&&{...n.shell.actions&&{actions:Jg(e,n.shell.actions,`shell.actions`)},...n.shell.rightPanel&&{rightPanel:Jg(e,n.shell.rightPanel,`shell.rightPanel`)},...n.shell.logo&&{logo:Jg(e,n.shell.logo,`shell.logo`)}},o=n.beforeSignIn&&Jg(e,n.beforeSignIn,`beforeSignIn`);return{name:e.name,components:r,...n.actions&&{actions:n.actions},...n.dropRules&&{dropRules:n.dropRules},...n.boardDrops&&{boardDrops:n.boardDrops},...i&&{fields:i},...a&&{shell:a},...o&&{beforeSignIn:o}}},Yg={name:`@protobase/ui`,version:`0.37.2`,description:`The Protobase admin app and the React hooks and components for custom UI.`,license:`Apache-2.0`,repository:{type:`git`,url:`git+https://github.com/PrototeamHQ/protobase.git`,directory:`packages/ui`},homepage:`https://docs.protobase.net`,type:`module`,protobase:{pluginApi:1},sideEffects:[`*.css`,`./dist/app/main.js`],engines:{node:`>=22.12.0`},exports:{".":`./src/index.ts`,"./theme.css":`./src/theme.css`,"./styles.css":`./src/styles.css`},types:`./src/index.ts`,files:[`dist`],scripts:{build:`tsdown && protobase build-shell dist/shell --source-maps dist/shell-source-maps`,prepack:`tsdown && protobase build-shell dist/shell --source-maps dist/shell-source-maps`},publishConfig:{access:`public`,exports:{".":`./dist/index.js`,"./theme.css":`./dist/theme.css`,"./styles.css":`./dist/styles.css`},types:`./dist/index.d.ts`},dependencies:{"@dnd-kit/core":`^6.3.1`,"@dnd-kit/sortable":`^10.0.0`,"@protobase/client":`workspace:*`,"@protobase/layout":`workspace:*`,"@protobase/schema":`workspace:*`,"@sentry/browser":`^11.7.0`,"@tanstack/react-query":`^5.104.1`,"@tanstack/react-table":`^9.2.6`,"altcha-lib":`^2.6.0`,dompurify:`^3.4.17`,fflate:`^0.8.3`,"lucide-react":`^1.52.0`,"maplibre-gl":`^6.14.0`,marked:`^18.1.1`,pmtiles:`^4.5.0`,react:`^19.3.0`,"react-dom":`^19.3.0`,"react-map-gl":`^8.1.3`,recharts:`^3.10.1`,tailwindcss:`^4.3.3`,thumbhash:`^0.1.1`,uqr:`^0.1.3`}},Xg=Yg.protobase.pluginApi,Zg=Yg.version,Qie={readJson:async e=>{let t=await fetch(e,{cache:`no-cache`,credentials:`same-origin`});return t.ok?{json:await t.json()}:{status:t.status}},addStylesheet:e=>{if([...document.querySelectorAll(`link[rel="stylesheet"]`)].some(t=>t.href===e))return;let t=document.createElement(`link`);t.rel=`stylesheet`,t.href=e,document.head.append(t)},importModule:e=>m(()=>import(e),[])},$ie={api:Xg,version:Zg},eae=e=>e instanceof Error?e.message:String(e),tae=async(e,t,n,r=$ie)=>{let i=new URL(e.url,n).href,a=(e,t)=>({kind:`off`,url:i,...t&&{name:t},reason:e}),o;try{let n=await t.readJson(i);if(`status`in n)return a(Gg(`answered`,n.status));let s=qie(n.json);if(`problem`in s)return a(s.problem);let{manifest:c}=s;o=c.name;let l=mr(c,r);if(l)return a(l,o);c.css&&t.addStylesheet(new URL(c.css,i).href);let u=await t.importModule(new URL(c.entry,i).href),d={name:o,...c.version&&{version:c.version},url:i,settings:e.settings??{}};return{kind:`loaded`,plugin:d,ui:Zie(d,u)}}catch(e){return a(Gg(`couldNotLoad`,eae(e)),o)}},nae=e=>{let t=new Map;return{load:n=>{let r=JSON.stringify(n),i=t.get(r);if(i)return i;let a=tae(n,e,window.location.href);return t.set(r,a),a}}},Qg=(0,L.createContext)(null),rae=({loader:e=Qie,children:t})=>{let n=(0,L.useMemo)(()=>nae(e),[e]);return(0,z.jsx)(Qg.Provider,{value:n,children:t})},$g=()=>{let e=(0,L.useContext)(Qg);if(!e)throw Error(`usePluginSource must be used inside PluginSourceProvider`);return e},e_=1e4,t_=[],n_=(e,t)=>{let n=JSON.stringify(e),[r,i]=(0,L.useState)({key:`[]`,loads:t_,settled:!0});return(0,L.useEffect)(()=>{if(e.length===0)return;let r=!0,a=!1,o=e.map(()=>void 0),s=()=>{if(!r)return;let t=o.filter(e=>e!==void 0);i({key:n,loads:t,settled:a||t.length===e.length})},c=setTimeout(()=>{a=!0,s()},e_);return e.forEach((e,n)=>{t.load(e).then(e=>{o[n]=e,s()})}),()=>{r=!1,clearTimeout(c)}},[n,t]),e.length===0?{loads:t_,settled:!0}:r.key===n?r:{loads:t_,settled:!1}},iae=({children:e})=>{let{state:t,beforeSignIn:n,adoptSession:r}=xf(),{path:i,params:a,navigate:o}=Pm(),{loads:s,settled:c}=n_(n,$g()),l=(0,L.useMemo)(()=>Wg(void 0,s).ui.beforeSignIn,[s]),u=(0,L.useCallback)(e=>{let t=new URLSearchParams(a);for(let n of e)t.delete(n);o(t.size>0?`${i}?${t}`:i,{replace:!0})},[i,a,o]);return t.kind!==`signed-out`&&t.kind!==`visitor`?e:c?l?(0,z.jsx)(Lg,{name:`beforeSignIn`,fallback:e,children:(0,z.jsx)(l,{signedIn:r,params:a,removeParams:u,children:e})}):e:(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,Gg(`loading`)]})},aae=()=>{let e=window.location.href,t=lie(e);if(t)return{kind:`reset-password`,token:t.token};let n=kie(e);if(n)return{kind:`staff-sign-in`,link:n};let r=Iie(e);if(r)return{kind:`invitation`,token:r.token};let i=hf(e);if(i)return{kind:`provider-sign-in`,provider:i};let a=gf(e);return a?{kind:`sign-in`,providerError:a}:{kind:`sign-in`}},r_=({to:e})=>{let{navigate:t}=Pm();return(0,L.useEffect)(()=>t(e,{replace:!0}),[t,e]),null},i_=({workspace:e,children:t})=>{let n=a_(e,t);return(0,z.jsx)(iae,{children:n})},a_=(e,t)=>{let{state:n,recheck:r,passwordReset:i,signOut:a,signInProviders:o,canSignUp:s,browse:c}=xf(),{path:l,params:u,basePath:d,navigate:f}=Pm(),{address:p,next:m,open:h,link:g,leave:_}=Vm(),[v,y]=(0,L.useState)(aae),[b,x]=(0,L.useState)(),[S,C]=(0,L.useState)(),[w,T]=(0,L.useState)(),E=new URL(`${d}${l}${u.size>0?`?${u}`:``}`,window.location.origin).href,D=(0,L.useCallback)(e=>{let t=e(E).slice(d.length);f(t.startsWith(`/`)?t:`/${t}`,{replace:!0})},[E,d,f]),O=n.kind===`signed-in`||n.kind===`two-factor`||n.kind===`setup-required`;(0,L.useEffect)(()=>{O&&(v.kind===`provider-sign-in`&&D(_f),(v.kind===`provider-sign-in`||v.kind===`sign-in`&&(v.notice||v.error||v.providerError))&&y({kind:`sign-in`}),x(void 0),C(void 0),T(void 0))},[O,v,D]);let k=p!==void 0&&gf(E)!==void 0;(0,L.useEffect)(()=>{!O&&v.kind===`sign-in`&&v.providerError&&k&&D(_f)},[O,v,k,D]);let A=(0,L.useCallback)(e=>y({kind:`sign-in`,error:e}),[]),j=e=>{D(uie),y(e)},M=async()=>{n.kind===`signed-in`&&await a(),j({kind:`sign-in`,notice:B(`passwordChanged`)})},N=()=>{y({kind:`sign-in`}),a().then(()=>h(`sign-in`,{replace:!0}))};switch(n.kind){case`loading`:return(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,B(`loading`)]});case`error`:return(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`cannotReach`,n.message)}),(0,z.jsx)(V,{onClick:r,children:B(`tryAgain`)})]});case`needs-admin`:return(0,z.jsx)(oie,{onCheckAgain:r})}if(n.kind===`signed-in`&&p)return(0,z.jsx)(r_,{to:m??`/`});if(v.kind===`reset-password`)return(0,z.jsx)(gie,{token:v.token,onDone:()=>void M(),onRequestNewLink:i?()=>{y({kind:`sign-in`}),f(Fs({step:`forgot-password`}),{replace:!0})}:void 0,onBack:()=>j({kind:`sign-in`})});if(v.kind===`staff-sign-in`)return(0,z.jsx)(Mie,{link:v.link,onBack:()=>{D(bg),y({kind:`sign-in`})}});let P=n.kind===`signed-out`||n.kind===`visitor`;if(v.kind===`invitation`&&(n.kind===`signed-in`||P&&!p))return(0,z.jsx)(Vie,{token:v.token,onDone:()=>{D(Lie),y({kind:`sign-in`})},signIn:g()});if(n.kind===`signed-in`)return t;if(n.kind===`two-factor`)return(0,z.jsx)(Fie,{methods:n.methods,onBack:N});if(n.kind===`setup-required`)return(0,z.jsx)(yie,{missing:n.missing},n.missing.join());if(v.kind===`provider-sign-in`)return(0,z.jsx)(pie,{provider:v.provider,workspace:e,onFailed:A});let ee=v.kind===`sign-in`?v:{kind:`sign-in`};if(!p){let e=ee.notice||ee.error||ee.providerError;return n.kind===`visitor`&&!e?t:(0,z.jsx)(r_,{to:Fs({next:m})})}let te={"sign-in":!0,"forgot-password":i,"email-code":b!==void 0,"sign-up":s,"sign-up-code":s&&S!==void 0,"sign-up-details":s&&w!==void 0}[p.step]?p.step:`sign-in`,ne=e=>()=>h(e,{replace:!0}),re=c&&(()=>{c(),_()});if(te===`forgot-password`)return(0,z.jsx)(die,{back:g(`sign-in`,{replace:!0})});if(te===`email-code`)return(0,z.jsx)(iie,{email:b,onBack:ne(`sign-in`)});if(te===`sign-up`||te===`sign-up-code`||te===`sign-up-details`)return(0,z.jsx)(Oie,{workspace:e,email:te===`sign-up`?void 0:S,ticket:te===`sign-up-details`?w:void 0,onCodeSent:e=>{C(e),T(void 0),h(`sign-up-code`)},onVerified:e=>{T(e),h(`sign-up-details`,{replace:!0})},onBack:ne(`sign-up`),onSignIn:()=>h(`sign-in`),onBrowse:re},te);let ie=ee.providerError&&ff(ee.providerError,o.length===1?o[0].name:`the provider`),ae=ee.error??ie;return(0,z.jsx)(wie,{workspace:e,notice:ee.notice,error:ae,forgotPassword:i?g(`forgot-password`):void 0,onCodeSent:e=>{x(e),h(`email-code`)},signUp:s?g(`sign-up`):void 0,onBrowse:re},ae)},o_=e=>[...e].reduce((e,t)=>(e*31+t.charCodeAt(0))%360,7),s_=e=>e.split(/[\s@.]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join(``),c_=e=>(e.role??`user`).split(`,`).map(e=>e.trim()),l_=e=>c_(e).includes(`admin`),u_=e=>{let t=c_(e),n=t.includes(`admin`);return{name:e.name||e.email,email:e.email,initials:s_(e.name||e.email)||`?`,hue:o_(e.id||e.email),role:n?B(`admin`):(t[0]??`user`).replace(/^./,e=>e.toUpperCase()),roleTone:n?`violet`:`blue`}},oae=3e4,sae=(e,t=Date.now())=>Math.max(1e3,xu(e)-t-oae),d_=()=>{let{state:e,session:t}=xf(),n=e.kind===`signed-in`,[r,i]=(0,L.useState)();return(0,L.useEffect)(()=>{if(!n)return;let e=!0,r,a=async n=>{let o=await t.token(),s=o!==void 0&&o===n?await t.token({refresh:!0}):o;e&&(i(s),s&&(r=setTimeout(()=>void a(s),sae(s))))};return a(),()=>{e=!1,clearTimeout(r)}},[t,n]),n?r:void 0},cae=({children:e})=>(0,z.jsx)(ag,{locale:xf().locale,children:e}),lae=(e,t)=>{let n=new Set,r,i=()=>{r=void 0;let i=new Set(n);n.clear();let a=e=>i.has(e[1]);e.invalidateQueries({predicate:e=>a(e.queryKey)&&e.queryKey[0]!==`record`}),e.invalidateQueries({predicate:e=>a(e.queryKey)&&e.queryKey[0]===`record`,refetchType:t()?`none`:`active`})};return{changed:e=>{for(let t of e)n.add(t);n.size>0&&!r&&(r=setTimeout(i,300))},stop:()=>clearTimeout(r)}},uae=e=>{let t=W(),n=Km(),r=(0,L.useContext)(Yh),i=(0,L.useMemo)(()=>Object.values(e.resources).filter(t=>t.live&&!ig(e,t.name)).map(e=>e.name).sort().join(`,`),[e]);(0,L.useEffect)(()=>{if(!i)return;let e=lae(n,()=>r?.paused()??!1),a=t.live({onChanges:t=>e.changed(t.map(e=>e.resource)),onResync:()=>e.changed(i.split(`,`))});return()=>{a(),e.stop()}},[t,n,r,i])},f_=(e,t,n=!0)=>{let r=W(),i=sr(t);return Kh({queryKey:U.record(e,i),enabled:n,queryFn:()=>r.get(e,t)})},p_=(e,t,n=!0)=>{let r=W(),i=Km(),a=sr(t);return Kh({queryKey:U.record(e,a),enabled:n,queryFn:()=>r.get(e,t),placeholderData:()=>i.getQueryData(U.recordPreview(e,a))})},m_=e=>e.charAt(0).toUpperCase()+e.slice(1),q=e=>m_(e.replace(/(Id|Code|_id|_code)$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/_+/g,` `).trim().toLowerCase()||e);function h_(){var e=[...arguments];return(0,L.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var g_=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function __(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function v_(e){return`nodeType`in e}function y_(e){return e?__(e)?e:v_(e)?e.ownerDocument?.defaultView??window:window:window}function b_(e){let{Document:t}=y_(e);return e instanceof t}function x_(e){return!__(e)&&e instanceof y_(e).HTMLElement}function S_(e){return e instanceof y_(e).SVGElement}function C_(e){return e?__(e)?e.document:v_(e)?b_(e)?e:x_(e)||S_(e)?e.ownerDocument:document:document:document}var w_=g_?L.useLayoutEffect:L.useEffect;function T_(e){let t=(0,L.useRef)(e);return w_(()=>{t.current=e}),(0,L.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function dae(){let e=(0,L.useRef)(null);return[(0,L.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,L.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function E_(e,t){t===void 0&&(t=[e]);let n=(0,L.useRef)(e);return w_(()=>{n.current!==e&&(n.current=e)},t),n}function D_(e,t){let n=(0,L.useRef)();return(0,L.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function O_(e){let t=T_(e),n=(0,L.useRef)(null);return[n,(0,L.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function k_(e){let t=(0,L.useRef)();return(0,L.useEffect)(()=>{t.current=e},[e]),t.current}var A_={};function j_(e,t){return(0,L.useMemo)(()=>{if(t)return t;let n=A_[e]==null?0:A_[e]+1;return A_[e]=n,e+`-`+n},[e,t])}function M_(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var N_=M_(1),P_=M_(-1);function F_(e){return`clientX`in e&&`clientY`in e}function I_(e){if(!e)return!1;let{KeyboardEvent:t}=y_(e.target);return t&&e instanceof t}function L_(e){if(!e)return!1;let{TouchEvent:t}=y_(e.target);return t&&e instanceof t}function R_(e){if(L_(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return F_(e)?{x:e.clientX,y:e.clientY}:null}var z_=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[z_.Translate.toString(e),z_.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),B_=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function V_(e){return e.matches(B_)?e:e.querySelector(B_)}var H_={display:`none`};function U_(e){let{id:t,value:n}=e;return L.createElement(`div`,{id:t,style:H_},n)}function W_(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return L.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function G_(){let[e,t]=(0,L.useState)(``);return{announce:(0,L.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var K_=(0,L.createContext)(null);function q_(e){let t=(0,L.useContext)(K_);(0,L.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function J_(){let[e]=(0,L.useState)(()=>new Set),t=(0,L.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,L.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Y_={draggable:`
|
|
7
|
+
`)}\n`;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,z.jsx)(`ul`,{"aria-label":R(`backupCodes`),className:`grid grid-cols-2 gap-x-4 gap-y-1 rounded-md border bg-surface p-3 font-mono`,children:e.map(e=>(0,z.jsx)(`li`,{children:e},e))}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(V,{size:`sm`,onClick:()=>{navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},children:[t?(0,z.jsx)(xi,{className:`size-3.5 text-success`}):(0,z.jsx)(Li,{className:`size-3.5`}),R(t?`copied`:`copy`)]}),(0,z.jsxs)(V,{size:`sm`,onClick:()=>Ep(r,`backup-codes.txt`),children:[(0,z.jsx)(Ui,{className:`size-3.5`}),R(`download`)]})]})]})},Op=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:o})=>{let[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(),p=async()=>{u(!0),f(void 0);try{await a(i?s:void 0)}catch(e){if(!(e instanceof Oc))throw e;f(sf(e)),u(!1)}};return(0,z.jsxs)(_p,{title:e,description:t,onClose:o,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:o,children:R(`cancel`)}),(0,z.jsx)(V,{variant:r?`danger`:`primary`,loading:l,disabled:i&&!s,onClick:()=>void p(),children:n})]}),children:[i&&(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[R(`yourPassword`),(0,z.jsx)(Wd,{type:`password`,autoComplete:`current-password`,autoFocus:!0,value:s,invalid:!!d,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&s&&void p()})]}),d&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:d})]})},kp=(e,t)=>e.replace(/\D/g,``).slice(0,t),Ap=(e,t,n)=>{let r=kp(t??``,n);return r.length===n?r:kp(e,n)},jp=(e,t,n,r)=>{let i=t.replace(/\D/g,``);return i.length>=r?i.slice(0,r):kp(e.slice(0,n)+i+e.slice(n+i.length),r)},Mp=({value:e,onChange:t,onComplete:n,length:r=6,invalid:i,disabled:a,className:o,ref:s,onFocus:c,onBlur:l,onSelect:u,onKeyDown:d,onClick:f,onPaste:p,...m})=>{let h=(0,L.useRef)(null),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(e.length),x=e.slice(0,r),S=Math.min(y,r-1),C=e=>{h.current=e,typeof s==`function`?s(e):s&&(s.current=e)},w=e=>{e!==x&&(t(e),e.length===r&&n?.(e))},T=e=>{let t=h.current;if(!t)return;let n=Math.max(0,Math.min(e,x.length));t.setSelectionRange(n,n<x.length?n+1:n),b(n)},E=e=>{if(d?.(e),e.defaultPrevented||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey)return;let t=e.currentTarget.selectionStart??x.length,n={ArrowLeft:t-1,ArrowRight:t+1,Home:0,End:x.length}[e.key];n!==void 0&&(e.preventDefault(),T(n))},D=e=>{f?.(e);let t=e.currentTarget.getBoundingClientRect();e.clientX<=t.left||e.clientX>=t.right||T(Math.floor((e.clientX-t.left)/t.width*r))};return(0,z.jsxs)(`div`,{className:g(`relative`,a&&`opacity-50`,o),children:[(0,z.jsx)(`div`,{"aria-hidden":!0,className:`flex justify-center gap-2`,children:Array.from({length:r},(e,t)=>{let n=_&&t===S;return(0,z.jsx)(`div`,{"data-slot":t,"data-digit":x[t],className:g(`flex h-12 min-w-0 max-w-12 flex-1 items-center justify-center rounded-md border bg-background font-mono text-xl font-semibold text-foreground shadow-sm transition-colors before:content-[attr(data-digit)]`,i?`border-danger`:n?`border-primary`:`border-border-strong`,n&&(i?`ring-2 ring-danger/20`:`ring-2 ring-primary/20`)),children:x[t]===void 0&&(n?(0,z.jsx)(`span`,{className:`h-6 w-px animate-pulse bg-foreground`}):(0,z.jsx)(`span`,{className:`size-1.5 rounded-full bg-border-strong`}))},t)})}),(0,z.jsx)(`input`,{ref:C,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,pattern:`[0-9]{${r}}`,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,"aria-invalid":i||void 0,disabled:a,value:x,className:`absolute inset-0 size-full cursor-text bg-transparent text-transparent caret-transparent outline-none selection:bg-transparent disabled:cursor-not-allowed`,...m,onChange:e=>{let{data:t,dataTransfer:n}=e.nativeEvent;w(Ap(e.target.value,t??n?.getData(`text/plain`),r))},onPaste:e=>{if(p?.(e),e.defaultPrevented)return;e.preventDefault();let t=e.currentTarget,n=jp(x,e.clipboardData.getData(`text`),t.selectionStart??x.length,r);w(n),b(n.length)},onSelect:e=>{u?.(e);let t=e.currentTarget,n=t.selectionStart??x.length;n===t.selectionEnd&&n<t.value.length&&t.setSelectionRange(n,n+1),b(n)},onKeyDown:E,onClick:D,onFocus:e=>{v(!0),c?.(e)},onBlur:e=>{v(!1),l?.(e)}})]})},Np=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(Np||{}),Pp=[0,1],Fp=[1,0],Ip=[2,3],Lp=[3,2],Rp={L:Pp,M:Fp,Q:Ip,H:Lp},zp=/^\d*$/,Bp=/^[A-Z0-9 $%*+./:-]*$/,Vp=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,Hp=1,Up=40,Wp=3,Gp=3,Kp=40,qp=10,Jp=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Yp=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],Xp=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<Hp||e>Up)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,Np.Timing),this.setFunctionModule(e,6,e%2==0,Np.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,Qp(r,e));this.setFunctionModule(8,7,Qp(r,6)),this.setFunctionModule(8,8,Qp(r,7)),this.setFunctionModule(7,8,Qp(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,Qp(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,Qp(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,Qp(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=Qp(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,Np.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,Np.Alignment)}setFunctionModule(e,t,n,r=Np.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==pm(t,n))throw RangeError(`Invalid argument`);let r=Yp[n[0]][t],i=Jp[n[0]][t],a=Math.floor(fm(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=mm(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=hm(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(fm(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=Qp(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=Wp:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Kp),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Kp}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=Wp:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Kp),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Kp}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=Gp)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*qp,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Zp(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function Qp(e,t){return!!(e>>>t&1)}var $p=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},em=[1,10,12,14],tm=[2,9,11,13],nm=[4,8,16,16];function rm(e,t){return e[Math.floor((t+7)/17)+1]}function im(e){let t=[];for(let n of e)Zp(n,8,t);return new $p(nm,e.length,t)}function am(e){if(!cm(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);Zp(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new $p(em,e.length,t)}function om(e){if(!lm(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Vp.indexOf(e.charAt(n))*45;r+=Vp.indexOf(e.charAt(n+1)),Zp(r,11,t)}return n<e.length&&Zp(Vp.indexOf(e.charAt(n)),6,t),new $p(tm,e.length,t)}function sm(e){return e===``?[]:cm(e)?[am(e)]:lm(e)?[om(e)]:[im(dm(e))]}function cm(e){return zp.test(e)}function lm(e){return Bp.test(e)}function um(e,t){let n=0;for(let r of e){let e=rm(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function dm(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function fm(e){if(e<Hp||e>Up)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function pm(e,t){return Math.floor(fm(e)/8)-Jp[t[0]][e]*Yp[t[0]][e]}function mm(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=gm(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=gm(n,2)}return t}function hm(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=gm(t,e))}return n}function gm(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function _m(e,t,n=1,r=40,i=-1,a=!0){if(!(Hp<=n&&n<=r&&r<=Up)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=pm(o,t)*8,i=um(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Fp,Ip,Lp])a&&s<=pm(o,e)*8&&(t=e);let c=[];for(let t of e){Zp(t.mode[0],4,c),Zp(t.numChars,rm(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=pm(o,t)*8;Zp(0,Math.min(4,l-c.length),c),Zp(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Zp(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new Xp(o,t,u,i)}function vm(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?sm(e):Array.isArray(e)?[im(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=_m(c,Rp[n],i,a,o,r),u=ym({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function ym(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=Np.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}var bm=({uri:e,className:t})=>{let{size:n,path:r}=(0,L.useMemo)(()=>{let t=vm(e,{ecc:`M`,border:2}),n=t.data.flatMap((e,t)=>e.flatMap((e,n)=>e?[`M${n} ${t}h1v1h-1z`]:[]));return{size:t.size,path:n.join(``)}},[e]);return(0,z.jsxs)(`svg`,{viewBox:`0 0 ${n} ${n}`,role:`img`,"aria-label":R(`qrCode`),shapeRendering:`crispEdges`,className:t,children:[(0,z.jsx)(`rect`,{width:n,height:n,fill:`#fff`}),(0,z.jsx)(`path`,{d:r,fill:`#000`})]})},xm=e=>(new URL(e).searchParams.get(`secret`)??``).replace(/(.{4})(?=.)/g,`$1 `),Sm=()=>[{value:`app`,label:R(`authenticatorApp`),description:R(`authenticatorAppDescription`)},{value:`email`,label:R(`emailedCode`),description:R(`emailedCodeDescription`)}],Cm=({offerEmailedCodes:e,needsPassword:t,onStartApp:n,onConfirmApp:r,onEmailedCodes:i,onDone:a,onCancel:o})=>{let[s,c]=(0,L.useState)({kind:`choose`}),[l,u]=(0,L.useState)(`app`),[d,f]=(0,L.useState)(``),[p,m]=(0,L.useState)(``),[h,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(),b=e?Sm():Sm().filter(e=>e.value===`app`),x=async e=>{_(!0),y(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;y(sf(e))}_(!1)},S=()=>x(async()=>{let e=t?d:void 0;if(l===`email`)return await i(e),a();c({kind:`scan`,setup:await n(e)})}),C=(e,t=p)=>x(async()=>{await r(t),c({kind:`backup-codes`,codes:e.backupCodes})}),w=v&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:v});return s.kind===`backup-codes`?(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:R(`twoFactorIsOn`)}),(0,z.jsx)(Dp,{codes:s.codes}),(0,z.jsx)(V,{variant:`primary`,onClick:a,className:`min-h-10`,children:R(`savedCodes`)})]}):s.kind===`scan`?(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),C(s.setup)},children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:R(`scanCode`)}),(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,z.jsx)(bm,{uri:s.setup.totpURI,className:`size-44 rounded-md border`}),(0,z.jsxs)(`p`,{className:`text-center text-xs text-muted-foreground`,children:[R(`cannotScan`),(0,z.jsx)(`span`,{className:`mt-1 block break-all font-mono text-body text-foreground`,children:xm(s.setup.totpURI)})]})]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[R(`codeFromApp`),(0,z.jsx)(Mp,{name:`code`,required:!0,autoFocus:!0,value:p,invalid:!!v,onChange:m,onComplete:e=>!h&&void C(s.setup,e)})]}),w,(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:R(`turnOn`)}),o&&(0,z.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:R(`cancel`)})]}):(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,z.jsx)(`div`,{role:`radiogroup`,"aria-label":R(`secondStep`),className:`flex flex-col gap-2`,children:b.map(e=>(0,z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e.value,onClick:()=>u(e.value),className:g(`rounded-md border p-3 text-left transition-colors`,l===e.value?`border-primary bg-primary-soft`:`border-border-strong hover:bg-muted`),children:[(0,z.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,z.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted-foreground`,children:e.description})]},e.value))}),t&&(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[R(`yourPassword`),(0,z.jsx)(Wd,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:d,invalid:!!v,onChange:e=>f(e.target.value),className:`min-h-6`})]}),w,(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:R(`continue`)}),o&&(0,z.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:R(`cancel`)})]})},wm={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},Tm=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,L.useState)(),d=()=>u(void 0),f=n?(0,z.jsx)(_d,{tone:`green`,children:R(`on`)}):t===`required`?(0,z.jsx)(_d,{tone:`amber`,children:R(`required`)}):(0,z.jsx)(_d,{children:R(`off`)}),p=R(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:wm[t]);return l?.kind===`setup`?(0,z.jsx)(vp,{title:R(`twoFactor`),status:f,description:p,children:(0,z.jsx)(`div`,{className:`max-w-sm`,children:(0,z.jsx)(Cm,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,z.jsxs)(vp,{title:R(`twoFactor`),status:f,description:p,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,z.jsx)(V,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:R(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,z.jsx)(V,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:R(`addAuthenticator`)}),n&&r&&(0,z.jsx)(V,{onClick:()=>u({kind:`new-codes`}),children:R(`newBackupCodes`)}),n&&(0,z.jsx)(V,{variant:`danger`,disabled:t===`required`,title:t===`required`?R(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:R(`turnOff`)})]}),l?.kind===`turn-off`&&(0,z.jsx)(Op,{title:R(`turnOffTitle`),description:R(`turnOffDescription`),confirmLabel:R(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,z.jsx)(Op,{title:R(`newCodesTitle`),description:R(`newCodesDescription`),confirmLabel:R(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,z.jsx)(_p,{title:R(`yourNewCodes`),description:R(`keepCodesSafe`),onClose:d,actions:(0,z.jsx)(V,{variant:`primary`,onClick:d,children:R(`savedCodes`)}),children:(0,z.jsx)(Dp,{codes:l.codes})})]})},Em=()=>{let e=gf(window.location.href);return e&&window.history.replaceState(window.history.state,``,_f(window.location.href)),e},Dm=({email:e})=>{let{session:t,signInProviders:n,socialProviders:r,linkProvider:i,mcp:a}=xf(),o=n.filter(e=>r.includes(e.id)),{account:s}=t,[c,l]=(0,L.useState)(),[u,d]=(0,L.useState)(),[f]=(0,L.useState)(Em),p=(0,L.useCallback)(()=>{Promise.all([s.signInMethods(),s.passkeys(),s.linkedProviders(),a?s.connectedApps():[]]).then(([e,t,n,r])=>l({methods:e,passkeys:t,linked:n,apps:r}),e=>d(e instanceof Oc?sf(e):R(`couldNotReadMethods`)))},[s,a]);(0,L.useEffect)(p,[p]);let m=e=>e.then(e=>(p(),e));return(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,z.jsx)(ef,{title:R(`signInSecurity`),subtitle:e}),c?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(wp,{rule:c.methods.policy.passkey,passkeys:c.passkeys,onAdd:()=>m(s.addPasskey()),onRename:(e,t)=>m(s.renamePasskey(e,t)),onRemove:e=>m(s.removePasskey(e))}),(0,z.jsx)(Tm,{rule:c.methods.policy.twoFactor,enabled:c.methods.account.twoFactor,authenticatorApp:c.methods.account.authenticatorApp,mail:c.methods.mail,needsPassword:c.methods.account.password,onStartApp:e=>s.startAuthenticatorApp(e),onConfirmApp:e=>s.confirmAuthenticatorApp(e),onEmailedCodes:e=>s.turnOnEmailedCodes(e),onTurnOff:e=>s.turnOffTwoFactor(e),onNewBackupCodes:e=>s.newBackupCodes(e),onChanged:p}),o.length>0&&(0,z.jsx)(Tp,{providers:o,linked:c.linked,onConnect:i,error:f&&ff(f,o.length===1?o[0].name:R(`theProvider`))}),a&&(0,z.jsx)(Sp,{apps:c.apps,onDisconnect:e=>m(s.disconnectApp(e))})]}):u?(0,z.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:u}):(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,R(`loading`)]})]})},Om={wallet:gte,"file-text":ta,send:xo,ruler:ho,bed:$r,bath:Zr,house:ca,"door-open":Jee,"land-plot":ite,leaf:ya,tag:pte,key:fa,calendar:gi,heart:oa,bell:ti,bookmark:li,"external-link":Yi,ban:Yr,play:lte,stop:ute,power:io,restart:po,terminal:mte,camera:Ree,"hard-drive":tte,server:Co,network:Ga,archive:Fr,copy:Li,"arrow-right-left":zr,download:Ui,upload:Qo,cpu:qee,memory:Ia,plug:eo,wrench:_te},km=e=>e!==void 0&&Object.hasOwn(Om,e)?Om[e]:void 0,Am=(e,t)=>t>=60&&t>Math.abs(e),jm=({title:e,open:t,onClose:n,children:r})=>{let i=(0,L.useRef)(null),a=(0,L.useRef)(void 0);return Hu(i,t,n),t?(0,z.jsxs)(`div`,{className:`fixed inset-0 z-[80]`,children:[(0,z.jsx)(`div`,{className:`absolute inset-0 bg-backdrop/40`,onClick:n,"aria-hidden":!0}),(0,z.jsxs)(`div`,{ref:i,role:`dialog`,"aria-modal":`true`,"aria-label":e,tabIndex:-1,className:`absolute inset-x-0 bottom-0 flex max-h-[85vh] flex-col rounded-t-xl border-t bg-background shadow-pop outline-none`,children:[(0,z.jsxs)(`header`,{className:`relative flex shrink-0 touch-none items-center justify-between border-b px-4`,onPointerDown:e=>{e.pointerType===`touch`&&(a.current={x:e.clientX,y:e.clientY})},onPointerUp:e=>{if(!a.current)return;let t=Am(e.clientX-a.current.x,e.clientY-a.current.y);a.current=void 0,t&&n()},onPointerCancel:()=>a.current=void 0,children:[(0,z.jsx)(`span`,{className:`absolute left-1/2 top-1.5 h-1 w-9 -translate-x-1/2 rounded-full bg-border-strong`,"aria-hidden":!0}),(0,z.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:e}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Kd(`close`),onClick:n,className:`-mr-2 inline-flex size-11 items-center justify-center rounded-md text-muted-foreground hover:bg-muted`,children:(0,z.jsx)(ss,{className:`size-5`})})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-6`,children:r})]})]}):null},Mm=({title:e,description:t,open:n,onClose:r,actions:i,children:a,wide:o})=>{let s=Mu();return n?s?(0,z.jsx)(_p,{title:e,description:t,onClose:r,actions:i,wide:o,children:a}):(0,z.jsx)(jm,{title:e,open:!0,onClose:r,children:(0,z.jsxs)(`div`,{className:`pt-3`,children:[t&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:t}),a&&(0,z.jsx)(`div`,{className:`mt-4`,children:a}),(0,z.jsx)(`div`,{className:`mt-5 flex flex-col-reverse gap-2 [&>*]:min-h-11`,children:i})]})}):null},H=a({en:{notFound:`Not found`,noResource:e=>`There is no resource called ${e}.`,somethingWentWrong:`Something went wrong`,signInSecurity:`Sign-in & security`,signInPolicy:`Sign-in policy`,adminsOnly:`Admins only`,onlyAdminPolicy:`Only an admin can change how people sign in.`,ownersOnly:`Owners and admins only`,onlyOwners:`Only the organization's owners and admins manage its members.`,chooseResource:`Choose a resource`,pickFromSidebar:`Pick one from the sidebar.`,nothingHere:`There is nothing at this address.`,noPage:`There is no page called {}.`,assistant:`Assistant`,operationFailed:(e,t,n)=>`Operation ${e} (${t}) failed: ${n} Nothing was saved.`,nothingSaved:e=>`${e} Nothing was saved.`,admin:`Admin`,new:`New`,loadingRecord:`Loading record`,noComponent:`No component is registered as {}. Export it from protobase.ui.tsx, or load the plugin that provides it.`,choose:`Choose...`,fileMissing:`The file is missing from storage`,chooseFileFor:e=>`Choose a file for ${e}`,notUploaded:`Not uploaded`,uploadingLabel:e=>`Uploading ${e}`,uploading:e=>`Uploading… ${e}%`,replace:`Replace`,remove:`Remove`,dropFile:`Drop a file here or`,chooseFile:`Choose a file`,average:e=>`Average ${e.toLowerCase()}`,pages:`Pages`,account:`Account`,sales:`Sales`,crm:`CRM`,catalog:`Catalog`,inventory:`Inventory`,hr:`HR`,cannotReach:e=>`Cannot reach ${e}`,searchPlural:e=>`Search ${e}`,couldNotLoadOptions:`Could not load the options`,noMatches:`No matches`,loading:`Loading`,leaveTitle:`Leave without saving?`,leaveDescription:`You have unsaved changes on this page. They stay in this browser, and come back when you open the record again.`,stay:`Stay`,leave:`Leave`,show:e=>`Show ${e}`,hide:e=>`Hide ${e}`,couldNotShow:e=>`Could not show the ${e}`,noAnswer:`It did not answer.`,signInRefused:e=>`It did not accept your sign-in: ${e}`,loadingFrom:e=>`Loading from ${e}`,restWorks:`The rest of the app works as before.`,tryAgain:`Try again`,staffSession:`Staff session`,staffSignedIn:`{} is signed in as {} until {}. Reason: {}`,stopStaffSession:`Stop staff session`,open:`Open`,openLabel:e=>`Open ${e}`},nl:{notFound:`Niet gevonden`,noResource:e=>`Er is geen onderdeel met de naam ${e}.`,somethingWentWrong:`Er ging iets mis`,signInSecurity:`Inloggen en beveiliging`,signInPolicy:`Inlogbeleid`,adminsOnly:`Alleen beheerders`,onlyAdminPolicy:`Alleen een beheerder kan wijzigen hoe mensen inloggen.`,ownersOnly:`Alleen eigenaren en beheerders`,onlyOwners:`Alleen de eigenaren en beheerders van de organisatie beheren de leden.`,chooseResource:`Kies een onderdeel`,pickFromSidebar:`Kies er een in de zijbalk.`,nothingHere:`Er is niets op dit adres.`,noPage:`Er is geen pagina met de naam {}.`,assistant:`Assistent`,operationFailed:(e,t,n)=>`Bewerking ${e} (${t}) mislukte: ${n} Er is niets bewaard.`,nothingSaved:e=>`${e} Er is niets bewaard.`,admin:`Beheer`,new:`Nieuw`,loadingRecord:`Record laden`,noComponent:`Er is geen component geregistreerd als {}. Exporteer die uit protobase.ui.tsx, of laad de plug-in die haar levert.`,choose:`Kiezen...`,fileMissing:`Het bestand ontbreekt in de opslag`,chooseFileFor:e=>`Kies een bestand voor ${e}`,notUploaded:`Niet geüpload`,uploadingLabel:e=>`${e} uploaden`,uploading:e=>`Uploaden… ${e}%`,replace:`Vervangen`,remove:`Verwijderen`,dropFile:`Zet hier een bestand neer of`,chooseFile:`Kies een bestand`,average:e=>`${e}, gemiddeld`,pages:`Pagina's`,account:`Account`,sales:`Verkoop`,crm:`CRM`,catalog:`Catalogus`,inventory:`Voorraad`,hr:`HR`,cannotReach:e=>`Kan ${e} niet bereiken`,searchPlural:e=>`${e} zoeken`,couldNotLoadOptions:`Kon de keuzes niet laden`,noMatches:`Niets gevonden`,loading:`Laden`,leaveTitle:`Weggaan zonder te bewaren?`,leaveDescription:`Je hebt niet-bewaarde wijzigingen op deze pagina. Ze blijven in deze browser, en komen terug als je het record weer opent.`,stay:`Blijven`,leave:`Weggaan`,show:e=>`${e} tonen`,hide:e=>`${e} verbergen`,couldNotShow:e=>`Kon ${e} niet tonen`,noAnswer:`Het antwoordde niet.`,signInRefused:e=>`Het accepteerde je inlog niet: ${e}`,loadingFrom:e=>`Laden van ${e}`,restWorks:`De rest van de app werkt zoals eerst.`,tryAgain:`Opnieuw proberen`,staffSession:`Sessie van een medewerker`,staffSignedIn:`{} is ingelogd als {} tot {}. Reden: {}`,stopStaffSession:`Sessie van medewerker stoppen`,open:`Openen`,openLabel:e=>`${e} openen`}}),Nm=(0,L.createContext)(null),Pm=()=>{let e=(0,L.useContext)(Nm);if(!e)throw Error(`useRouter must be used inside Router`);return e},Fm=()=>`${window.location.pathname}${window.location.search}`,Im=e=>new URL(e,`http://local`).pathname,Lm=()=>window.history.state??{},Rm=()=>Lm().protobaseIndex??0,zm=()=>Math.random().toString(36).slice(2),Bm=()=>{let e=Lm();if(e.protobaseEntry)return e.protobaseEntry;let t=zm();return window.history.replaceState({...e,protobaseEntry:t},``),t},Hne=({basePath:e=``,initialUrl:t,children:n})=>{let r=t!==void 0,[i,a]=(0,L.useState)(()=>({url:t??Fm(),entry:r?zm():Bm()})),o=(0,L.useRef)(new Set),s=(0,L.useRef)(i);s.current=i;let c=(0,L.useRef)(r?0:Rm()),l=(0,L.useRef)(!1),u=(0,L.useRef)(!1),d=(0,L.useRef)(void 0),[f,p]=(0,L.useState)();(0,L.useEffect)(()=>{if(r)return;window.history.replaceState({protobaseIndex:c.current,protobaseEntry:s.current.entry},``);let e=()=>{let e=Rm();if(l.current){l.current=!1,c.current=e,d.current!==void 0&&window.history.go(d.current),d.current=void 0;return}let t=e-c.current,n=Im(Fm())!==Im(s.current.url);if(!u.current&&o.current.size>0&&n){l.current=!0,window.history.go(-t),p({kind:`history`,delta:t});return}u.current=!1,c.current=e,a({url:Fm(),entry:Bm()})};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[r]);let m=(0,L.useCallback)((e,t)=>{let n=t?s.current.entry:zm();r||(c.current+=+!t,window.history[t?`replaceState`:`pushState`]({protobaseIndex:c.current,protobaseEntry:n},``,e)),a({url:e,entry:n})},[r]),h=(0,L.useCallback)((t,{replace:n=!1}={})=>{let r=`${e}${t}`;if(Im(r)!==Im(s.current.url)&&o.current.size>0)return p({kind:`link`,full:r,replace:n});m(r,n)},[e,m]),g=(0,L.useCallback)(()=>{let e=Symbol(`guard`);return o.current.add(e),()=>void o.current.delete(e)},[]),_=()=>{if(f){if(p(void 0),f.kind===`link`)return m(f.full,f.replace);u.current=!0,l.current?d.current=f.delta:window.history.go(f.delta)}},v=(0,L.useMemo)(()=>{let t=new URL(i.url,`http://local`);return{path:t.pathname.slice(e.length)||`/`,params:t.searchParams,basePath:e,entry:i.entry,navigate:h,registerGuard:g}},[i,e,h,g]);return(0,z.jsxs)(Nm.Provider,{value:v,children:[n,f&&(0,z.jsx)(_p,{title:H(`leaveTitle`),description:H(`leaveDescription`),onClose:()=>p(void 0),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:()=>p(void 0),children:H(`stay`)}),(0,z.jsx)(V,{variant:`primary`,onClick:_,children:H(`leave`)})]})})]})},Une=({to:e,replace:t,...n})=>{let{navigate:r,basePath:i}=Pm();return(0,z.jsx)(Qu,{to:{href:`${i}${e}`,onFollow:()=>r(e,{replace:t})},...n})},Wne=e=>{let{registerGuard:t}=Pm();(0,L.useEffect)(()=>e?t():void 0,[e,t]),(0,L.useEffect)(()=>{if(!e)return;let t=e=>e.preventDefault();return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e])},Vm=()=>{let{path:e,params:t,basePath:n,navigate:r}=Pm(),i=(0,L.useMemo)(()=>Is(e,t),[e,t]),a=_f(new URL(t.size>0?`${e}?${t}`:e,`http://local`).href),o=i?i.next:a,s=(0,L.useCallback)((e=`sign-in`,t)=>r(Fs({step:e,next:o}),t),[r,o]);return{address:i,next:o,open:s,link:(0,L.useCallback)((e=`sign-in`,t)=>({href:`${n}${Fs({step:e,next:o})}`,onFollow:()=>s(e,t)}),[n,o,s]),leave:(0,L.useCallback)(()=>r(o??`/`,{replace:!0}),[r,o])}},Hm=({benefits:e})=>e&&e.length>0?(0,z.jsx)(`ul`,{className:`flex flex-col gap-2 text-left`,children:e.map(e=>(0,z.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(xi,{className:`mt-0.5 size-4 shrink-0 text-primary`,"aria-hidden":!0}),e]},e))}):null,Um=({prompt:e})=>{let{canSignUp:t}=xf(),{link:n}=Vm(),r=gp({variant:`primary`}),i=e.signUp?(0,z.jsx)(`a`,{href:e.signUp.href,target:`_blank`,rel:`noreferrer`,className:r,children:e.signUp.label}):t&&(0,z.jsx)(Qu,{to:n(`sign-up`),className:r,children:B(`createAnAccount`)});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Qu,{to:n(),className:i?gp():r,children:B(`signIn`)}),i]})},Wm=e=>{let{prompt:t}=e,n=(0,L.useId)();if(e.as===`dialog`)return(0,z.jsx)(Mm,{title:t.title,description:t.description,open:e.open,onClose:e.onClose,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:e.onClose,children:B(`notNow`)}),(0,z.jsx)(Um,{prompt:t})]}),children:(0,z.jsx)(Hm,{benefits:t.benefits})});let r=km(t.icon)??Oa;return(0,z.jsxs)(`section`,{"aria-labelledby":n,className:`mx-auto flex w-full max-w-md flex-col items-center gap-4 px-5 py-10 text-center sm:py-16`,children:[(0,z.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,z.jsx)(r,{className:`size-6`,"aria-hidden":!0})}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`h1`,{id:n,className:`text-lg font-semibold`,children:t.title}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:t.description})]}),(0,z.jsx)(Hm,{benefits:t.benefits}),(0,z.jsx)(`div`,{className:`mt-2 flex w-full flex-col-reverse gap-2 sm:w-auto sm:flex-row sm:justify-center [&>*]:min-h-11 sm:[&>*]:min-h-0`,children:(0,z.jsx)(Um,{prompt:t})})]})},Gm=L.createContext(void 0),Km=e=>{let t=L.useContext(Gm);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Gne=({client:e,children:t})=>(L.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,z.jsx)(Gm.Provider,{value:e,children:t})),Kne={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},qm=new class{#e=Kne;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function qne(e){setTimeout(e,0)}var Jne=typeof window>`u`||`Deno`in globalThis;function Jm(){}function Yne(e,t){return typeof e==`function`?e(t):e}function Ym(e){return typeof e==`number`&&e>=0&&e!==1/0}function Xm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Zm(e,t){return typeof e==`function`?e(t):e}function Qm(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==eh(o,t.options))return!1}else if(!nh(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function $m(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(th(t.options.mutationKey)!==th(a))return!1}else if(!nh(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function eh(e,t){return(t?.queryKeyHashFn||th)(e)}function th(e){return JSON.stringify(e,(e,t)=>oh(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function nh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!nh(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!nh(e[r],t[r]))return!1;return!0}return!1}var Xne=Object.prototype.hasOwnProperty;function rh(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ah(e)&&ah(t);if(!r&&!(oh(e)&&oh(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Xne.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=rh(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function ih(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ah(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function oh(e){if(!sh(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!sh(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function sh(e){return Object.prototype.toString.call(e)===`[object Object]`}function Zne(e){return new Promise(t=>{qm.setTimeout(t,e)})}function ch(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:rh(e,t)}function lh(e){return e}function Qne(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function $ne(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var uh=Symbol();function dh(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===uh?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function fh(e,t){return typeof e==`function`?e(...t):!!e}function ere(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var tre=()=>Jne,ph=()=>tre(),mh=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},hh=new class extends mh{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},nre=qne;function rre(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=nre,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var gh=rre(),_h=new class extends mh{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function ire(e){return Math.min(1e3*2**e,3e4)}function vh(e){return(e??`online`)!==`online`||_h.isOnline()}var yh=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function bh(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(Jm);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new yh(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>hh.isFocused()&&(e.networkMode===`always`||_h.isOnline())&&e.canRun(),p=()=>vh(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(ph()?0:3),a=e.retryDelay??ire,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),Zne(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var xh=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ym(this.gcTime)&&(this.#e=qm.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ph()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(qm.clearTimeout(this.#e),this.#e=void 0)}};function are(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ere(e,()=>t.signal,()=>n=!0)},u=dh(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?$ne:Qne;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Ch:Sh,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Sh(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Sh(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ch(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function ore(e,t){return t?Sh(e,t)!=null:!1}function sre(e,t){return!t||!e.getPreviousPageParam?!1:Ch(e,t)!=null}var cre=class extends xh{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Eh(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Eh(this.options);e.data!==void 0&&(this.setState(Th(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=ch(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Jm).catch(Jm):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Zm(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===uh||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Zm(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Xm(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=dh(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?are(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=bh({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof yh&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof yh){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...wh(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Th(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),gh.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function wh(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:vh(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Th(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Eh(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Dh=class extends mh{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Oh(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return kh(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return kh(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Zm(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!ih(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ah(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||Zm(this.options.enabled,this.#t)!==Zm(t.enabled,this.#t)||Zm(this.options.staleTime,this.#t)!==Zm(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Zm(this.options.enabled,this.#t)!==Zm(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ih(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Jm)),t}#h(e){return!ph()&&Zm(this.options.enabled,this.#t)!==!1&&Ym(e)}#g(){this.#b();let e=Zm(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=Xm(this.#r.dataUpdatedAt,e)+1;this.#u=qm.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return Zm(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=qm.setInterval(()=>{(this.options.refetchIntervalInBackground||hh.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(qm.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(qm.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Oh(e,t),o=i&&Ah(e,n,t,r);(a||o)&&(l={...l,...wh(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=ch(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=ch(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:jh(e,t),refetch:this.refetch,isEnabled:Zm(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),ih(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();gh.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function lre(e,t){return Zm(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Zm(t.retryOnMount,e)!==!1)}function Oh(e,t){return lre(e,t)||e.state.data!==void 0&&kh(e,t,t.refetchOnMount)}function kh(e,t,n){if(Zm(t.enabled,e)!==!1&&Zm(t.staleTime,e)!==`static`){let r=Zm(n,e);return r===`always`||r!==!1&&jh(e,t)}return!1}function Ah(e,t,n,r){return(e!==t||Zm(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&jh(e,n)}function jh(e,t){return Zm(t.enabled,e)!==!1&&e.isStaleByTime(Zm(t.staleTime,e))}var ure=class extends Dh{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ore(t,n.data),hasPreviousPage:sre(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},dre=class extends xh{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Mh(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=bh({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),gh.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Mh(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var fre=class extends mh{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new dre({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Nh(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Nh(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Nh(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Nh(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){gh.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>$m(t,e))}findAll(e={}){return this.getAll().filter(t=>$m(e,t))}notify(e){gh.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return gh.batch(()=>Promise.all(e.map(e=>e.continue().catch(Jm))))}};function Nh(e){return e.options.scope?.id}var pre=class extends mh{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),ih(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&th(t.mutationKey)!==th(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Mh();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){gh.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Ph(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var mre=class extends mh{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,gh.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!ih(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ph(e,n).forEach(e=>{e.destroy()}),Ph(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=rh(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Dh(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&gh.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},hre=class extends mh{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??eh(r,t),a=this.get(i);return a||(a=new cre({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){gh.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Qm(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Qm(e,t)):t}notify(e){gh.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){gh.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){gh.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},gre=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new hre,this.#t=e.mutationCache||new fre,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=hh.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=_h.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Zm(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Yne(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return gh.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;gh.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return gh.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=gh.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Jm).catch(Jm)}invalidateQueries(e,t={}){return gh.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=gh.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Jm)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Jm)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(Zm(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Zm(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Jm).catch(Jm)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Jm).catch(Jm)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return _h.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(th(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{nh(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(th(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{nh(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=eh(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===uh&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Fh=L.createContext(!1),Ih=()=>L.useContext(Fh);Fh.Provider;function _re(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var vre=L.createContext(_re()),Lh=()=>L.useContext(vre),Rh=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?fh(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},zh=e=>{L.useEffect(()=>{e.clearReset()},[e])},Bh=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||fh(n,[e.error,r])),Vh=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Hh=(e,t)=>e?.suspense&&t.isPending,Uh=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Wh({queries:e,...t},n){let r=Km(n),i=Ih(),a=Lh(),o=t.subscribed!==!1,s=L.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:o?`optimistic`:void 0,t}),[e,r,i,o]);s.forEach(e=>{Vh(e);let t=r.getQueryCache().get(e.queryHash);Rh(e,a,t)}),zh(a);let[c]=L.useState(()=>new mre(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;L.useSyncExternalStore(L.useCallback(e=>f?c.subscribe(gh.batchCalls(e)):Jm,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),L.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>Hh(s[t],e))?l.flatMap((e,t)=>{let n=s[t];return n&&Hh(n,e)?Uh(n,new Dh(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=s[t];return n&&Bh({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m)throw m.error;return u(d())}function Gh(e,t,n){let r=Ih(),i=Lh(),a=Km(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Vh(o),Rh(o,i,s),zh(i);let[l]=L.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(L.useSyncExternalStore(L.useCallback(e=>{let t=d?l.subscribe(gh.batchCalls(e)):Jm;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),L.useEffect(()=>{l.setOptions(o)},[o,l]),Hh(o,u))throw Uh(o,l,i);if(Bh({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function Kh(e,t){return Gh(e,Dh,t)}function qh(e,t){let n=Km(t),[r]=L.useState(()=>new pre(n,e));L.useEffect(()=>{r.setOptions(e)},[r,e]);let i=L.useSyncExternalStore(L.useCallback(e=>r.subscribe(gh.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=L.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(Jm)},[r]);if(i.error&&fh(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Jh(e,t){return Gh(e,ure,t)}var yre=()=>{let e=0;return{refetchOnWindowFocus:()=>e>0?!1:`always`,paused:()=>e>0,pause:()=>{e+=1;let t=!1;return()=>{t||(t=!0,--e)}}}},Yh=(0,L.createContext)(null),bre=e=>{let t=(0,L.useContext)(Yh);(0,L.useEffect)(()=>e&&t?t.pause():void 0,[e,t])},xre=e=>{let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),window.addEventListener(`focus`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t),window.removeEventListener(`focus`,t)}},U={meta:[`meta`],sourceMeta:(e,t)=>[`source-meta`,e,t.join(`,`)],sourceMetas:e=>[`source-meta`,e],list:(e,t,n,r,i)=>[`list`,e,t,n,r,i],page:(e,t,n,r,i)=>[`page`,e,t,n,r,i],pages:(e,t,n)=>[`page`,e,t,n],navRecent:(e,t,n,r)=>[`list`,e,t,n,r,`nav-recent`],first:(e,t,n)=>[`first-page`,e,t,n],record:(e,t)=>[`record`,e,t],recordPreview:(e,t)=>[`record-preview`,e,t],history:(e,t,n)=>[`record`,e,t,`history`,n],comments:(e,t)=>[`record`,e,t,`comments`],mentionable:(e,t,n)=>[`record`,e,t,`mentionable`,n],facets:(e,t,n)=>[`facets`,e,t,n],series:(e,t,n,r,i)=>[`series`,e,t,n,r,i],aggregate:(e,t)=>[`aggregate`,e,t],histogram:(e,t,n,r)=>[`histogram`,e,t,n,r],map:(e,t,n,r,i)=>[`map`,e,t,n,r,i],relatedLabel:(e,t)=>[`related-label`,e,t],labels:(e,t)=>[`labels`,e,t],pickedLabels:(e,t)=>[`picked-labels`,e,t],count:(e,t)=>[`count`,e,t],exportCount:(e,t)=>[`list`,e,t,`export-count`],firstRecord:(e,t,n)=>[`first-record`,e,t,n],pathValue:(e,t,n)=>[`path-value`,e,t,n],publicForm:e=>[`public-form`,e]},Xh=(0,L.createContext)(null),Zh=(0,L.createContext)(null),Qh=(0,L.createContext)(null),W=()=>{let e=(0,L.useContext)(Xh);if(!e)throw Error(`useClient must be used inside ApiProvider`);return e},$h=e=>{let t=W();return(0,L.useContext)(Qh)?.(e)??t},Sre=()=>{let e=W(),t=(0,L.useContext)(Qh);return(0,L.useCallback)(n=>t?.(n)??e,[e,t])},Cre=()=>{let e=(0,L.useContext)(Zh);if(!e)throw Error(`useSourceClients must be used inside ApiProvider`);return e},wre=({client:e,resourceClient:t,children:n})=>(0,z.jsx)(Xh.Provider,{value:e,children:(0,z.jsx)(Qh.Provider,{value:t,children:n})}),eg=({baseUrl:e,client:t,sources:n,fetch:r,queryClient:i,token:a,onUnauthenticated:o,children:s})=>{let[c]=(0,L.useState)(yre),[l]=(0,L.useState)(()=>i??new gre({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:c.refetchOnWindowFocus}}}));(0,L.useEffect)(()=>hh.setEventListener(xre),[]);let u=(0,L.useRef)(void 0),d=(0,L.useMemo)(()=>t??fc({baseUrl:e,fetch:r,token:a,onUnauthenticated:o,onMetaVersion:e=>{let t=u.current;u.current=e,t!==void 0&&t!==e&&l.invalidateQueries({queryKey:U.meta},{cancelRefetch:!1})}}),[t,e,r,l,a,o]),f=(0,L.useMemo)(()=>{let e=new Map;return t=>{let i=n?.[t.url]??e.get(t.url);if(i)return i;let o,s=fc({baseUrl:t.url,fetch:r,token:a,onMetaVersion:e=>{let n=o;o=e,n!==void 0&&n!==e&&l.invalidateQueries({queryKey:U.sourceMetas(t.url)},{cancelRefetch:!1})}});return e.set(t.url,s),s}},[n,r,a,l]);return(0,z.jsx)(Gne,{client:l,children:(0,z.jsx)(Xh.Provider,{value:d,children:(0,z.jsx)(Zh.Provider,{value:f,children:(0,z.jsx)(Yh.Provider,{value:c,children:s})})})})},tg=(0,L.createContext)(null),ng={create:!0,update:!0,delete:!0,conditional:[]},rg=()=>{let e=W(),t=Km(),n=(0,L.useContext)(tg),r=Kh({queryKey:U.meta,staleTime:0,refetchOnWindowFocus:`always`,queryFn:async()=>{let n=t.getQueryData(U.meta),r=await e.meta(n?.etag);if(r.status===`unchanged`){if(!n)throw Error(`The server answered 304 to a request without If-None-Match`);return n}return{etag:r.etag,appName:r.meta.appName,...r.meta.appIcon&&{appIcon:r.meta.appIcon},resources:Object.fromEntries(r.meta.resources.map(e=>[e.name,e])),views:Object.fromEntries(r.meta.views.map(e=>[e.resource,e])),pages:Object.fromEntries((r.meta.pages??[]).map(e=>[e.name,e])),permissions:r.meta.permissions??{},...r.meta.userMenu&&{userMenu:r.meta.userMenu},...r.meta.signIn&&{signIn:Object.fromEntries(r.meta.signIn.map(e=>[e.resource,e]))},...r.meta.bottomBar&&{bottomBar:r.meta.bottomBar},...r.meta.assistant&&{assistant:r.meta.assistant},...r.meta.runtime&&{runtime:r.meta.runtime},...r.meta.errorReporting&&{errorReporting:r.meta.errorReporting},...r.meta.maps&&{maps:r.meta.maps},...r.meta.locale&&{locale:r.meta.locale},...r.meta.files&&{files:r.meta.files},...r.meta.plugins&&{plugins:r.meta.plugins},...r.meta.sources&&{sources:r.meta.sources.map(e=>({source:e,state:`loading`}))}}}});return(0,L.useMemo)(()=>n&&r.data?{...r,data:n}:r,[n,r])},Tre=1e4,Ere=e=>e.map(e=>({data:e.data?.meta,error:e.error})),Dre=(e,t)=>{let n=Km(),r=Wh({queries:e.map(e=>{let r=U.sourceMeta(e.url,e.resources);return{queryKey:r,staleTime:0,refetchOnWindowFocus:`always`,queryFn:async()=>{let i=n.getQueryData(r),a=await t(e).meta(i?.etag,{signal:AbortSignal.timeout(Tre)});if(a.status===`unchanged`){if(!i)throw Error(`${e.label} answered 304 to a request without If-None-Match`);return i}return{etag:a.etag,meta:Dc(a.meta,e)}}}}),combine:Ere});return(0,L.useMemo)(()=>e.map((e,t)=>{let{data:n,error:i}=r[t];return n?{source:e,state:`ready`,meta:n}:i?{source:e,state:`error`,error:i}:{source:e,state:`loading`}}),[e,r])},Ore=(e,t)=>{if(t.length===0)return e;let n=t.flatMap(e=>e.state===`ready`?[e.meta]:[]),r=t.map(e=>e.state===`error`?{source:e.source,state:`error`,error:e.error}:{source:e.source,state:e.state});return{...e,resources:{...e.resources,...Object.fromEntries(n.flatMap(e=>e.resources.map(e=>[e.name,e])))},views:{...e.views,...Object.fromEntries(n.flatMap(e=>e.views.map(e=>[e.resource,e])))},permissions:{...e.permissions,...Object.assign({},...n.map(e=>e.permissions))},sources:r}},ig=(e,t)=>e.sources?.find(e=>e.source.resources.includes(t)),ag=({locale:e,children:t})=>{h(e);let n=p();return(0,L.useEffect)(()=>{document.documentElement.lang=n},[n]),(0,z.jsx)(L.Fragment,{children:t},n)},og=a({en:{loading:`Loading`,cannotReach:`Cannot reach the API`,noAnswer:`The server did not answer. Is it running?`},nl:{loading:`Laden`,cannotReach:`De API is niet bereikbaar`,noAnswer:`De server gaf geen antwoord. Draait hij?`}}),G=()=>{let e=(0,L.useContext)(tg);if(!e)throw Error(`useAdminMeta must be used inside MetaGate`);return e},sg=({title:e,children:t})=>(0,z.jsx)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center p-8`,children:(0,z.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,z.jsx)(`h1`,{className:`text-[16px] font-semibold`,children:e}),(0,z.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]})}),kre=({meta:e,children:t})=>{let n=W(),r=Cre(),i=(0,L.useMemo)(()=>(e.sources??[]).map(e=>e.source),[e.sources]),a=Dre(i,r),o=(0,L.useMemo)(()=>Ore(e,a),[e,a]),s=(0,L.useMemo)(()=>{let e=new Map(i.flatMap(e=>e.resources.map(t=>[t,e]))),t=t=>{let n=e.get(t);return n&&r(n)};return{client:mc(n,t),resourceClient:t}},[i,n,r]);return(0,z.jsx)(wre,{client:s.client,resourceClient:s.resourceClient,children:(0,z.jsx)(tg.Provider,{value:o,children:(0,z.jsx)(ag,{locale:e.locale,children:t})})})},Are=({children:e})=>{let t=rg();return t.isPending?(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,og(`loading`)]}):t.error?(0,z.jsx)(sg,{title:og(`cannotReach`),children:Xs(t.error)?t.error.message:og(`noAnswer`)}):(0,z.jsx)(kre,{meta:t.data,children:e})},cg=e=>G().permissions[e]??ng,jre=(e=window)=>e.top!==e.self,Mre=(e,t,n)=>{let r=!1,i,a=e=>{r!==e&&(r=e,n(e))},o=()=>{clearTimeout(i),a(!1)},s=()=>{o(),e.visibilityState===`visible`&&e.hasFocus()&&(i=setTimeout(()=>a(!0),t))},c=()=>e.visibilityState===`visible`?s():o();return e.defaultView?.addEventListener(`focus`,s),e.defaultView?.addEventListener(`blur`,o),e.addEventListener(`visibilitychange`,c),s(),()=>{clearTimeout(i),e.defaultView?.removeEventListener(`focus`,s),e.defaultView?.removeEventListener(`blur`,o),e.removeEventListener(`visibilitychange`,c)}},Nre=()=>{let e=!1;return{down:(t,n=!1)=>{e=t&&!n},take:()=>{let t=e;return e=!1,t}}},Pre=e=>{let[t,n]=(0,L.useState)(!1);return(0,L.useEffect)(()=>Mre(document,e,n),[e]),t},Fre=(e,t)=>{let n=(0,L.useRef)(Nre());return{onPointerDown:()=>n.current.down(e),onKeyDown:t=>n.current.down(e,t.repeat),onClick:()=>{n.current.take()&&t()}}},Ire=[`localhost`,`127.0.0.1`,`[::1]`],lg=[`javascript:`,`data:`,`vbscript:`,`file:`,`blob:`,`about:`],Lre=e=>{if(!URL.canParse(e))return;let t=new URL(e);if(t.protocol===`https:`)return{kind:`site`,host:t.host};if(t.protocol===`http:`)return Ire.includes(t.hostname)?{kind:`this-computer`,port:t.port||`80`}:void 0;if(!lg.includes(t.protocol))return{kind:`device-app`,uri:e.split(`?`)[0].split(`#`)[0]}},Rre=e=>!URL.canParse(e,`http://local`)||!lg.includes(new URL(e,`http://local`).protocol),zre=(e,t)=>{let n=new URL(e,t.origin);if(n.origin===t.origin&&n.pathname===t.pathname)return ks(n.search).oauthQuery},Bre=()=>{let{params:e}=Pm();return(0,L.useMemo)(()=>ks(e.toString()),[e])},Vre={invalid_signature:`This request has expired: connect again from your app.`,STAFF_CANNOT_CONNECT:`Staff signed in as someone cannot allow apps to act for them.`,SIGN_IN_SETUP_REQUIRED:`Set up what this app requires for signing in first, then connect again from your app.`,ADDRESS_NOT_VERIFIED:`Confirm your address first: sign out, then sign in with a code emailed to you, and connect again from your app.`},Hre=e=>{if(!(e instanceof Oc))throw e;return(e.code&&Vre[e.code])??sf(e)},Ure=e=>t=>{if(!Rre(t))throw new Oc(`The app asked to be sent somewhere this page will not go.`,400);e(t)},Wre=({target:e})=>e.kind===`site`?(0,z.jsxs)(z.Fragment,{children:[`the website `,(0,z.jsx)(`strong`,{className:`font-medium text-foreground`,children:e.host})]}):e.kind===`this-computer`?(0,z.jsxs)(z.Fragment,{children:[`an app on this computer (port `,e.port,`)`]}):(0,z.jsxs)(z.Fragment,{children:[`an app on this device that opens `,(0,z.jsx)(`code`,{className:`break-all text-foreground`,children:e.uri})]}),Gre=({asking:e,appName:t,email:n,onAnswer:r,onSignOut:i})=>{let[a,o]=(0,L.useState)(!1),s=Pre(500),c=e=>{o(!0),r(e).finally(()=>o(!1))},l=Fre(s&&!a,()=>c(!0)),u=wf(e.client.client_name),d=Tf(e.client.client_id),{target:f}=e;return(0,z.jsx)(`div`,{className:`mx-auto flex w-full max-w-lg flex-col gap-4 px-4 py-10`,children:(0,z.jsxs)(`section`,{"aria-label":`Allow an app`,className:`rounded-lg border bg-background p-5`,children:[(0,z.jsxs)(`h1`,{className:`text-[16px] font-semibold`,children:[`Allow an app to act as you in `,t,`?`]}),(0,z.jsxs)(`p`,{className:`mt-3`,children:[`An app that calls itself`,` `,(0,z.jsxs)(`bdi`,{className:`inline-block max-w-full truncate align-bottom font-medium`,title:u,children:[`“`,u??`no name`,`”`]}),` `,`asks to act as you here.`]}),d&&(0,z.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Published by `,d,`.`]}),f?(0,z.jsxs)(`p`,{className:`mt-3 text-muted-foreground`,children:[`Allowing sends you on to `,(0,z.jsx)(Wre,{target:f}),`.`]}):(0,z.jsx)(`p`,{role:`alert`,className:`mt-3 text-danger-text`,children:`This app asked to be sent somewhere this page will not go, so it cannot be allowed.`}),(0,z.jsx)(`p`,{className:`mt-3 text-muted-foreground`,children:`It can then read and change what you can, with your current role and organization, until you disconnect it from your account page.`}),(0,z.jsxs)(`div`,{className:`mt-5 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,children:[(0,z.jsx)(V,{disabled:a,onClick:()=>c(!1),children:`Deny`}),f&&(0,z.jsx)(V,{variant:`primary`,loading:a,disabled:!s||a,...l,children:`Allow`})]}),(0,z.jsxs)(`p`,{className:`mt-4 border-t pt-3 text-xs text-muted-foreground`,children:[`Signed in as `,n,`.`,` `,(0,z.jsx)(`button`,{type:`button`,className:`underline underline-offset-2 hover:text-foreground`,onClick:i,children:`Not you? Sign out`})]})]})})},Kre=({oauthQuery:e,appName:t,email:n,assign:r})=>{let{session:i,signOut:a}=xf(),{path:o,basePath:s}=Pm(),c=Ure(r),l=e=>zre(e,{origin:window.location.origin,pathname:`${s}${o}`}),[u,d]=(0,L.useState)({kind:`loading`}),f=e=>d({kind:`failed`,message:Hre(e)});(0,L.useEffect)(()=>{let t=!0;return(async()=>{let{url:n}=await i.connect.resume(e),r=l(n);if(r===void 0)return c(n);let a=new URLSearchParams(r),o=await i.connect.client(a.get(`client_id`)??``);t&&d({kind:`asking`,asking:{oauthQuery:r,client:o,target:Lre(a.get(`redirect_uri`)??``)}})})().catch(e=>t&&f(e)),()=>{t=!1}},[i,e]);let p=async(e,t)=>{try{let{url:n}=await i.connect.answer(e,t.oauthQuery);l(n)!==void 0&&await a(),c(n)}catch(e){f(e)}};return u.kind===`failed`?(0,z.jsx)(sg,{title:`This app cannot be connected`,children:u.message}):u.kind===`loading`?(0,z.jsxs)(`div`,{className:`flex min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` Loading`]}):(0,z.jsx)(Gre,{asking:u.asking,appName:t,email:n,onAnswer:e=>p(e,u.asking),onSignOut:()=>void a()})},qre=({email:e,appName:t,isFramed:n=jre,assign:r=e=>window.location.assign(e)})=>{let[i]=(0,L.useState)(n),{oauthQuery:a}=Bre();return i?(0,z.jsxs)(sg,{title:`This page cannot be used inside another site`,children:[(0,z.jsx)(`a`,{href:window.location.href,target:`_blank`,rel:`noopener`,className:`underline underline-offset-2`,children:`Open it on its own`}),` `,`to go on.`]}):a?(0,z.jsx)(Kre,{oauthQuery:a,appName:t,email:e,assign:r},a):(0,z.jsx)(sg,{title:`Nothing to connect`,children:`Connect again from your app.`})},ug=()=>[{value:`allowed`,label:R(`on`)},{value:`forbidden`,label:R(`off`)}],dg=()=>[{value:`allowed`,label:R(`optional`)},{value:`required`,label:R(`required`)},{value:`forbidden`,label:R(`off`)}],fg=()=>[{method:`password`,label:R(`password`),description:R(`passwordDescription`),rules:ug()},{method:`emailCode`,label:R(`emailedSignInCode`),description:R(`emailedSignInCodeDescription`),rules:ug()},{method:`passkey`,label:R(`passkeys`),description:R(`passkeysPolicyDescription`),rules:dg()},{method:`twoFactor`,label:R(`twoFactor`),description:R(`twoFactorPolicyDescription`),rules:dg()},{method:`staffAccess`,label:R(`staffAccess`),description:R(`staffAccessDescription`),rules:[{value:`allowed`,label:R(`on`)},{value:`notify`,label:R(`emailThePerson`)},{value:`forbidden`,label:R(`off`)}]},{method:`platformSignIn`,label:R(`platformSignIn`),description:R(`platformSignInDescription`),rules:ug()}],Jre=(e,t)=>{let n=fg().find(t=>t.method===e)?.rules.find(e=>e.value===t)?.label;if(n===void 0)throw Error(`No label for the ${t} rule of ${e}`);return n},Yre=({row:e,value:t,onChange:n})=>(0,z.jsx)(`span`,{role:`radiogroup`,"aria-label":e.label,className:`inline-flex h-8 shrink-0 rounded-md bg-muted p-0.5`,children:e.rules.map(e=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t,onClick:()=>n(e.value),className:g(`rounded px-3 text-body font-medium transition-colors`,e.value===t?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value))}),Xre=({method:e},t,{mail:n,effective:r,policy:i})=>{if(e===`emailCode`&&!n)return R(`codeNeedsMail`);if(e===`password`&&!n&&t.password===`forbidden`)return R(`passwordStaysOn`);if(e===`staffAccess`&&!n&&t.staffAccess===`notify`)return R(`staffNeedsMail`);if(e===`platformSignIn`&&t.platformSignIn===`allowed`&&(t.passkey===`required`||t.twoFactor===`required`))return R(`platformOff`);if(t[e]===i[e]&&r[e]!==i[e])return R(`appliesAs`,Jre(e,r[e]))},Zre=({operator:e,platformSignIn:t})=>fg().flatMap(n=>n.method===`staffAccess`&&!e?[]:n.method===`platformSignIn`?t?[{...n,label:R(`platformSignInWith`,t)}]:[]:[n]),Qre=({state:e,onSave:t,busy:n,error:r,notice:i})=>{let[a,o]=(0,L.useState)(e.policy),s=Zre(e),c=s.some(({method:t})=>a[t]!==e.policy[t]);return(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t(a)},children:[(0,z.jsx)(`ul`,{className:`divide-y rounded-lg border bg-background`,children:s.map(t=>{let n=Xre(t,a,e);return(0,z.jsxs)(`li`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`font-semibold`,children:t.label}),(0,z.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t.description}),n&&(0,z.jsx)(`p`,{className:`mt-1.5 text-xs font-medium text-warning-text`,children:n})]}),(0,z.jsx)(Yre,{row:t,value:a[t.method],onChange:e=>o({...a,[t.method]:e})})]},t.method)})}),r&&(0,z.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-body font-medium text-danger-text`,children:r}),i&&!c&&(0,z.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.savedAt?e.savedBy?R(`lastSavedBy`,e.savedBy,np(Date.parse(e.savedAt))):R(`lastSaved`,np(Date.parse(e.savedAt))):R(`neverChanged`)}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[c&&(0,z.jsx)(V,{onClick:()=>o(e.policy),children:R(`reset`)}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:n,disabled:!c,children:R(`save`)})]})]})]})},$re=(e,t)=>e.endedAt?(0,z.jsx)(_d,{tone:`neutral`,children:R(`stopped`,np(Date.parse(e.endedAt)))}):Date.parse(e.expiresAt)<=t?(0,z.jsx)(_d,{tone:`neutral`,children:R(`ended`,np(Date.parse(e.expiresAt)))}):(0,z.jsx)(_d,{tone:`amber`,children:R(`signedInUntil`,np(Date.parse(e.expiresAt)))}),eie=({signIns:e,operator:t,error:n,now:r=Date.now()})=>(0,z.jsxs)(vp,{title:R(`staffSignIns`),description:R(`staffSignInsDescription`,t),children:[(0,z.jsx)(yp,{message:n}),e&&e.length===0&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:R(`noStaffSignIns`)}),e&&e.length>0&&(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,z.jsxs)(`li`,{className:`flex flex-col gap-1.5 p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,z.jsx)(`span`,{className:`font-medium break-all`,children:e.staffName?`${e.staffName} (${e.staff})`:e.staff}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:R(`as`)}),(0,z.jsx)(`span`,{className:`font-medium break-all`,children:e.user})]}),(0,z.jsx)(`p`,{className:`break-words`,children:e.reason}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:np(Date.parse(e.startedAt))}),$re(e,r)]})]},e.id))})]}),tie=({operator:e})=>{let{session:t}=xf(),[n,r]=(0,L.useState)(),[i,a]=(0,L.useState)();return(0,L.useEffect)(()=>{t.staff.log().then(r,e=>a(e instanceof Oc?sf(e):R(`couldNotReadStaffSignIns`)))},[t]),(0,z.jsx)(eie,{operator:e,signIns:n,error:i})},nie=()=>{let{session:e}=xf(),[t,n]=(0,L.useState)(),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(),[s,c]=(0,L.useState)();(0,L.useEffect)(()=>{e.signInPolicy.read().then(n,e=>o(e instanceof Oc?sf(e):R(`couldNotReadPolicy`)))},[e]);let l=async t=>{i(!0),o(void 0),c(void 0);try{n(await e.signInPolicy.save(t)),c(R(`policySaved`))}catch(e){if(!(e instanceof Oc))throw e;o(sf(e))}i(!1)};return(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,z.jsx)(ef,{title:R(`signInPolicy`),subtitle:R(`policySubtitle`)}),t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Qre,{state:t,busy:r,error:a,notice:s,onSave:e=>void l(e)},t.savedAt??`default`),t.operator&&(0,z.jsx)(tie,{operator:t.operator})]}):a?(0,z.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:a}):(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,R(`loading`)]})]})},pg=({title:e,description:t,size:n=`sm`,children:r})=>(0,z.jsx)(`div`,{className:`flex min-h-full w-full items-center justify-center bg-surface px-4 py-10`,children:(0,z.jsxs)(`div`,{className:g(`w-full`,n===`sm`?`max-w-sm`:`max-w-lg`),children:[(0,z.jsxs)(`div`,{className:`mb-6 flex flex-col items-center text-center`,children:[(0,z.jsx)(nd,{className:`size-10`}),(0,z.jsx)(`h1`,{className:`mt-4 text-xl font-semibold tracking-tight`,children:e}),t&&(0,z.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]}),(0,z.jsx)(`div`,{className:`rounded-lg border bg-background p-5 shadow-sm`,children:r})]})}),mg=({onResend:e,cooldown:t=30,disabled:n})=>{let[r,i]=(0,L.useState)(()=>Date.now()+t*1e3),[a,o]=(0,L.useState)(()=>Date.now()),s=Math.max(0,Math.ceil((r-a)/1e3));return(0,L.useEffect)(()=>{if(s===0)return;let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[s]),(0,z.jsx)(V,{variant:`ghost`,disabled:n||s>0,onClick:()=>{let n=Date.now();i(n+t*1e3),o(n),e()},className:`min-h-10`,children:s>0?B(`sendNewCodeIn`,s):B(`sendNewCode`)})},hg=({title:e,description:t,explanation:n,submitLabel:r,onSubmit:i,onResend:a,onChangeAddress:o,changeAddressLabel:s,busy:c,error:l,notice:u,resendCooldown:d})=>{let[f,p]=(0,L.useState)(``);return(0,z.jsxs)(pg,{title:e,description:t,children:[(0,z.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:n}),u&&(0,z.jsx)(`p`,{role:`status`,className:`mb-4 rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:u}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),i(f)},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`code`),(0,z.jsx)(Mp,{name:`code`,required:!0,autoFocus:!0,value:f,invalid:!!l,onChange:p,onComplete:e=>!c&&i(e)})]}),l&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:l}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:c,className:`min-h-10`,children:r}),(0,z.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-x-2 sm:justify-between`,children:[(0,z.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:s}),(0,z.jsx)(mg,{onResend:a,disabled:c,cooldown:d})]})]})]})},gg=(e,...t)=>{let n=e.split(`{}`);if(n.length!==t.length+1)throw Error(`The text "${e}" has ${n.length-1} places for ${t.length} elements`);return(0,z.jsx)(z.Fragment,{children:n.map((e,n)=>(0,z.jsxs)(L.Fragment,{children:[e,n<t.length&&t[n]]},n))})},rie=({email:e,onBack:t,...n})=>(0,z.jsx)(hg,{title:B(`checkEmail`),description:B(`signInCodeDescription`),explanation:(0,z.jsx)(z.Fragment,{children:gg(B(`signInCodeSent`),(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),submitLabel:B(`signIn`),onChangeAddress:t,changeAddressLabel:B(`backToSignIn`),...n}),iie=({email:e,onBack:t})=>{let{signInWithCode:n,sendSignInCode:r}=xf(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(),[c,l]=(0,L.useState)(),u=async e=>{a(!0),s(void 0),l(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;s(sf(e))}a(!1)};return(0,z.jsx)(rie,{email:e,busy:i,error:o,notice:c,onBack:t,onSubmit:t=>void u(()=>n(e,t)),onResend:()=>void u(async()=>{await r(e),l(B(`newCodeSent`))})})},aie=`protobase users create you@example.com`,oie=({command:e=aie,onCheckAgain:t,busy:n})=>{let[r,i]=(0,L.useState)(!1);return(0,z.jsxs)(pg,{title:B(`noAdminTitle`),description:B(`noAdminDescription`),children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`noAdminExplanation`)}),(0,z.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-md border bg-surface py-1.5 pl-3 pr-1.5`,children:[(0,z.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-xs`,children:e}),(0,z.jsx)(`button`,{type:`button`,"aria-label":B(`copyCommand`),onClick:()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)})},className:`inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted pointer-coarse:size-11`,children:r?(0,z.jsx)(xi,{className:`size-4 text-success`}):(0,z.jsx)(Li,{className:`size-4`})})]}),(0,z.jsx)(V,{variant:`primary`,className:`mt-4 min-h-10 w-full`,loading:n,onClick:t,children:B(`reload`)})]})},sie=({onSubmit:e,back:t,busy:n,error:r,sentTo:i})=>{let[a,o]=(0,L.useState)(``);return i?(0,z.jsxs)(pg,{title:B(`checkEmail`),children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:gg(B(`resetSent`),(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:i}))}),(0,z.jsx)(Qu,{to:t,className:g(gp({variant:`primary`}),`mt-4 min-h-10 w-full`),children:B(`backToSignIn`)})]}):(0,z.jsx)(pg,{title:B(`resetTitle`),description:B(`resetDescription`),children:(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(a.trim())},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`email`),(0,z.jsx)(Wd,{type:`email`,name:`email`,autoComplete:`username`,required:!0,autoFocus:!0,value:a,invalid:!!r,onChange:e=>o(e.target.value),className:`min-h-6`})]}),r&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:r}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:n,className:`min-h-10`,children:B(`sendResetLink`)}),(0,z.jsx)(Qu,{to:t,className:g(gp({variant:`ghost`}),`min-h-10`),children:B(`backToSignIn`)})]})})},_g=`password-reset`,cie=e=>{let t=new URL(e);return`${t.origin}${t.pathname}?${_g}`},lie=e=>{let t=new URL(e).searchParams;if(t.has(`password-reset`))return{token:t.get(`token`)||void 0}},uie=e=>{let t=new URL(e);for(let e of[_g,`token`,`error`])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},die=({back:e})=>{let{session:t}=xf(),[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(),[o,s]=(0,L.useState)(),c=async e=>{r(!0),a(void 0);try{await t.requestPasswordReset(e,cie(window.location.href)),s(e)}catch(e){if(!(e instanceof Oc))throw e;a(e.status===429?B(`tooManyRequests`):e.message)}r(!1)};return(0,z.jsx)(sie,{busy:n,error:i,sentTo:o,back:e,onSubmit:e=>void c(e)})},fie=({name:e,workspace:t})=>(0,z.jsx)(pg,{title:B(`signingInWith`,e),description:t,children:(0,z.jsxs)(`p`,{role:`status`,className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,B(`takingYouTo`,e)]})}),pie=({provider:e,workspace:t,onFailed:n})=>{let{signInProviders:r,signInSocial:i}=xf(),a=r.find(t=>t.id===e),o=a?.name??yf(e),s=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{if(!s.current){if(s.current=!0,!a)return n(B(`providerNotOffered`,o));i(e).catch(e=>{if(!(e instanceof Oc))throw e;n(cf(e))})}},[a,o,e,i,n]),(0,z.jsx)(fie,{name:o,workspace:t})},mie=({onSubmit:e,invalidLink:t,onRequestNewLink:n,onBack:r,busy:i,error:a})=>{let[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(!1);if(t)return(0,z.jsxs)(pg,{title:B(`linkExpiredTitle`),children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`linkExpiredExplanation`)}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[n&&(0,z.jsx)(V,{variant:`primary`,className:`min-h-10`,onClick:n,children:B(`sendNewLink`)}),(0,z.jsx)(V,{variant:n?`ghost`:`primary`,className:`min-h-10`,onClick:r,children:B(`backToSignIn`)})]})]});let f=u?B(`passwordsDiffer`):a;return(0,z.jsx)(pg,{title:B(`choosePassword`),description:B(`atLeast`,12),children:(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),d(o!==c),o===c&&e(o)},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`newPassword`),(0,z.jsx)(Wd,{type:`password`,name:`new-password`,autoComplete:`new-password`,required:!0,minLength:12,autoFocus:!0,value:o,invalid:!!f,onChange:e=>s(e.target.value),className:`min-h-6`})]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`repeatPassword`),(0,z.jsx)(Wd,{type:`password`,name:`repeat-password`,autoComplete:`new-password`,required:!0,minLength:12,value:c,invalid:!!f,onChange:e=>l(e.target.value),className:`min-h-6`})]}),f&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:B(`setPassword`)})]})})},hie=e=>e.status===429?B(`tooManyAttempts`):e.code===`PASSWORD_TOO_SHORT`?B(`useAtLeast`,12):e.code===`PASSWORD_TOO_LONG`?B(`passwordTooLong`):e.message,gie=({token:e,onDone:t,onRequestNewLink:n,onBack:r})=>{let{session:i}=xf(),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(),[l,u]=(0,L.useState)(!e),d=async n=>{o(!0),c(void 0);try{await i.resetPassword(e,n),t()}catch(e){if(!(e instanceof Oc))throw e;e.code===`INVALID_TOKEN`?u(!0):c(hie(e)),o(!1)}};return(0,z.jsx)(mie,{busy:a,error:s,invalidLink:l,onRequestNewLink:n,onBack:r,onSubmit:e=>void d(e)})},_ie=e=>B(e===`twoFactor`?`turnOnTwoFactor`:`addPasskey`),vie=({step:e,twoFactor:t,onAddPasskey:n,busy:r,error:i,onSignOut:a})=>(0,z.jsxs)(pg,{title:_ie(e),description:B(`requiredForEveryAccount`),children:[e===`twoFactor`?(0,z.jsx)(Cm,{...t}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`passkeyExplanation`)}),i&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,z.jsxs)(V,{variant:`primary`,loading:r,onClick:n,className:`min-h-10`,children:[(0,z.jsx)(fa,{className:`size-4`}),B(`addPasskey`)]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:underline`,children:B(`signOut`)})]}),yie=({missing:e})=>{let{session:t,recheck:n,signOut:r}=xf(),[i,a]=(0,L.useState)(),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)();(0,L.useEffect)(()=>{t.account.signInMethods().then(a,e=>l(e instanceof Oc?sf(e):B(`couldNotReadAccount`)))},[t]);let u=async()=>{s(!0),l(void 0);try{await t.account.addPasskey(),n()}catch(e){if(!(e instanceof Oc))throw e;l(sf(e)),s(!1)}};return!i&&!c?(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,B(`loading`)]}):(0,z.jsx)(vie,{step:e[0],busy:o,error:c,onAddPasskey:()=>void u(),onSignOut:()=>void r(),twoFactor:{offerEmailedCodes:i?.mail??!1,needsPassword:i?.account.password??!0,onStartApp:e=>t.account.startAuthenticatorApp(e),onConfirmApp:e=>t.account.confirmAuthenticatorApp(e),onEmailedCodes:e=>t.account.turnOnEmailedCodes(e),onDone:n}})},bie=({className:e})=>(0,z.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:g(`size-4 shrink-0`,e),"aria-hidden":!0,children:(0,z.jsx)(`path`,{d:`M10.226 17.284c-2.965-.36-5.054-2.493-5.054-5.256 0-1.123.404-2.336 1.078-3.144-.292-.741-.247-2.314.09-2.965.898-.112 2.111.36 2.83 1.01.853-.269 1.752-.404 2.853-.404 1.1 0 1.999.135 2.807.382.696-.629 1.932-1.1 2.83-.988.315.606.36 2.179.067 2.942.72.854 1.101 2 1.101 3.167 0 2.763-2.089 4.852-5.098 5.234.763.494 1.28 1.572 1.28 2.807v2.336c0 .674.561 1.056 1.235.786 4.066-1.55 7.255-5.615 7.255-10.646C23.5 6.188 18.334 1 11.978 1 5.62 1 .5 6.188.5 12.545c0 4.986 3.167 9.12 7.435 10.669.606.225 1.19-.18 1.19-.786V20.63a2.9 2.9 0 0 1-1.078.224c-1.483 0-2.359-.808-2.987-2.313-.247-.607-.517-.966-1.034-1.033-.27-.023-.359-.135-.359-.27 0-.27.45-.471.898-.471.652 0 1.213.404 1.797 1.235.45.651.921.943 1.483.943.561 0 .92-.202 1.437-.719.382-.381.674-.718.944-.943`})}),xie=({id:e,className:t})=>e===`github`?(0,z.jsx)(bie,{className:t}):null,Sie=()=>(0,z.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`h-px flex-1 bg-border`}),B(`or`),(0,z.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),Cie=({onSubmit:e,busy:t,error:n,workspace:r,notice:i,methods:a=[`password`],onSendCode:o,onPasskey:s,passkeyDomains:c=[],forgotPassword:l,providers:u=[],onContinueWith:d,signUp:f,onBrowse:p})=>{let[m,h]=(0,L.useState)(``),[g,_]=(0,L.useState)(``),v=(0,L.useRef)(null),y=a.includes(`password`),b=a.includes(`emailCode`)&&o!==void 0,x=a.includes(`passkey`)&&s!==void 0,S=d?u:[],C=()=>{v.current?.reportValidity()&&o?.(m.trim())};return(0,z.jsxs)(pg,{title:B(`signInTitle`),description:r,children:[i&&(0,z.jsx)(`p`,{role:`status`,className:`mb-4 rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(S.length>0||x)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[S.map(e=>(0,z.jsxs)(V,{onClick:()=>d?.(e.id),disabled:t,className:`min-h-10 w-full`,children:[(0,z.jsx)(xie,{id:e.id}),B(`continueWith`,e.name)]},e.id)),x&&(0,z.jsxs)(V,{onClick:()=>s?.(),disabled:t,className:`min-h-10 w-full`,children:[(0,z.jsx)(fa,{className:`size-4`}),B(`signInWithPasskey`)]}),x&&c.slice(1).map(e=>(0,z.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>s?.(e),disabled:t,className:`w-full`,children:B(`passkeyFor`,e)},e))]}),y||b?(0,z.jsx)(Sie,{}):n&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-4 text-body font-medium text-danger-text`,children:n})]}),(y||b)&&(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),y?e(m.trim(),g):C()},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`email`),(0,z.jsx)(Wd,{ref:v,type:`email`,name:`email`,autoComplete:`username webauthn`,required:!0,autoFocus:!0,value:m,invalid:!!n,onChange:e=>h(e.target.value),className:`min-h-6`})]}),y&&(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`password`),(0,z.jsx)(Wd,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:g,invalid:!!n,onChange:e=>_(e.target.value),className:`min-h-6`})]}),n&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:n}),y&&(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:t,className:`min-h-10`,children:B(`signIn`)}),b&&(0,z.jsxs)(V,{variant:y?`secondary`:`primary`,type:y?`button`:`submit`,onClick:y?C:void 0,loading:t&&!y,disabled:t,className:`min-h-10`,children:[(0,z.jsx)(Ma,{className:`size-4`}),B(`emailSignInCode`)]}),y&&l&&(0,z.jsx)(Qu,{to:l,className:`self-center font-medium text-primary-text hover:underline`,children:B(`forgotPassword`)})]}),f&&(0,z.jsxs)(`p`,{className:`mt-4 text-center text-muted-foreground`,children:[B(`newHere`),` `,(0,z.jsx)(Qu,{to:f,className:`font-medium text-primary-text hover:underline`,children:B(`createAnAccount`)})]}),p&&(0,z.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:B(`browse`)})]})},wie=({workspace:e,notice:t,forgotPassword:n,signUp:r,onBrowse:i,onCodeSent:a,error:o})=>{let{signIn:s,signInSocial:c,signInProviders:l,signInMethods:u,passkeyDomains:d,sendSignInCode:f,signInWithPasskey:p}=xf(),[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(o),v=async(e,t)=>{h(!0),_(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;_(t(e)),h(!1)}};return(0,z.jsx)(Cie,{busy:m,error:g,workspace:e,notice:t,methods:u,forgotPassword:n,signUp:r,onBrowse:i,providers:l,onContinueWith:e=>void v(()=>c(e),cf),passkeyDomains:d,onPasskey:e=>void v(()=>p(e),sf),onSendCode:e=>void v(async()=>{await f(e),a(e)},sf),onSubmit:(e,t)=>void v(()=>s(e,t),cf)})},Tie=({email:e,onBack:t,...n})=>(0,z.jsx)(hg,{title:B(`checkEmail`),description:B(`signUpCodeDescription`),explanation:(0,z.jsx)(z.Fragment,{children:gg(B(`signUpCodeSent`),(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),submitLabel:B(`continue`),onChangeAddress:t,changeAddressLabel:B(`useAnotherAddress`),...n}),Eie=({email:e,onSubmit:t,onBack:n,methods:r,busy:i,error:a})=>{let[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(``),u=(0,L.useId)(),d=r.includes(`password`),f=r.includes(`emailCode`);return(0,z.jsxs)(pg,{title:B(`detailsTitle`),description:B(`detailsDescription`),children:[(0,z.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:gg(B(`codeWasRight`),(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({name:o.trim(),...d&&c&&{password:c}})},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`yourName`),(0,z.jsx)(Wd,{name:`name`,autoComplete:`name`,required:!0,autoFocus:!0,maxLength:200,value:o,onChange:e=>s(e.target.value),className:`min-h-6`})]}),d&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(f?`passwordOptional`:`password`),(0,z.jsx)(Wd,{type:`password`,name:`password`,autoComplete:`new-password`,"aria-describedby":u,required:!f,minLength:12,maxLength:128,value:c,onChange:e=>l(e.target.value),className:`min-h-6`})]}),(0,z.jsxs)(`p`,{id:u,className:`text-xs text-muted-foreground`,children:[B(`atLeast`,12),f&&B(`withoutPassword`)]})]}),a&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:B(`createAccount`)}),(0,z.jsx)(V,{variant:`ghost`,onClick:n,className:`min-h-10`,children:B(`useAnotherAddress`)})]})]})},Die=({onSubmit:e,onSignIn:t,onBrowse:n,busy:r,error:i,workspace:a})=>{let[o,s]=(0,L.useState)(``);return(0,z.jsxs)(pg,{title:B(`createAnAccount`),description:a,children:[(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(o.trim())},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`email`),(0,z.jsx)(Wd,{type:`email`,name:`email`,autoComplete:`email`,required:!0,autoFocus:!0,value:o,invalid:!!i,onChange:e=>s(e.target.value),className:`min-h-6`})]}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`codeToConfirm`)}),i&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,z.jsxs)(V,{variant:`primary`,type:`submit`,loading:r,className:`min-h-10`,children:[(0,z.jsx)(Ma,{className:`size-4`}),B(`emailCode`)]}),(0,z.jsxs)(`p`,{className:`text-center text-muted-foreground`,children:[B(`haveAccount`),` `,(0,z.jsx)(`button`,{type:`button`,onClick:t,className:`font-medium text-primary-text hover:underline`,children:B(`signIn`)})]})]}),n&&(0,z.jsx)(`button`,{type:`button`,onClick:n,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:B(`browseWithoutAccount`)})]})},Oie=({workspace:e,email:t,ticket:n,onCodeSent:r,onVerified:i,onBack:a,onSignIn:o,onBrowse:s})=>{let{signInMethods:c,sendSignUpCode:l,verifySignUpCode:u,signUp:d}=xf(),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(),[g,_]=(0,L.useState)(),v=async e=>{p(!0),h(void 0),_(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;h(sf(e))}p(!1)};return t===void 0?(0,z.jsx)(Die,{workspace:e,busy:f,error:m,onSignIn:o,onBrowse:s,onSubmit:e=>void v(async()=>{await l(e),r(e)})}):n===void 0?(0,z.jsx)(Tie,{email:t,busy:f,error:m,notice:g,onBack:a,onSubmit:e=>void v(async()=>i(await u(t,e))),onResend:()=>void v(async()=>{await l(t),_(B(`newCodeSent`))})}):(0,z.jsx)(Eie,{email:t,methods:c,busy:f,error:m,onBack:a,onSubmit:e=>void v(()=>d({ticket:n,...e}))})},vg=`staff-sign-in`,yg=`staff-error`,kie=e=>{let t=new URL(e).searchParams,n=t.get(yg);if(!t.has(`staff-sign-in`)&&!n)return;let r=t.has(vg);return{email:r&&t.get(`email`)||``,reason:r&&t.get(`reason`)||``,...n&&{error:n}}},bg=e=>{let t=new URL(e);if(t.searchParams.has(`staff-sign-in`))for(let e of[vg,`email`,`reason`])t.searchParams.delete(e);return t.searchParams.delete(yg),`${t.pathname}${t.search}${t.hash}`},Aie=10,jie=({operator:e,email:t=``,reason:n=``,onSubmit:r,onBack:i,busy:a,error:o})=>{let[s,c]=(0,L.useState)(t),[l,u]=(0,L.useState)(n);return e?(0,z.jsx)(pg,{title:B(`signInAsPerson`),description:B(`forStaffOf`,e),children:(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),r(s.trim(),l.trim())},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`theirEmail`),(0,z.jsx)(Wd,{type:`email`,name:`email`,required:!0,autoFocus:!t,value:s,onChange:e=>c(e.target.value),className:`min-h-6`})]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(`reason`),(0,z.jsx)(`textarea`,{name:`reason`,required:!0,minLength:Aie,rows:3,value:l,placeholder:B(`reasonExample`),onChange:e=>u(e.target.value),className:g(`resize-y rounded-md border bg-background px-2.5 py-1.5 font-normal shadow-sm outline-none placeholder:text-faint-foreground focus:border-primary focus:ring-2 focus:ring-primary/20`,o?`border-danger`:`border-border-strong`)})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:B(`staffExplanation`,e)}),o&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:o}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:a,className:`min-h-10`,children:B(`continueWith`,e)}),(0,z.jsx)(V,{variant:`ghost`,onClick:i,className:`min-h-10`,children:B(`backToSignIn`)})]})}):(0,z.jsxs)(pg,{title:B(`staffTitle`),description:B(`staffUnavailable`),children:[o&&(0,z.jsx)(`p`,{role:`alert`,className:`mb-4 text-body font-medium text-danger-text`,children:o}),(0,z.jsx)(V,{variant:`primary`,className:`min-h-10 w-full`,onClick:i,children:B(`backToSignIn`)})]})},Mie=({link:e,onBack:t})=>{let{session:n,staffSignIn:r}=xf(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(e.error&&uf(e.error)),c=async(e,t)=>{a(!0),s(void 0);try{let r=`${window.location.origin}${bg(window.location.href)}`;window.location.assign(await n.staff.start({email:e,reason:t,callbackURL:r}))}catch(e){if(!(e instanceof Oc))throw e;s(uf(e)),a(!1)}};return(0,z.jsx)(jie,{operator:r,email:e.email,reason:e.reason,busy:i,error:o,onBack:t,onSubmit:(e,t)=>void c(e,t)})},xg=({checked:e,indeterminate:t,onChange:n,label:r,disabled:i,className:a})=>(0,z.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t?`mixed`:e,"aria-label":r,disabled:i,onClick:()=>n?.(!e),className:g(`relative inline-flex size-4 shrink-0 items-center justify-center rounded border transition-colors after:absolute after:-inset-1 after:content-[""] pointer-coarse:after:-inset-3.5`,e||t?`border-primary bg-primary text-primary-foreground`:`border-border-strong bg-background hover:border-faint-foreground`,a),children:t?(0,z.jsx)(Ba,{className:`size-3`,strokeWidth:3}):e&&(0,z.jsx)(xi,{className:`size-3`,strokeWidth:3})}),Nie={totp:`totpInstruction`,otp:`otpInstruction`,backup:`backupInstruction`},Pie=({methods:e,onVerify:t,onSendCode:n,onBack:r,busy:i,error:a,codeSent:o,initialStep:s})=>{let[c,l]=(0,L.useState)(s??(e.includes(`totp`)?`totp`:`otp`)),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(!1),m=c===`otp`&&!o,h=e=>{l(e),d(``),e===`otp`&&!o&&n()};return(0,z.jsxs)(pg,{title:B(`twoFactorTitle`),description:B(`twoFactorDescription`),children:[m?(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`codeToFinish`)}),a&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,z.jsx)(V,{variant:`primary`,loading:i,onClick:n,className:`min-h-10`,children:B(`emailCode`)})]}):(0,z.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({method:c,code:u.trim(),trustDevice:f})},children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(Nie[c])}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[B(c===`backup`?`backupCode`:`code`),c===`backup`?(0,z.jsx)(Wd,{name:`code`,autoComplete:`off`,spellCheck:!1,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:e=>d(e.target.value),className:`min-h-6 font-mono`}):(0,z.jsx)(Mp,{name:`code`,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:d})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(xg,{checked:f,onChange:p,label:B(`trustBrowser`)}),B(`trustBrowserFor`)]}),a&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:B(`verify`)})]}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col items-center gap-2 border-t pt-4`,children:[c!==`totp`&&e.includes(`totp`)&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>h(`totp`),className:`font-medium text-primary-text hover:underline`,children:B(`useAuthenticator`)}),c!==`otp`&&e.includes(`otp`)&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>h(`otp`),className:`font-medium text-primary-text hover:underline`,children:B(`emailCodeInstead`)}),c!==`backup`&&e.includes(`totp`)&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>h(`backup`),className:`font-medium text-primary-text hover:underline`,children:B(`useBackupCode`)}),(0,z.jsx)(`button`,{type:`button`,onClick:r,className:`font-medium text-muted-foreground hover:underline`,children:B(`backToSignIn`)})]})]})},Fie=({methods:e,onBack:t})=>{let{verifyTwoFactor:n,session:r}=xf(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(),[c,l]=(0,L.useState)(!1),u=async e=>{a(!0),s(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;s(sf(e))}a(!1)};return(0,z.jsx)(Pie,{methods:e,busy:i,error:o,codeSent:c,onBack:t,onVerify:e=>void u(()=>n(e)),onSendCode:()=>void u(async()=>{await r.sendTwoFactorCode(),l(!0)})})},Iie=e=>{let t=new URL(e),n=t.searchParams.get(`token`);return t.pathname.endsWith(`/-/invitation`)&&n?{token:n}:void 0},Lie=e=>`${new URL(e).pathname.slice(0,-13)}/`,K=a({en:{organizations:`Organizations`,organization:`Organization`,members:`Members`,invitations:`Invitations`,owner:`Owner`,admin:`Admin`,member:`Member`,loading:`Loading`,name:`Name`,slug:`Slug`,save:`Save`,cancel:`Cancel`,delete:`Delete`,remove:`Remove`,create:`Create`,current:`Current`,open:`Open`,allOrganizations:`All organizations`,allOrganizationsDescription:`Every organization in the app. Your global roles let you work in any of them, with what those roles allow there. Opening one you are not a member of is written to the audit log.`,findOrganization:`Find an organization`,nameOrSlug:`Name or slug`,cannotChangeRole:`You cannot give or take away this role`,makeAccountToJoin:e=>`Make your account for ${e} to join.`,makeAccount:e=>`Make your account for ${e}.`,yourName:`Your name`,password:`Password`,passwordOptional:e=>`Password (optional, ${e}+ characters)`,passwordRequired:e=>`Password (${e}+ characters)`,createAndJoin:`Create account and join`,createYourAccount:`Create your account`,invalidLink:`This invitation link is not valid`,invitation:`Invitation`,goToApp:`Go to the app`,invitesToApp:(e,t)=>`${e} invites you to join ${t}.`,invitesTo:(e,t,n)=>`${e} invites you to ${t} as ${n}.`,invitesToWith:(e,t,n,r)=>`${e} invites you to ${t} as ${n}, with ${r}.`,join:e=>`Join ${e}`,hasAccount:e=>`${e} has an account already: sign in with it.`,signOut:`Sign out`,signInAs:e=>`Sign in as ${e}`,signInAsToJoin:e=>`Sign in as ${e} to join`,otherAddress:(e,t)=>`This invitation is for ${e}, and you are signed in as ${t}.`,signOutToAccept:`Sign out to accept it`,inviteSomeone:`Invite someone`,inviteDescription:`They get an email with a link to join, or to make an account first. You can give the app roles you hold, and those your roles grant.`,organizationRole:`Organization role`,peopleInvited:e=>`People invited to ${e}.`,notAcceptedYet:`Not accepted yet`,sendingAgain:`Sending again gives a new link, which replaces the earlier one.`,nobodyWaiting:`Nobody is waiting.`,roleOf:e=>`Organization role of ${e}`,couldNotReadMembers:`Could not read the members`,whoWorks:e=>`Who works in ${e}, and with which roles.`,membersDescription:`Owners and admins manage the organization; app roles decide what each member sees and does in the app.`,details:`Details`,detailsEditable:`The name people see, and the slug that names it in links.`,detailsReadOnly:`Owners and admins can change these.`,handOver:`Hand over`,handOverDescription:`Make another member the owner. You stay as an admin.`,newOwner:`New owner`,chooseMember:`Choose a member`,deleteOrganization:`Delete organization`,deleteDescription:`Takes the organization and its members and invitations away. Its records must be deleted first.`,deleteTitle:e=>`Delete ${e}?`,deleteConfirm:`Type its name to confirm. This cannot be undone.`,organizationName:`Organization name`,leave:`Leave`,leaveOwner:`An organization keeps an owner: hand it over before you leave, unless it has another owner.`,leaveMember:`You stop being a member, and lose your roles here.`,leaveName:e=>`Leave ${e}`,noOrganization:`You do not work in an organization now. Choose one under Organizations.`,youAre:e=>`You are ${e} here.`,throughGlobalRoles:`You work here through your global roles, without being a member.`,newOrganization:`New organization`,newOrganizationDescription:`You become its owner, with every role, and work in it once it is made.`,invitationsForYou:`Invitations for you`,invitationsForYouDescription:`Open the link in the invitation email to accept one.`,anOrganization:`An organization`,noAppRoles:`no app roles`,until:e=>`Until ${e}`,organizationsSubtitle:`You work in one organization at a time; what you see follows from your roles there.`,yourOrganizations:`Your organizations`,memberOf:`The organizations you are a member of.`,notMember:`You are not a member of an organization yet.`,couldNotReadOrganizations:`Could not read your organizations`},nl:{organizations:`Organisaties`,organization:`Organisatie`,members:`Leden`,invitations:`Uitnodigingen`,owner:`Eigenaar`,admin:`Beheerder`,member:`Lid`,loading:`Laden`,name:`Naam`,slug:`Slug`,save:`Bewaren`,cancel:`Annuleren`,delete:`Verwijderen`,remove:`Verwijderen`,create:`Maken`,current:`Huidige`,open:`Openen`,allOrganizations:`Alle organisaties`,allOrganizationsDescription:`Elke organisatie in de app. Met je globale rollen kun je in elk ervan werken, met wat die rollen daar toestaan. Wie er een opent waar die geen lid van is, komt in het auditlogboek.`,findOrganization:`Een organisatie zoeken`,nameOrSlug:`Naam of slug`,cannotChangeRole:`Je kunt deze rol niet geven of afnemen`,makeAccountToJoin:e=>`Maak je account voor ${e} om lid te worden.`,makeAccount:e=>`Maak je account voor ${e}.`,yourName:`Je naam`,password:`Wachtwoord`,passwordOptional:e=>`Wachtwoord (optioneel, ${e}+ tekens)`,passwordRequired:e=>`Wachtwoord (${e}+ tekens)`,createAndJoin:`Account maken en lid worden`,createYourAccount:`Je account maken`,invalidLink:`Deze uitnodigingslink is niet geldig`,invitation:`Uitnodiging`,goToApp:`Naar de app`,invitesToApp:(e,t)=>`${e} nodigt je uit voor ${t}.`,invitesTo:(e,t,n)=>`${e} nodigt je uit voor ${t} als ${n}.`,invitesToWith:(e,t,n,r)=>`${e} nodigt je uit voor ${t} als ${n}, met ${r}.`,join:e=>`Lid worden van ${e}`,hasAccount:e=>`${e} heeft al een account: log daarmee in.`,signOut:`Uitloggen`,signInAs:e=>`Inloggen als ${e}`,signInAsToJoin:e=>`Inloggen als ${e} om lid te worden`,otherAddress:(e,t)=>`Deze uitnodiging is voor ${e}, en je bent ingelogd als ${t}.`,signOutToAccept:`Uitloggen om die te accepteren`,inviteSomeone:`Iemand uitnodigen`,inviteDescription:`Die krijgt een e-mail met een link om lid te worden, of om eerst een account te maken. Je kunt de app-rollen geven die je zelf hebt, en die je rollen toekennen.`,organizationRole:`Rol in de organisatie`,peopleInvited:e=>`Mensen uitgenodigd voor ${e}.`,notAcceptedYet:`Nog niet geaccepteerd`,sendingAgain:`Opnieuw sturen geeft een nieuwe link, die de vorige vervangt.`,nobodyWaiting:`Er wacht niemand.`,roleOf:e=>`Rol in de organisatie van ${e}`,couldNotReadMembers:`Kon de leden niet lezen`,whoWorks:e=>`Wie in ${e} werkt, en met welke rollen.`,membersDescription:`Eigenaren en beheerders beheren de organisatie; app-rollen bepalen wat elk lid in de app ziet en doet.`,details:`Gegevens`,detailsEditable:`De naam die mensen zien, en de slug die haar in links noemt.`,detailsReadOnly:`Eigenaren en beheerders kunnen dit wijzigen.`,handOver:`Overdragen`,handOverDescription:`Maak een ander lid eigenaar. Jij blijft beheerder.`,newOwner:`Nieuwe eigenaar`,chooseMember:`Kies een lid`,deleteOrganization:`Organisatie verwijderen`,deleteDescription:`Verwijdert de organisatie met haar leden en uitnodigingen. Haar records moeten eerst worden verwijderd.`,deleteTitle:e=>`${e} verwijderen?`,deleteConfirm:`Typ de naam om te bevestigen. Dit kan niet ongedaan worden gemaakt.`,organizationName:`Naam van de organisatie`,leave:`Verlaten`,leaveOwner:`Een organisatie houdt een eigenaar: draag die rol over voordat je vertrekt, tenzij er nog een eigenaar is.`,leaveMember:`Je bent dan geen lid meer, en verliest je rollen hier.`,leaveName:e=>`${e} verlaten`,noOrganization:`Je werkt nu niet in een organisatie. Kies er een onder Organisaties.`,youAre:e=>`Je bent hier ${e}.`,throughGlobalRoles:`Je werkt hier via je globale rollen, zonder lid te zijn.`,newOrganization:`Nieuwe organisatie`,newOrganizationDescription:`Je wordt de eigenaar, met elke rol, en werkt erin zodra die is gemaakt.`,invitationsForYou:`Uitnodigingen voor jou`,invitationsForYouDescription:`Open de link in de uitnodigingsmail om er een te accepteren.`,anOrganization:`Een organisatie`,noAppRoles:`geen app-rollen`,until:e=>`Tot ${e}`,organizationsSubtitle:`Je werkt in één organisatie tegelijk; wat je ziet volgt uit je rollen daar.`,yourOrganizations:`Je organisaties`,memberOf:`De organisaties waar je lid van bent.`,notMember:`Je bent nog geen lid van een organisatie.`,couldNotReadOrganizations:`Kon je organisaties niet lezen`}}),Sg=`/-/organizations`,Cg=`/-/organization`,wg=`/-/organization/members`,Tg=`/-/organization/invitations`,Rie={[Sg]:`organizations`,[Cg]:`organization`,[wg]:`members`,[Tg]:`invitations`},zie=e=>{let t=Rie[e];return t&&K(t)},Eg=e=>K(e),Dg=(e,t)=>e.find(e=>e.name===t)?.label??t,Og=e=>e?.role===`owner`||e?.role===`admin`,Bie=(e,t,n)=>{let r=(n,r,i,a)=>({id:n,label:r,icon:i,href:`${e}${a}`,active:t===a});return[r(`organizations`,K(`organizations`),Ga,Sg),...n?.organization?[r(`organization`,K(`organization`),mi,Cg)]:[],...Og(n)?[r(`members`,K(`members`),ts,wg),r(`invitations`,K(`invitations`),Ma,Tg)]:[]]},kg=(e,t)=>{let n=[...t?.globalRoles??[],...t?.appRoles??[]],r=e.filter(e=>e.membership).map(e=>e.name);if(n.includes(`admin`))return new Set(r);let i=n.flatMap(t=>e.find(e=>e.name===t)?.grants??[]);return new Set([...n,...i].filter(e=>r.includes(e)))},Ag=()=>{let[e,t]=(0,L.useState)(!1),[n,r]=(0,L.useState)();return{busy:e,error:n,run:async e=>{t(!0),r(void 0);try{await e()}catch(e){if(!(e instanceof Oc))throw e;r(sf(e))}t(!1)},setError:r}},jg=({token:e,preview:t,joins:n,onDone:r})=>{let{session:i,signInMethods:a,recheck:o}=xf(),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(``),{busy:d,error:f,run:p}=Ag(),m=a.includes(`password`),h=a.includes(`emailCode`),g=()=>p(async()=>{await i.organizations.signUpFromInvitation(e,{name:s.trim(),...m&&l&&{password:l}}),r(),o()});return(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:K(n?`makeAccountToJoin`:`makeAccount`,t.email)}),f&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,z.jsx)(Wd,{"aria-label":K(`yourName`),placeholder:K(`yourName`),autoComplete:`name`,value:s,onChange:e=>c(e.target.value)}),m&&(0,z.jsx)(Wd,{"aria-label":K(`password`),type:`password`,autoComplete:`new-password`,placeholder:K(h?`passwordOptional`:`passwordRequired`,12),value:l,onChange:e=>u(e.target.value)}),(0,z.jsx)(V,{type:`submit`,variant:`primary`,loading:d,disabled:!s.trim()||m&&!h&&l.length<12,children:K(n?`createAndJoin`:`createYourAccount`)})]})},Vie=({token:e,onDone:t,signIn:n})=>{let{session:r,state:i,signOut:a,organizations:o}=xf(),[s,c]=(0,L.useState)(),[l,u]=(0,L.useState)(),{busy:d,error:f,run:p}=Ag();if((0,L.useEffect)(()=>{r.organizations.invitation(e).then(c,e=>u(e instanceof Oc?sf(e):K(`invalidLink`)))},[r,e]),l)return(0,z.jsx)(pg,{title:K(`invitation`),description:l,children:(0,z.jsx)(V,{className:`w-full`,onClick:t,children:K(`goToApp`)})});if(!s)return(0,z.jsx)(pg,{title:K(`invitation`),children:(0,z.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,K(`loading`)]})});let m=i.kind===`signed-in`?i.user:void 0,h=m?.email.toLowerCase()===s.email.toLowerCase();if(!s.organization){let r=s.app?.name??``,i=K(`invitesToApp`,s.inviter.name,r);return(0,z.jsx)(pg,{title:K(`join`,r),description:i,children:s.hasAccount?m&&h?(0,z.jsx)(V,{variant:`primary`,className:`w-full`,onClick:t,children:K(`goToApp`)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:K(`hasAccount`,s.email)}),m?(0,z.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:K(`signOut`)}):(0,z.jsx)(Qu,{to:n,className:g(gp({variant:`primary`}),`w-full`),children:K(`signInAs`,s.email)})]}):m?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:K(`otherAddress`,s.email,m.email)}),(0,z.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:K(`signOutToAccept`)})]}):(0,z.jsx)(jg,{token:e,preview:s,joins:!1,onDone:t})})}let _=s.organization,v=s.appRoles.map(e=>Dg(o?.roles??[],e)),y=Eg(s.role).toLowerCase(),b=v.length>0?K(`invitesToWith`,s.inviter.name,_.name,y,v.join(`, `)):K(`invitesTo`,s.inviter.name,_.name,y);return m&&!h?(0,z.jsxs)(pg,{title:K(`join`,_.name),description:b,children:[(0,z.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:K(`otherAddress`,s.email,m.email)}),(0,z.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:K(`signOutToAccept`)})]}):(0,z.jsx)(pg,{title:K(`join`,_.name),description:b,children:m?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,z.jsx)(V,{variant:`primary`,className:`w-full`,loading:d,onClick:()=>void p(async()=>{await r.organizations.accept(e),t()}),children:K(`join`,_.name)})]}):s.hasAccount?(0,z.jsx)(Qu,{to:n,className:g(gp({variant:`primary`}),`w-full`),children:K(`signInAsToJoin`,s.email)}):(0,z.jsx)(jg,{token:e,preview:s,joins:!0,onDone:t})})},Mg,Ng,Hie=({dsn:e,environment:t})=>(Mg??=m(()=>import(`./prod-YZ9ZMG1O.js`).then(n=>{n.init({dsn:e,...t&&{environment:t},integrations:e=>e.filter(e=>e.name!==`BrowserSession`),beforeSend:e=>Cr(e)}),Ng=(e,t)=>n.captureException(e,t?{contexts:{react:{componentStack:t}}}:void 0)}),[]),Mg),Pg=(e,t)=>Ng?.(e,t??void 0),Fg=({children:e})=>(0,z.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-dashed border-warning bg-warning-soft p-3 text-warning-text`,children:e}),Ig=a({en:{notFound:`Not found`,noPage:`There is no page called {}.`,cancel:`Cancel`,couldNotDraw:`{} could not be drawn.`,noComponent:`No component is registered as {}. Export it from protobase.ui.tsx, or load the plugin that provides it.`,unknownBlock:`{} is not a block this version of the app knows.`,somethingWrong:`Something went wrong`,needsRecord:`Needs a record`,cannotChange:`You cannot change this record`,cannotDelete:`You cannot delete this record`,doesNotApply:`Does not apply to this record`,noHandler:e=>`The app has no handler for "${e}"`,noInputComponent:(e,t)=>`The app has no component "${e}" for input "${t}"`,done:e=>`${e}: done`,doneOn:(e,t,n,r)=>[`${e}: done on ${t}`,...n>0?[`skipped ${n} it does not apply to`]:[],...r>0?[`failed on ${r}`]:[]].join(`, `),failed:e=>`${e} failed`,noAction:e=>`No action "${e}"`,couldNotLoad:`Could not load`,nothingYet:`Nothing here yet.`,saved:e=>`${e}: saved`,create:`Create`,save:`Save`,notSaved:`Not saved`,couldNotCount:`Could not count`,required:`Required`,wholeNumber:`A whole number`,number:`A number`,dateFormat:`A date as YYYY-MM-DD`,atMost:e=>`At most ${e} characters`},nl:{notFound:`Niet gevonden`,noPage:`Er is geen pagina met de naam {}.`,cancel:`Annuleren`,couldNotDraw:`{} kon niet worden getekend.`,noComponent:`Er is geen component geregistreerd als {}. Exporteer die uit protobase.ui.tsx, of laad de plug-in die haar levert.`,unknownBlock:`{} is geen blok dat deze versie van de app kent.`,somethingWrong:`Er ging iets mis`,needsRecord:`Vraagt een record`,cannotChange:`Je kunt dit record niet wijzigen`,cannotDelete:`Je kunt dit record niet verwijderen`,doesNotApply:`Geldt niet voor dit record`,noHandler:e=>`De app heeft geen handler voor "${e}"`,noInputComponent:(e,t)=>`De app heeft geen component "${e}" voor invoer "${t}"`,done:e=>`${e}: klaar`,doneOn:(e,t,n,r)=>[`${e}: klaar voor ${t}`,...n>0?[`${n} overgeslagen waarvoor het niet geldt`]:[],...r>0?[`mislukt voor ${r}`]:[]].join(`, `),failed:e=>`${e} mislukt`,noAction:e=>`Geen actie "${e}"`,couldNotLoad:`Kon niet laden`,nothingYet:`Hier staat nog niets.`,saved:e=>`${e}: bewaard`,create:`Maken`,save:`Bewaren`,notSaved:`Niet bewaard`,couldNotCount:`Kon niet tellen`,required:`Verplicht`,wholeNumber:`Een geheel getal`,number:`Een getal`,dateFormat:`Een datum als JJJJ-MM-DD`,atMost:e=>`Hoogstens ${e} tekens`}}),Lg=class extends L.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){Pg(e,t.componentStack)}render(){return this.state.failed?this.props.fallback===void 0?(0,z.jsx)(Fg,{children:gg(Ig(`couldNotDraw`),this.props.name)}):this.props.fallback:this.props.children}},Uie=/^[A-Z][A-Za-z0-9]*$/,Wie=e=>typeof e==`function`||typeof e==`object`&&!!e&&`$$typeof`in e,Rg=e=>{let t=e.default??{},n=Object.entries(e).filter(e=>e[0]!=="default"&&Uie.test(e[0])&&Wie(e[1]));if(n.length===0)return t;for(let[e,r]of n)if(t.components&&Object.hasOwn(t.components,e)&&t.components[e]!==r)throw Error(`The component "${e}" is exported by name and given in components as another one; keep the export`);return{...t,components:{...t.components,...Object.fromEntries(n)}}},zg=class extends Error{name=`UiConflictError`},Gie=e=>Object.keys(e).some(e=>e==="default"||/^[A-Z]/.test(e))?Rg(e):e,Bg=(e,t)=>[...(e.extends??[]).map(Gie).flatMap((e,n)=>Bg(e,e.name??`${t} extends[${n}]`)),{ui:e,label:t}],Vg=(e,t,n)=>{let r={},i=new Map;for(let{ui:a,label:o}of t)for(let[t,s]of Object.entries(n(a)??{})){if(Object.hasOwn(r,t)&&r[t]!==s)throw new zg(`${e} "${t}" is defined twice, by ${i.get(t)} and by ${o}; rename one of them`);r[t]=s,i.set(t,i.get(t)??o)}return r},Hg=e=>e.length<=1?e[0]:()=>e.map((e,t)=>(0,z.jsx)(e,{},t)),Kie=e=>e.length<=1?e[0]:({children:t,...n})=>e.reduceRight((e,t)=>(0,z.jsx)(t,{...n,children:e}),t),Ug=(...e)=>{let t=e.flatMap((e,t)=>Bg(e,e.name??`UI config ${t+1}`)),n=Vg(`The component`,t,e=>e.components),r=Vg(`The action handler`,t,e=>e.actions),i=Vg(`The field type`,t,e=>e.fields),a=Vg(`The drop rule`,t,e=>e.dropRules),o=Vg(`The board drop`,t,e=>e.boardDrops),s=Hg(t.flatMap(({ui:e})=>e.shell?.actions?[e.shell.actions]:[])),c=Hg(t.flatMap(({ui:e})=>e.shell?.rightPanel?[e.shell.rightPanel]:[])),l=t.findLast(({ui:e})=>e.shell?.logo)?.ui.shell?.logo,u=Kie(t.flatMap(({ui:e})=>e.beforeSignIn?[e.beforeSignIn]:[])),d=e.at(-1)?.name;return{...d&&{name:d},components:n,actions:r,...Object.keys(i).length>0&&{fields:i},...Object.keys(a).length>0&&{dropRules:a},...Object.keys(o).length>0&&{boardDrops:o},...(s||c||l)&&{shell:{...s&&{actions:s},...c&&{rightPanel:c},...l&&{logo:l}}},...u&&{beforeSignIn:u}}},Wg=(e,t)=>{let n=Ug(e??{}),r=[],i=[];for(let e of t){if(e.kind===`off`){i.push(e);continue}try{Ug(...r,e.ui,n),r.push(e.ui)}catch(t){if(!(t instanceof zg))throw t;i.push({kind:`off`,url:e.plugin.url,name:e.plugin.name,reason:t.message})}}return{ui:r.length===0?n:Ug(...r,n),off:i}},Gg=a({en:{loading:`Loading`,pluginsOff:`Plugins off`,pluginOff:`The plugin {} is off: {}.`,dismiss:`Dismiss`,answered:e=>`its plugin.json answered ${e}`,couldNotLoad:e=>`it could not be loaded: ${e}`,notObject:`its plugin.json is not an object`,noName:`its plugin.json names no plugin`,noApi:`its plugin.json names no plugin API`,noVersions:`its plugin.json names no Protobase versions`,noModule:`its plugin.json names no module`,badStylesheet:`its plugin.json names a stylesheet that is no URL`,badVersion:`its plugin.json has a version that is no text`},nl:{loading:`Laden`,pluginsOff:`Plug-ins uit`,pluginOff:`De plug-in {} staat uit: {}.`,dismiss:`Sluiten`,answered:e=>`de plugin.json antwoordde ${e}`,couldNotLoad:e=>`hij kon niet worden geladen: ${e}`,notObject:`de plugin.json is geen object`,noName:`de plugin.json noemt geen plug-in`,noApi:`de plugin.json noemt geen plug-in-API`,noVersions:`de plugin.json noemt geen Protobase-versies`,noModule:`de plugin.json noemt geen module`,badStylesheet:`de plugin.json noemt een stylesheet die geen URL is`,badVersion:`de plugin.json heeft een versie die geen tekst is`}}),Kg=e=>typeof e==`string`&&e.trim()!==``,qie=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return{problem:Gg(`notObject`)};let{name:t,version:n,api:r,protobase:i,entry:a,css:o}=e;return Kg(t)?Number.isInteger(r)?Kg(i)?Kg(a)?o!==void 0&&!Kg(o)?{problem:Gg(`badStylesheet`)}:n!==void 0&&!Kg(n)?{problem:Gg(`badVersion`)}:{manifest:{name:t,api:r,protobase:i,entry:a,...n!==void 0&&{version:n},...o!==void 0&&{css:o}}}:{problem:Gg(`noModule`)}:{problem:Gg(`noVersions`)}:{problem:Gg(`noApi`)}:{problem:Gg(`noName`)}},qg=(0,L.createContext)(null),Jie=qg.Provider,Yie=()=>{let e=(0,L.useContext)(qg);if(!e)throw Error(`usePlugin is for the components of a plugin the app loaded`);return e},Jg=(e,t,n)=>{let r=n=>(0,z.jsx)(Jie,{value:e,children:(0,z.jsx)(t,{...n})});return r.displayName=`${e.name}:${n}`,r},Xie=(e,t,n)=>({of:n.of,display:Jg(e,n.display,`fields.${t}.display`),...n.editor&&{editor:Jg(e,n.editor,`fields.${t}.editor`)},...n.cell&&{cell:Jg(e,n.cell,`fields.${t}.cell`)}}),Zie=(e,t)=>{let n=Ug({...Rg(t),name:e.name}),r=Object.fromEntries(Object.entries(n.components??{}).map(([t,n])=>[t,Jg(e,n,t)])),i=n.fields&&Object.fromEntries(Object.entries(n.fields).map(([t,n])=>[t,Xie(e,t,n)])),a=n.shell&&{...n.shell.actions&&{actions:Jg(e,n.shell.actions,`shell.actions`)},...n.shell.rightPanel&&{rightPanel:Jg(e,n.shell.rightPanel,`shell.rightPanel`)},...n.shell.logo&&{logo:Jg(e,n.shell.logo,`shell.logo`)}},o=n.beforeSignIn&&Jg(e,n.beforeSignIn,`beforeSignIn`);return{name:e.name,components:r,...n.actions&&{actions:n.actions},...n.dropRules&&{dropRules:n.dropRules},...n.boardDrops&&{boardDrops:n.boardDrops},...i&&{fields:i},...a&&{shell:a},...o&&{beforeSignIn:o}}},Yg={name:`@protobase/ui`,version:`0.39.0`,description:`The Protobase admin app and the React hooks and components for custom UI.`,license:`Apache-2.0`,repository:{type:`git`,url:`git+https://github.com/PrototeamHQ/protobase.git`,directory:`packages/ui`},homepage:`https://docs.protobase.net`,type:`module`,protobase:{pluginApi:1},sideEffects:[`*.css`,`./dist/app/main.js`],engines:{node:`>=22.12.0`},exports:{".":`./src/index.ts`,"./theme.css":`./src/theme.css`,"./styles.css":`./src/styles.css`},types:`./src/index.ts`,files:[`dist`],scripts:{build:`tsdown && protobase build-shell dist/shell --source-maps dist/shell-source-maps`,prepack:`tsdown && protobase build-shell dist/shell --source-maps dist/shell-source-maps`},publishConfig:{access:`public`,exports:{".":`./dist/index.js`,"./theme.css":`./dist/theme.css`,"./styles.css":`./dist/styles.css`},types:`./dist/index.d.ts`},dependencies:{"@dnd-kit/core":`^6.3.1`,"@dnd-kit/sortable":`^10.0.0`,"@protobase/client":`workspace:*`,"@protobase/layout":`workspace:*`,"@protobase/schema":`workspace:*`,"@sentry/browser":`^11.7.0`,"@tanstack/react-query":`^5.104.1`,"@tanstack/react-table":`^9.2.6`,"altcha-lib":`^2.6.0`,dompurify:`^3.4.17`,fflate:`^0.8.3`,"lucide-react":`^1.52.0`,"maplibre-gl":`^6.14.0`,marked:`^18.1.1`,pmtiles:`^4.5.0`,react:`^19.3.0`,"react-dom":`^19.3.0`,"react-map-gl":`^8.1.3`,recharts:`^3.10.1`,tailwindcss:`^4.3.3`,thumbhash:`^0.1.1`,uqr:`^0.1.3`}},Xg=Yg.protobase.pluginApi,Zg=Yg.version,Qie={readJson:async e=>{let t=await fetch(e,{cache:`no-cache`,credentials:`same-origin`});return t.ok?{json:await t.json()}:{status:t.status}},addStylesheet:e=>{if([...document.querySelectorAll(`link[rel="stylesheet"]`)].some(t=>t.href===e))return;let t=document.createElement(`link`);t.rel=`stylesheet`,t.href=e,document.head.append(t)},importModule:e=>m(()=>import(e),[])},$ie={api:Xg,version:Zg},eae=e=>e instanceof Error?e.message:String(e),tae=async(e,t,n,r=$ie)=>{let i=new URL(e.url,n).href,a=(e,t)=>({kind:`off`,url:i,...t&&{name:t},reason:e}),o;try{let n=await t.readJson(i);if(`status`in n)return a(Gg(`answered`,n.status));let s=qie(n.json);if(`problem`in s)return a(s.problem);let{manifest:c}=s;o=c.name;let l=mr(c,r);if(l)return a(l,o);c.css&&t.addStylesheet(new URL(c.css,i).href);let u=await t.importModule(new URL(c.entry,i).href),d={name:o,...c.version&&{version:c.version},url:i,settings:e.settings??{}};return{kind:`loaded`,plugin:d,ui:Zie(d,u)}}catch(e){return a(Gg(`couldNotLoad`,eae(e)),o)}},nae=e=>{let t=new Map;return{load:n=>{let r=JSON.stringify(n),i=t.get(r);if(i)return i;let a=tae(n,e,window.location.href);return t.set(r,a),a}}},Qg=(0,L.createContext)(null),rae=({loader:e=Qie,children:t})=>{let n=(0,L.useMemo)(()=>nae(e),[e]);return(0,z.jsx)(Qg.Provider,{value:n,children:t})},$g=()=>{let e=(0,L.useContext)(Qg);if(!e)throw Error(`usePluginSource must be used inside PluginSourceProvider`);return e},e_=1e4,t_=[],n_=(e,t)=>{let n=JSON.stringify(e),[r,i]=(0,L.useState)({key:`[]`,loads:t_,settled:!0});return(0,L.useEffect)(()=>{if(e.length===0)return;let r=!0,a=!1,o=e.map(()=>void 0),s=()=>{if(!r)return;let t=o.filter(e=>e!==void 0);i({key:n,loads:t,settled:a||t.length===e.length})},c=setTimeout(()=>{a=!0,s()},e_);return e.forEach((e,n)=>{t.load(e).then(e=>{o[n]=e,s()})}),()=>{r=!1,clearTimeout(c)}},[n,t]),e.length===0?{loads:t_,settled:!0}:r.key===n?r:{loads:t_,settled:!1}},iae=({children:e})=>{let{state:t,beforeSignIn:n,adoptSession:r}=xf(),{path:i,params:a,navigate:o}=Pm(),{loads:s,settled:c}=n_(n,$g()),l=(0,L.useMemo)(()=>Wg(void 0,s).ui.beforeSignIn,[s]),u=(0,L.useCallback)(e=>{let t=new URLSearchParams(a);for(let n of e)t.delete(n);o(t.size>0?`${i}?${t}`:i,{replace:!0})},[i,a,o]);return t.kind!==`signed-out`&&t.kind!==`visitor`?e:c?l?(0,z.jsx)(Lg,{name:`beforeSignIn`,fallback:e,children:(0,z.jsx)(l,{signedIn:r,params:a,removeParams:u,children:e})}):e:(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,Gg(`loading`)]})},aae=()=>{let e=window.location.href,t=lie(e);if(t)return{kind:`reset-password`,token:t.token};let n=kie(e);if(n)return{kind:`staff-sign-in`,link:n};let r=Iie(e);if(r)return{kind:`invitation`,token:r.token};let i=hf(e);if(i)return{kind:`provider-sign-in`,provider:i};let a=gf(e);return a?{kind:`sign-in`,providerError:a}:{kind:`sign-in`}},r_=({to:e})=>{let{navigate:t}=Pm();return(0,L.useEffect)(()=>t(e,{replace:!0}),[t,e]),null},i_=({workspace:e,children:t})=>{let n=a_(e,t);return(0,z.jsx)(iae,{children:n})},a_=(e,t)=>{let{state:n,recheck:r,passwordReset:i,signOut:a,signInProviders:o,canSignUp:s,browse:c}=xf(),{path:l,params:u,basePath:d,navigate:f}=Pm(),{address:p,next:m,open:h,link:g,leave:_}=Vm(),[v,y]=(0,L.useState)(aae),[b,x]=(0,L.useState)(),[S,C]=(0,L.useState)(),[w,T]=(0,L.useState)(),E=new URL(`${d}${l}${u.size>0?`?${u}`:``}`,window.location.origin).href,D=(0,L.useCallback)(e=>{let t=e(E).slice(d.length);f(t.startsWith(`/`)?t:`/${t}`,{replace:!0})},[E,d,f]),O=n.kind===`signed-in`||n.kind===`two-factor`||n.kind===`setup-required`;(0,L.useEffect)(()=>{O&&(v.kind===`provider-sign-in`&&D(_f),(v.kind===`provider-sign-in`||v.kind===`sign-in`&&(v.notice||v.error||v.providerError))&&y({kind:`sign-in`}),x(void 0),C(void 0),T(void 0))},[O,v,D]);let k=p!==void 0&&gf(E)!==void 0;(0,L.useEffect)(()=>{!O&&v.kind===`sign-in`&&v.providerError&&k&&D(_f)},[O,v,k,D]);let A=(0,L.useCallback)(e=>y({kind:`sign-in`,error:e}),[]),j=e=>{D(uie),y(e)},M=async()=>{n.kind===`signed-in`&&await a(),j({kind:`sign-in`,notice:B(`passwordChanged`)})},N=()=>{y({kind:`sign-in`}),a().then(()=>h(`sign-in`,{replace:!0}))};switch(n.kind){case`loading`:return(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,B(`loading`)]});case`error`:return(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B(`cannotReach`,n.message)}),(0,z.jsx)(V,{onClick:r,children:B(`tryAgain`)})]});case`needs-admin`:return(0,z.jsx)(oie,{onCheckAgain:r})}if(n.kind===`signed-in`&&p)return(0,z.jsx)(r_,{to:m??`/`});if(v.kind===`reset-password`)return(0,z.jsx)(gie,{token:v.token,onDone:()=>void M(),onRequestNewLink:i?()=>{y({kind:`sign-in`}),f(Fs({step:`forgot-password`}),{replace:!0})}:void 0,onBack:()=>j({kind:`sign-in`})});if(v.kind===`staff-sign-in`)return(0,z.jsx)(Mie,{link:v.link,onBack:()=>{D(bg),y({kind:`sign-in`})}});let P=n.kind===`signed-out`||n.kind===`visitor`;if(v.kind===`invitation`&&(n.kind===`signed-in`||P&&!p))return(0,z.jsx)(Vie,{token:v.token,onDone:()=>{D(Lie),y({kind:`sign-in`})},signIn:g()});if(n.kind===`signed-in`)return t;if(n.kind===`two-factor`)return(0,z.jsx)(Fie,{methods:n.methods,onBack:N});if(n.kind===`setup-required`)return(0,z.jsx)(yie,{missing:n.missing},n.missing.join());if(v.kind===`provider-sign-in`)return(0,z.jsx)(pie,{provider:v.provider,workspace:e,onFailed:A});let ee=v.kind===`sign-in`?v:{kind:`sign-in`};if(!p){let e=ee.notice||ee.error||ee.providerError;return n.kind===`visitor`&&!e?t:(0,z.jsx)(r_,{to:Fs({next:m})})}let te={"sign-in":!0,"forgot-password":i,"email-code":b!==void 0,"sign-up":s,"sign-up-code":s&&S!==void 0,"sign-up-details":s&&w!==void 0}[p.step]?p.step:`sign-in`,ne=e=>()=>h(e,{replace:!0}),re=c&&(()=>{c(),_()});if(te===`forgot-password`)return(0,z.jsx)(die,{back:g(`sign-in`,{replace:!0})});if(te===`email-code`)return(0,z.jsx)(iie,{email:b,onBack:ne(`sign-in`)});if(te===`sign-up`||te===`sign-up-code`||te===`sign-up-details`)return(0,z.jsx)(Oie,{workspace:e,email:te===`sign-up`?void 0:S,ticket:te===`sign-up-details`?w:void 0,onCodeSent:e=>{C(e),T(void 0),h(`sign-up-code`)},onVerified:e=>{T(e),h(`sign-up-details`,{replace:!0})},onBack:ne(`sign-up`),onSignIn:()=>h(`sign-in`),onBrowse:re},te);let ie=ee.providerError&&ff(ee.providerError,o.length===1?o[0].name:`the provider`),ae=ee.error??ie;return(0,z.jsx)(wie,{workspace:e,notice:ee.notice,error:ae,forgotPassword:i?g(`forgot-password`):void 0,onCodeSent:e=>{x(e),h(`email-code`)},signUp:s?g(`sign-up`):void 0,onBrowse:re},ae)},o_=e=>[...e].reduce((e,t)=>(e*31+t.charCodeAt(0))%360,7),s_=e=>e.split(/[\s@.]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join(``),c_=e=>(e.role??`user`).split(`,`).map(e=>e.trim()),l_=e=>c_(e).includes(`admin`),u_=e=>{let t=c_(e),n=t.includes(`admin`);return{name:e.name||e.email,email:e.email,initials:s_(e.name||e.email)||`?`,hue:o_(e.id||e.email),role:n?B(`admin`):(t[0]??`user`).replace(/^./,e=>e.toUpperCase()),roleTone:n?`violet`:`blue`}},oae=3e4,sae=(e,t=Date.now())=>Math.max(1e3,xu(e)-t-oae),d_=()=>{let{state:e,session:t}=xf(),n=e.kind===`signed-in`,[r,i]=(0,L.useState)();return(0,L.useEffect)(()=>{if(!n)return;let e=!0,r,a=async n=>{let o=await t.token(),s=o!==void 0&&o===n?await t.token({refresh:!0}):o;e&&(i(s),s&&(r=setTimeout(()=>void a(s),sae(s))))};return a(),()=>{e=!1,clearTimeout(r)}},[t,n]),n?r:void 0},cae=({children:e})=>(0,z.jsx)(ag,{locale:xf().locale,children:e}),lae=(e,t)=>{let n=new Set,r,i=()=>{r=void 0;let i=new Set(n);n.clear();let a=e=>i.has(e[1]);e.invalidateQueries({predicate:e=>a(e.queryKey)&&e.queryKey[0]!==`record`}),e.invalidateQueries({predicate:e=>a(e.queryKey)&&e.queryKey[0]===`record`,refetchType:t()?`none`:`active`})};return{changed:e=>{for(let t of e)n.add(t);n.size>0&&!r&&(r=setTimeout(i,300))},stop:()=>clearTimeout(r)}},uae=e=>{let t=W(),n=Km(),r=(0,L.useContext)(Yh),i=(0,L.useMemo)(()=>Object.values(e.resources).filter(t=>t.live&&!ig(e,t.name)).map(e=>e.name).sort().join(`,`),[e]);(0,L.useEffect)(()=>{if(!i)return;let e=lae(n,()=>r?.paused()??!1),a=t.live({onChanges:t=>e.changed(t.map(e=>e.resource)),onResync:()=>e.changed(i.split(`,`))});return()=>{a(),e.stop()}},[t,n,r,i])},f_=(e,t,n=!0)=>{let r=W(),i=sr(t);return Kh({queryKey:U.record(e,i),enabled:n,queryFn:()=>r.get(e,t)})},p_=(e,t,n=!0)=>{let r=W(),i=Km(),a=sr(t);return Kh({queryKey:U.record(e,a),enabled:n,queryFn:()=>r.get(e,t),placeholderData:()=>i.getQueryData(U.recordPreview(e,a))})},m_=e=>e.charAt(0).toUpperCase()+e.slice(1),q=e=>m_(e.replace(/(Id|Code|_id|_code)$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/_+/g,` `).trim().toLowerCase()||e);function h_(){var e=[...arguments];return(0,L.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var g_=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function __(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function v_(e){return`nodeType`in e}function y_(e){return e?__(e)?e:v_(e)?e.ownerDocument?.defaultView??window:window:window}function b_(e){let{Document:t}=y_(e);return e instanceof t}function x_(e){return!__(e)&&e instanceof y_(e).HTMLElement}function S_(e){return e instanceof y_(e).SVGElement}function C_(e){return e?__(e)?e.document:v_(e)?b_(e)?e:x_(e)||S_(e)?e.ownerDocument:document:document:document}var w_=g_?L.useLayoutEffect:L.useEffect;function T_(e){let t=(0,L.useRef)(e);return w_(()=>{t.current=e}),(0,L.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function dae(){let e=(0,L.useRef)(null);return[(0,L.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,L.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function E_(e,t){t===void 0&&(t=[e]);let n=(0,L.useRef)(e);return w_(()=>{n.current!==e&&(n.current=e)},t),n}function D_(e,t){let n=(0,L.useRef)();return(0,L.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function O_(e){let t=T_(e),n=(0,L.useRef)(null);return[n,(0,L.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function k_(e){let t=(0,L.useRef)();return(0,L.useEffect)(()=>{t.current=e},[e]),t.current}var A_={};function j_(e,t){return(0,L.useMemo)(()=>{if(t)return t;let n=A_[e]==null?0:A_[e]+1;return A_[e]=n,e+`-`+n},[e,t])}function M_(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var N_=M_(1),P_=M_(-1);function F_(e){return`clientX`in e&&`clientY`in e}function I_(e){if(!e)return!1;let{KeyboardEvent:t}=y_(e.target);return t&&e instanceof t}function L_(e){if(!e)return!1;let{TouchEvent:t}=y_(e.target);return t&&e instanceof t}function R_(e){if(L_(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return F_(e)?{x:e.clientX,y:e.clientY}:null}var z_=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[z_.Translate.toString(e),z_.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),B_=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function V_(e){return e.matches(B_)?e:e.querySelector(B_)}var H_={display:`none`};function U_(e){let{id:t,value:n}=e;return L.createElement(`div`,{id:t,style:H_},n)}function W_(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return L.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function G_(){let[e,t]=(0,L.useState)(``);return{announce:(0,L.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var K_=(0,L.createContext)(null);function q_(e){let t=(0,L.useContext)(K_);(0,L.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function J_(){let[e]=(0,L.useState)(()=>new Set),t=(0,L.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,L.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Y_={draggable:`
|
|
8
8
|
To pick up a draggable item, press the space bar.
|
|
9
9
|
While dragging, use the arrow keys to move the item.
|
|
10
10
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
@@ -64,7 +64,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
64
64
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bde(e,t){if(e){if(typeof e==`string`)return O$(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O$(e,t):void 0}}function O$(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Vde(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Hde(e){if(Array.isArray(e))return e}function Ude(e,t){if(e==null)return{};var n,r,i=Wde(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Wde(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function k$(){return k$=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},k$.apply(null,arguments)}function A$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function j$(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?A$(Object(n),!0).forEach(function(t){Gde(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A$(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Gde(e,t,n){return(t=Kde(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kde(e){var t=qde(e,`string`);return typeof t==`symbol`?t:t+``}function qde(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var M$={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:`bottom`,ticks:[],stroke:`#666`,tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:`preserveEnd`,zIndex:qF.axis};function Jde(e){var t=e.x,n=e.y,r=e.width,i=e.height,a=e.orientation,o=e.mirror,s=e.axisLine,c=e.otherSvgProps;if(!s)return null;var l=j$(j$(j$({},c),bE(s)),{},{fill:`none`});if(a===`top`||a===`bottom`){var u=+(a===`top`&&!o||a===`bottom`&&o);l=j$(j$({},l),{},{x1:t,y1:n+u*i,x2:t+r,y2:n+u*i})}else{var d=+(a===`left`&&!o||a===`right`&&o);l=j$(j$({},l),{},{x1:t+d*r,y1:n,x2:t+d*r,y2:n+i})}return L.createElement(`line`,k$({},l,{className:mE(`recharts-cartesian-axis-line`,HE(s,`className`))}))}function Yde(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h=s?-1:1,g=e.tickSize||o,_=Y(e.tickCoord)?e.tickCoord:e.coordinate;switch(a){case`top`:l=u=e.coordinate,f=n+ +!s*i,d=f-h*g,m=d-h*c,p=_;break;case`left`:d=f=e.coordinate,u=t+ +!s*r,l=u-h*g,p=l-h*c,m=_;break;case`right`:d=f=e.coordinate,u=t+ +s*r,l=u+h*g,p=l+h*c,m=_;break;default:l=u=e.coordinate,f=n+ +s*i,d=f+h*g,m=d+h*c,p=_}return{line:{x1:l,y1:d,x2:u,y2:f},tick:{x:p,y:m}}}function Xde(e,t){switch(e){case`left`:return t?`start`:`end`;case`right`:return t?`end`:`start`;default:return`middle`}}function Zde(e,t){switch(e){case`left`:case`right`:return`middle`;case`top`:return t?`start`:`end`;default:return t?`end`:`start`}}function Qde(e){var t=e.option,n=e.tickProps,r=e.value,i,a=mE(n.className,`recharts-cartesian-axis-tick-value`);if(L.isValidElement(t))i=L.cloneElement(t,j$(j$({},n),{},{className:a}));else if(typeof t==`function`)i=t(j$(j$({},n),{},{className:a}));else{var o=`recharts-cartesian-axis-tick-value`;typeof t!=`boolean`&&(o=mE(o,gX(t))),i=L.createElement(_Y,k$({},n,{className:o}),r)}return i}function $de(e){var t=e.ticks,n=e.axisType,r=e.axisId,i=Vk(),a=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(r!=null&&n!=null){var e=t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),o=a.current;o!=null&&o.axisId===r&&o.axisType===n&&Sde(o.ticks,e)||(a.current={ticks:e,axisId:r,axisType:n},i(Fde({ticks:e,axisId:r,axisType:n})))}},[i,t,r,n]),(0,L.useEffect)(()=>r==null||n==null?oD:()=>{i(Ide({axisId:r,axisType:n}))},[i,r,n]),null}var efe=(0,L.forwardRef)((e,t)=>{var n=e.ticks,r=n===void 0?[]:n,i=e.tick,a=e.tickLine,o=e.stroke,s=e.tickFormatter,c=e.unit,l=e.padding,u=e.tickTextProps,d=e.orientation,f=e.mirror,p=e.x,m=e.y,h=e.width,g=e.height,_=e.tickSize,v=e.tickMargin,y=e.fontSize,b=e.letterSpacing,x=e.getTicksConfig,S=e.events,C=e.axisType,w=e.axisId,T=w$(j$(j$({},x),{},{ticks:r}),y,b),E=bE(x),D=xE(i),O=oY(E.textAnchor)?E.textAnchor:Xde(d,f),k=Zde(d,f),A={};typeof a==`object`&&(A=a);var j=j$(j$({},E),{},{fill:`none`},A),M=T.map(e=>j$({entry:e},Yde(e,p,m,h,g,d,_,f,v))),N=M.map(e=>{var t=e.entry,n=e.line;return L.createElement(NE,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},a&&L.createElement(`line`,k$({},j,n,{className:mE(`recharts-cartesian-axis-tick-line`,HE(a,`className`))})))}),P=M.map((e,t)=>{var n=e.entry,r=e.tick,a=j$(j$({},j$(j$(j$(j$({verticalAnchor:k},E),{},{textAnchor:O,stroke:`none`,fill:o},r),{},{index:t,payload:n,visibleTicksCount:T.length,tickFormatter:s,padding:l},u),{},{angle:u?.angle??E.angle??0})),D);return L.createElement(NE,k$({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},yO(S,n,t)),i&&L.createElement(Qde,{option:i,tickProps:a,value:`${typeof s==`function`?s(n.value,t):n.value}${c||``}`}))});return L.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${C}-ticks`},L.createElement($de,{ticks:T,axisId:w,axisType:C}),P.length>0&&L.createElement(iq,{zIndex:qF.label},L.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${C}-tick-labels`,ref:t},P)),N.length>0&&L.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${C}-tick-lines`},N))}),tfe=(0,L.forwardRef)((e,t)=>{var n=e.axisLine,r=e.width,i=e.height,a=e.className,o=e.hide,s=e.ticks,c=e.axisType,l=e.axisId,u=Ude(e,Rde),d=D$((0,L.useState)(``),2),f=d[0],p=d[1],m=D$((0,L.useState)(``),2),h=m[0],g=m[1],_=(0,L.useRef)(null);(0,L.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>Nde({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin}),getCalculatedHeight:()=>Pde({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var v=(0,L.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);_.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==f||a!==h)&&(p(i),g(a))}}},[f,h]);return o||r!=null&&r<=0||i!=null&&i<=0?null:L.createElement(iq,{zIndex:e.zIndex},L.createElement(NE,{className:mE(`recharts-cartesian-axis`,a)},L.createElement(Jde,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:bE(e)}),L.createElement(efe,{ref:v,axisType:c,events:u,fontSize:f,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:l}),L.createElement(kY,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},L.createElement(WY,{label:e.label,labelRef:e.labelRef}),e.children)))}),N$=L.forwardRef((e,t)=>{var n=TO(e,M$);return L.createElement(tfe,k$({},n,{ref:t}))});N$.displayName=`CartesianAxis`;var P$=(0,L.createContext)({grid:{stroke:`#ccc`,fill:`none`}});P$.Provider;var nfe=()=>(0,L.useContext)(P$),rfe=[`x1`,`y1`,`x2`,`y2`,`key`],ife=[`offset`],afe=[`xAxisId`,`yAxisId`],ofe=[`xAxisId`,`yAxisId`];function F$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function I$(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?F$(Object(n),!0).forEach(function(t){sfe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):F$(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function sfe(e,t,n){return(t=cfe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cfe(e){var t=lfe(e,`string`);return typeof t==`symbol`?t:t+``}function lfe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function L$(){return L$=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},L$.apply(null,arguments)}function R$(e,t){if(e==null)return{};var n,r,i=ufe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ufe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var dfe=e=>{var t=e.fill;if(!t||t===`none`)return null;var n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.ry;return L.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function z$(e){var t=e.option,n=e.lineItemProps,r;if(L.isValidElement(t))r=L.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var i=n.x1,a=n.y1,o=n.x2,s=n.y2,c=n.key,l=bE(R$(n,rfe))??{};l.offset;var u=R$(l,ife),d=Array.isArray(u.strokeDasharray)?u.strokeDasharray.join(`,`):u.strokeDasharray;r=L.createElement(`line`,L$({},u,{strokeDasharray:d,x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function ffe(e){var t=e.x,n=e.width,r=e.horizontal,i=r===void 0||r,a=e.horizontalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=R$(e,afe),s=a.map((e,r)=>{var a=I$(I$({},o),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${r}`,index:r});return L.createElement(z$,{key:`line-${r}`,option:i,lineItemProps:a})});return L.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},s)}function pfe(e){var t=e.y,n=e.height,r=e.vertical,i=r===void 0||r,a=e.verticalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=R$(e,ofe),s=a.map((e,r)=>{var a=I$(I$({},o),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${r}`,index:r});return L.createElement(z$,{option:i,lineItemProps:a,key:`line-${r}`})});return L.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},s)}function mfe(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.horizontalPoints,c=e.horizontal;if(!(c===void 0||c)||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return L.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return L.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function hfe(e){var t=e.vertical,n=t===void 0||t,r=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,s=e.width,c=e.height,l=e.verticalPoints;if(!n||!r||!r.length)return null;var u=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==u[0]&&u.unshift(0);var d=u.map((e,t)=>{var n=u[t+1],l=n==null?a+s-e:n-e;if(l<=0)return null;var d=t%r.length;return L.createElement(`rect`,{key:`react-${t}`,x:e,y:o,width:l,height:c,stroke:`none`,fill:r[d],fillOpacity:i,className:`recharts-cartesian-grid-bg`})});return L.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},d)}var gfe=(e,t)=>{var n=e.xAxis,r=e.width,i=e.height,a=e.offset;return fM(w$(I$(I$(I$({},M$),n),{},{ticks:pM(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},_fe=(e,t)=>{var n=e.yAxis,r=e.width,i=e.height,a=e.offset;return fM(w$(I$(I$(I$({},M$),n),{},{ticks:pM(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},vfe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:qF.grid};function B$(e){var t=qM(),n=JM(),r=KM(),i=I$(I$({},TO(e,vfe)),{},{x:Y(e.x)?e.x:r.left,y:Y(e.y)?e.y:r.top,width:Y(e.width)?e.width:r.width,height:Y(e.height)?e.height:r.height}),a=i.xAxisId,o=i.yAxisId,s=i.x,c=i.y,l=i.width,u=i.height,d=i.syncWithTicks,f=i.horizontalValues,p=i.verticalValues,m=jM(),h=X(e=>OW(e,`xAxis`,a,m)),g=X(e=>OW(e,`yAxis`,o,m)),_=nfe(),v={stroke:i.stroke??_.grid.stroke,strokeWidth:i.strokeWidth??_.grid.strokeWidth,strokeOpacity:i.strokeOpacity??_.grid.strokeOpacity,strokeDasharray:i.strokeDasharray??_.grid.strokeDasharray};if(!sM(l)||!sM(u)||!Y(s)||!Y(c))return null;var y=i.verticalCoordinatesGenerator||gfe,b=i.horizontalCoordinatesGenerator||_fe,x=i.horizontalPoints,S=i.verticalPoints;if((!x||!x.length)&&typeof b==`function`){var C=f&&f.length,w=b({yAxis:g?I$(I$({},g),{},{ticks:C?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},C?!0:d);PM(Array.isArray(w),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof w}]`),Array.isArray(w)&&(x=w)}if((!S||!S.length)&&typeof y==`function`){var T=p&&p.length,E=y({xAxis:h?I$(I$({},h),{},{ticks:T?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},T?!0:d);PM(Array.isArray(E),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof E}]`),Array.isArray(E)&&(S=E)}return L.createElement(iq,{zIndex:i.zIndex},L.createElement(`g`,{className:`recharts-cartesian-grid`},L.createElement(dfe,{fill:i.fill??_.grid.fill,fillOpacity:i.fillOpacity??_.grid.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),L.createElement(mfe,L$({},i,{horizontalPoints:x})),L.createElement(hfe,L$({},i,{verticalPoints:S})),L.createElement(ffe,L$({},i,v,{offset:r,horizontalPoints:x,xAxis:h,yAxis:g})),L.createElement(pfe,L$({},i,v,{offset:r,verticalPoints:S,xAxis:h,yAxis:g}))))}B$.displayName=`CartesianGrid`;var yfe=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function V$(){return V$=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},V$.apply(null,arguments)}function bfe(e,t){if(e==null)return{};var n,r,i=xfe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function xfe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Sfe(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function H$(e,t){return`${t}px ${e}px`}function Cfe(e){return e.length%2==0?e:[...e,...e]}function wfe(e,t){for(var n=[],r=0;r<t;++r)n.push(...e);return n}function Tfe(e,t,n){var r=Cfe(n),i=r.reduce((e,t)=>e+t,0);if(!i)return H$(t,e);for(var a=Math.floor(e/i),o=e%i,s=[],c=0,l=0;c<r.length;l+=(u=r[c])??0,++c){var u,d=r[c];if(d!=null&&l+d>o){s=[...r.slice(0,c),o-l];break}}var f=s.length%2==0?[0,t]:[t];return[...wfe(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function Efe(e,t,n){return e?Tfe(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):H$(t,n)}function Dfe(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=bfe(e,yfe),a=r??!1,o;if(t!=null){var s=i.pathRef;o=Efe(n,Sfe(s?.current??null),t)}else n!=null&&(o=String(n));return L.createElement(jN,V$({},i,{connectNulls:a,strokeDasharray:o}))}function Ofe(e){var t=(0,L.useRef)(0),n=(0,L.useRef)(0),r=(0,L.useRef)(!1),i=(0,L.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,L.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(GE(t.current+e*i),i);return e>0&&i>0&&(n.current=Math.max(n.current,a),a>=i)?(r.current=!0,null):a},[])}var U$=Aj({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]||(e[r]=[]),e[r].push(i)},replaceErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.prev,a=n.next;e[r]&&(e[r]=e[r].map(e=>e.dataKey===i.dataKey&&e.direction===i.direction?a:e))},removeErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]&&(e[r]=e[r].filter(e=>e.dataKey!==i.dataKey||e.direction!==i.direction))}}}),W$=U$.actions;W$.addErrorBar,W$.replaceErrorBar,W$.removeErrorBar;var kfe=U$.reducer,Afe=[`children`];function jfe(e,t){if(e==null)return{};var n,r,i=Mfe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Mfe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Nfe=(0,L.createContext)({data:[],xAxisId:`xAxis-0`,yAxisId:`yAxis-0`,dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function G$(e){var t=e.children,n=jfe(e,Afe);return L.createElement(Nfe.Provider,{value:n},t)}function K$(e,t){var n=X(t=>kH(t,e)),r=X(e=>MH(e,t)),i=n?.allowDataOverflow??DH.allowDataOverflow,a=r?.allowDataOverflow??AH.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function q$(e){var t=e.xAxisId,n=e.yAxisId,r=e.clipPathId,i=ZQ(),a=K$(t,n),o=a.needClipX,s=a.needClipY,c=a.needClip,l=X(e=>nW(e,t,!1)),u=X(e=>rW(e,n,!1));if(!c||!i)return null;var d=i.x,f=i.y,p=i.width,m=i.height,h=o&&l?Math.min(l[0],l[1]):d-p/2,g=s&&u?Math.min(u[0],u[1]):f-m/2,_=o&&l?Math.abs(l[1]-l[0]):p*2,v=s&&u?Math.abs(u[1]-u[0]):m*2;return L.createElement(`clipPath`,{id:`clipPath-${r}`},L.createElement(`rect`,{x:h,y:g,width:_,height:v}))}var J$=(e,t,n,r)=>jW(e,`xAxis`,t,r),Y$=(e,t,n,r)=>AW(e,`xAxis`,t,r),X$=(e,t,n,r)=>jW(e,`yAxis`,n,r),Z$=(e,t,n,r)=>AW(e,`yAxis`,n,r),Pfe=Z([YM,J$,X$,Y$,Z$],(e,t,n,r,i)=>dM(e,`xAxis`)?vM(t,r,!1):vM(n,i,!1)),Ffe=(e,t,n,r,i)=>i;function Ife(e){return e.type===`line`}var Lfe=Z([YM,J$,X$,Y$,Z$,Z([BH,Ffe],(e,t)=>e.filter(Ife).find(e=>e.id===t)),Pfe,oF],(e,t,n,r,i,a,o,s)=>{var c=s.chartData,l=s.dataStartIndex,u=s.dataEndIndex;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var d=a.dataKey,f=a.data,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return ipe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Rfe(e){var t=xE(e),n=3,r=2;if(t!=null){var i=t.r,a=t.strokeWidth,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var zfe=[`id`],Bfe=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],Vfe=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function Q$(){return Q$=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Q$.apply(null,arguments)}function $$(e,t){if(e==null)return{};var n,r,i=Hfe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Hfe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function e1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function t1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?e1(Object(n),!0).forEach(function(t){Ufe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):e1(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ufe(e,t,n){return(t=Wfe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wfe(e){var t=Gfe(e,`string`);return typeof t==`symbol`?t:t+``}function Gfe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Kfe(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function qfe(e){var t=0,n=0;for(var r of e)r.status===`matched`&&r.prev.x!=null&&r.next.x!=null&&(t+=r.next.x-r.prev.x,n++);return n>0?t/n:0}var n1={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationInterpolateFn:(e,t)=>{if(e==null)return[];if(t===1)return e.flatMap(e=>e.status===`removed`?[]:[e.next]);var n=qfe(e),r=[];for(var i of e)if(i.status===`matched`)r.push(t1(t1({},i.next),{},{x:tD(i.prev.x,i.next.x,t),y:tD(i.prev.y,i.next.y,t)}));else if(i.status===`added`){if(i.next.x!=null){var a=i.next.x-n;r.push(t1(t1({},i.next),{},{x:tD(a,i.next.x,t),y:i.next.y}))}else r.push(i.next)}else if(i.status===`removed`&&i.prev.x!=null){var o=i.prev.x+n;r.push(t1(t1({},i.prev),{},{x:tD(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:aZ,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:Dfe,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:qF.line,type:`linear`},Jfe=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:bM(n,t),payload:e}]},Yfe=L.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:oD,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:bM(o,t),hide:s,type:u,color:r,unit:c,formatter:l,graphicalItemId:d}};return L.createElement(XX,{tooltipEntrySettings:f})});function Xfe(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=bE($$(r,zfe));return L.createElement(NQ,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:s,needClip:o,clipPathId:t})}function Zfe(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,L.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return t1(t1({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return L.createElement(QY,{value:t?i:void 0},n)}function Qfe(e){var t=e.clipPathId,n=e.pathRef,r=e.points,i=e.props,a=e.animationElapsedTime,o=e.isAnimating,s=e.isEntrance,c=e.visibleLength,l=i.type,u=i.layout,d=i.connectNulls,f=i.needClip,p=i.shape,m=i.strokeDasharray,h=t1(t1({},SE($$(i,Bfe))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:f?`url(#clipPath-${t})`:void 0,points:r,type:l,layout:u,connectNulls:d,strokeDasharray:m??i.strokeDasharray,pathRef:n,animationElapsedTime:a,isAnimating:o,isEntrance:i.animateNewValues?s:!1,visibleLength:c});return L.createElement(L.Fragment,null,r?.length>1&&L.createElement(KX,{option:p,DefaultShape:n1.shape,shapeProps:h}),L.createElement(Xfe,{points:r,clipPathId:t,props:i}))}function $fe(e){var t=e.clipPathId,n=e.props,r=e.pathRef,i=e.previousPointsRef,a=n.points,o=n.isAnimationActive,s=n.animationBegin,c=n.animationDuration,l=n.animationEasing,u=n.animationMatchBy,d=n.animationInterpolateFn,f=n.layout,p=Kfe(r.current),m=bZ(n.onAnimationStart,n.onAnimationEnd),h=m.isAnimating,g=m.handleAnimationStart,_=m.handleAnimationEnd,v=!h,y=Ofe(a),b=(0,L.useCallback)(e=>e>0&&p>0,[p]);return L.createElement(Zfe,{points:a,showLabels:v},n.children,L.createElement(xZ,{animationInput:a,animationIdPrefix:`recharts-line-`,items:a,previousItemsRef:i,isAnimationActive:o,animationBegin:s,animationDuration:c,animationEasing:l,onAnimationStart:g,onAnimationEnd:_,animationInterpolateFn:d,animationMatchBy:u,shouldUpdatePreviousRef:b,layout:f},(e,i,a)=>{var o=h||i<1,s=o?y(i,p):null;return L.createElement(Qfe,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),L.createElement(iX,{label:n.label}))}function epe(e){var t=e.clipPathId,n=e.props,r=(0,L.useRef)(null),i=(0,L.useRef)(null);return L.createElement($fe,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var tpe=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:uM(e.payload,t)}),npe=class extends L.Component{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.xAxisId,o=e.yAxisId,s=e.top,c=e.left,l=e.width,u=e.height,d=e.id,f=e.needClip,p=e.zIndex;if(t)return null;var m=mE(`recharts-line`,i),h=d,g=Rfe(n),_=g.r,v=g.strokeWidth,y=FX(n),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${h})`:void 0;return L.createElement(iq,{zIndex:p},L.createElement(NE,{className:m},f&&L.createElement(`defs`,null,L.createElement(q$,{clipPathId:h,xAxisId:a,yAxisId:o}),!y&&L.createElement(`clipPath`,{id:`clipPath-dots-${h}`},L.createElement(`rect`,{x:c-b/2,y:s-b/2,width:l+b,height:u+b}))),L.createElement(G$,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:tpe,errorBarOffset:0},L.createElement(epe,{props:this.props,clipPathId:h}))),L.createElement(a$,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}};function rpe(e){var t=TO(e,n1),n=t.activeDot,r=t.animateNewValues,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.connectNulls,c=t.dot,l=t.hide,u=t.isAnimationActive,d=t.label,f=t.legendType,p=t.xAxisId,m=t.yAxisId,h=t.id,g=$$(t,Vfe),_=K$(p,m).needClip,v=ZQ(),y=XM(),b=jM(),x=X(e=>Lfe(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var S=v.height,C=v.width,w=v.x,T=v.y;return L.createElement(npe,Q$({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function ipe(e){var t=e.layout,n=e.xAxis,r=e.yAxis,i=e.xAxisTicks,a=e.yAxisTicks,o=e.dataKey,s=e.bandSize;return e.displayedData.map((e,c)=>{var l=uM(e,o);if(t===`horizontal`)return{x:mM({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(rD(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=rD(l)?null:n.scale.map(l),d=mM({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function ape(e){var t=TO(e,n1),n=jM();return L.createElement(jZ,{id:t.id,type:`line`},e=>L.createElement(L.Fragment,null,L.createElement(ZX,{legendPayload:Jfe(t)}),L.createElement(Yfe,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),L.createElement(VZ,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),L.createElement(rpe,Q$({},t,{id:e}))))}var r1=L.memo(ape,sN);r1.displayName=`Line`;function i1(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function a1(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var ope=`Invariant failed`;function spe(e,t){if(!e)throw Error(ope)}var cpe=[`option`];function lpe(e,t){if(e==null)return{};var n,r,i=upe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function upe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var o1=CP;function s1(e){var t=e.option,n=lpe(e,cpe);return L.createElement(KX,{option:t,DefaultShape:o1,shapeProps:n,activeClassName:`recharts-active-bar`,inActiveClassName:`recharts-inactive-bar`})}var dpe=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(n,r)=>{if(Y(e))return e;var i=Y(n)||rD(n);return i?e(n,r):(!i&&spe(!1,`minPointSize callback function received a value with type of ${typeof n}. Currently only numbers or null/undefined are supported.`),t)}},fpe=(e,t,n)=>n,c1=Z([BH,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`bar`).find(e=>e.id===t)),ppe=Z([c1],e=>e?.maxBarSize),mpe=(e,t,n,r)=>r,hpe=Z([YM,BH,i1,a1,fpe],(e,t,n,r,i)=>t.filter(t=>e===`horizontal`?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===i).filter(e=>e.hide===!1).filter(e=>e.type===`bar`)),gpe=(e,t,n)=>{var r=YM(e),i=i1(e,t),a=a1(e,t);if(i!=null&&a!=null)return r===`horizontal`?fU(e,`yAxis`,a,n):fU(e,`xAxis`,i,n)},_pe=Z([hpe,BF,(e,t)=>{var n=YM(e),r=i1(e,t),i=a1(e,t);if(r!=null&&i!=null)return n===`horizontal`?TW(e,`xAxis`,r):TW(e,`yAxis`,i)}],ede),vpe=(e,t,n)=>{var r=c1(e,t);if(r==null)return 0;var i=i1(e,t),a=a1(e,t);if(i==null||a==null)return 0;var o=YM(e),s=LF(e),c=r.maxBarSize,l=rD(c)?s:c,u,d;return o===`horizontal`?(u=jW(e,`xAxis`,i,n),d=AW(e,`xAxis`,i,n)):(u=jW(e,`yAxis`,a,n),d=AW(e,`yAxis`,a,n)),vM(u,d,!0)??l??0},l1=(e,t,n)=>{var r=YM(e),i=i1(e,t),a=a1(e,t);if(i!=null&&a!=null){var o,s;return r===`horizontal`?(o=jW(e,`xAxis`,i,n),s=AW(e,`xAxis`,i,n)):(o=jW(e,`yAxis`,a,n),s=AW(e,`yAxis`,a,n)),vM(o,s)}},ype=Z([kM,AM,(e,t,n)=>{var r=i1(e,t);if(r!=null)return jW(e,`xAxis`,r,n)},(e,t,n)=>{var r=a1(e,t);if(r!=null)return jW(e,`yAxis`,r,n)},(e,t,n)=>{var r=i1(e,t);if(r!=null)return AW(e,`xAxis`,r,n)},(e,t,n)=>{var r=a1(e,t);if(r!=null)return AW(e,`yAxis`,r,n)},Z([Z([_pe,LF,RF,zF,vpe,l1,ppe],ade),c1],sde),YM,sF,l1,Z([gpe,c1],ode),c1,mpe],(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{var p=c.chartData,m=c.dataStartIndex,h=c.dataEndIndex;if(!(d==null||o==null||t==null||s!==`horizontal`&&s!==`vertical`||n==null||r==null||i==null||a==null||l==null)){var g=d.data,_=g!=null&&g.length>0?g:p?.slice(m,h+1);if(_!=null)return Qpe({layout:s,barSettings:d,pos:o,parentViewBox:t,bandSize:l,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:_,offset:e,cells:f,dataStartIndex:m})}}),bpe=[`index`];function u1(){return u1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u1.apply(null,arguments)}function xpe(e,t){if(e==null)return{};var n,r,i=Spe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Spe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var d1=(0,L.createContext)(void 0),Cpe=e=>{var t=(0,L.useContext)(d1);if(t!=null)return t.stackId;if(e!=null)return kce(e)},wpe=(e,t)=>`recharts-bar-stack-clip-path-${e}-${t}`,Tpe=e=>{var t=(0,L.useContext)(d1);if(t!=null){var n=t.stackId;return`url(#${wpe(n,e)})`}},f1=e=>{var t=e.index,n=xpe(e,bpe),r=Tpe(t);return L.createElement(NE,u1({className:`recharts-bar-stack-layer`,clipPath:r},n))},Epe=[`onMouseEnter`,`onMouseLeave`,`onClick`],Dpe=[`value`,`background`,`tooltipPosition`],Ope=[`id`],kpe=[`onMouseEnter`,`onClick`,`onMouseLeave`];function p1(e,t){return Npe(e)||Mpe(e,t)||jpe(e,t)||Ape()}function Ape(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
65
65
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jpe(e,t){if(e){if(typeof e==`string`)return m1(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m1(e,t):void 0}}function m1(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Mpe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Npe(e){if(Array.isArray(e))return e}function h1(){return h1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},h1.apply(null,arguments)}function g1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?g1(Object(n),!0).forEach(function(t){Ppe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g1(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ppe(e,t,n){return(t=Fpe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Fpe(e){var t=Ipe(e,`string`);return typeof t==`symbol`?t:t+``}function Ipe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v1(e,t){if(e==null)return{};var n,r,i=Lpe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Lpe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Rpe=e=>{var t=e.dataKey,n=e.name,r=e.fill,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:bM(n,t),payload:e}]},zpe=L.memo(e=>{var t=e.dataKey,n=e.stroke,r=e.strokeWidth,i=e.fill,a=e.name,o=e.hide,s=e.unit,c=e.formatter,l=e.tooltipType,u=e.id,d={dataDefinedOnItem:void 0,getPosition:oD,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:bM(a,t),hide:o,type:l,color:i,unit:s,formatter:c,graphicalItemId:u}};return L.createElement(XX,{tooltipEntrySettings:d})});function Bpe(e){var t=X(eK),n=e.data,r=e.dataKey,i=e.background,a=e.allOtherBarProps,o=a.onMouseEnter,s=a.onMouseLeave,c=a.onClick,l=v1(a,Epe),u=qX(o,r,a.id),d=JX(s),f=YX(c,r,a.id);if(!i||n==null)return null;var p=xE(i);return L.createElement(iq,{zIndex:cde(i,qF.barBackground)},n.map((e,n)=>{e.value;var a=e.background;e.tooltipPosition;var o=v1(e,Dpe);if(!a)return null;var s=u(e,e.originalDataIndex),c=d(e,e.originalDataIndex),m=f(e,e.originalDataIndex),h=_1(_1(_1(_1(_1({option:i,isActive:String(e.originalDataIndex)===t},o),{},{fill:`#eee`},a),p),yO(l,e,n)),{},{onMouseEnter:s,onMouseLeave:c,onClick:m,dataKey:r,index:n,className:`recharts-bar-background-rectangle`});return L.createElement(s1,h1({key:`background-bar-${n}`},h))}))}function Vpe(e){var t=e.showLabels,n=e.children,r=e.rects?.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return _1(_1({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return L.createElement(QY,{value:t?r:void 0},n)}function Hpe(e){var t=e.shape,n=e.activeBar,r=e.baseProps,i=e.entry,a=e.index,o=e.dataKey,s=X(eK),c=X(nK),l=n&&String(i.originalDataIndex)===s&&(c==null||o===c),u=s!=null&&(String(i.originalDataIndex)!==s||c!=null&&o!==c),d=p1((0,L.useState)(!1),2),f=d[0],p=d[1],m=p1((0,L.useState)(!1),2),h=m[0],g=m[1];(0,L.useEffect)(()=>{var e;return l?(p(!0),e=requestAnimationFrame(()=>{g(!0)})):(g(!1),u&&p(!1)),()=>{cancelAnimationFrame(e)}},[l,u]);var _=(0,L.useCallback)(()=>{l||p(!1)},[l]),v=l&&h,y=l||f,b=l?n===!0?t:n:t,x=L.createElement(s1,h1({},r,{name:String(r.name)},i,{isActive:v,option:b,index:a,dataKey:o,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance,onTransitionEnd:_}));return y?L.createElement(iq,{zIndex:qF.activeBar},L.createElement(f1,{index:i.originalDataIndex},x)):x}function Upe(e){var t=e.shape,n=e.baseProps,r=e.entry,i=e.index,a=e.dataKey;return L.createElement(s1,h1({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance}))}function Wpe(e){var t=e.data,n=e.props,r=e.animationElapsedTime,i=e.isAnimating,a=e.isEntrance,o=bE(n)??{},s=o.id,c=v1(o,Ope),l=n.shape,u=n.dataKey,d=n.activeBar,f=n.onMouseEnter,p=n.onClick,m=n.onMouseLeave,h=v1(n,kpe),g=qX(f,u,s),_=JX(m),v=YX(p,u,s);return t?L.createElement(L.Fragment,null,t.map((e,t)=>L.createElement(f1,h1({index:e.originalDataIndex,key:`rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,className:`recharts-bar-rectangle`},yO(h,e,t),{onMouseEnter:g(e,e.originalDataIndex),onMouseLeave:_(e,e.originalDataIndex),onClick:v(e,e.originalDataIndex)}),d?L.createElement(Hpe,{shape:l,activeBar:d,baseProps:c,entry:e,index:t,dataKey:u,animationElapsedTime:r,isAnimating:i,isEntrance:a}):L.createElement(Upe,{shape:l,baseProps:c,entry:e,index:t,dataKey:u,animationElapsedTime:r,isAnimating:i,isEntrance:a})))):null}var Gpe=(e,t,n)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>{if(e.status===`removed`)return n===`horizontal`?[_1(_1({},e.prev),{},{height:tD(e.prev.height,0,t),y:tD(e.prev.y,e.prev.y+e.prev.height,t)})]:[_1(_1({},e.prev),{},{width:tD(e.prev.width,0,t)})];if(e.status===`matched`)return[_1(_1({},e.next),{},{x:tD(e.prev.x,e.next.x,t),y:tD(e.prev.y,e.next.y,t),width:tD(e.prev.width,e.next.width,t),height:tD(e.prev.height,e.next.height,t)})];var r=e.next;return n===`horizontal`?[_1(_1({},r),{},{height:tD(0,r.height,t),y:tD(r.stackedBarStart,r.y,t)})]:[_1(_1({},r),{},{width:tD(0,r.width,t),x:tD(r.stackedBarStart,r.x,t)})]});function Kpe(e){var t=e.props,n=e.previousRectanglesRef,r=t.data,i=t.isAnimationActive,a=t.animationBegin,o=t.animationDuration,s=t.animationEasing,c=t.animationInterpolateFn,l=t.layout,u=bZ(t.onAnimationStart,t.onAnimationEnd),d=u.isAnimating,f=u.handleAnimationStart,p=u.handleAnimationEnd;return L.createElement(Vpe,{showLabels:!d,rects:r},L.createElement(xZ,{animationInput:r,animationIdPrefix:`recharts-bar-`,items:r,previousItemsRef:n,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s,onAnimationStart:f,onAnimationEnd:p,animationInterpolateFn:c,animationMatchBy:t.animationMatchBy,layout:l},(e,n,r)=>L.createElement(NE,null,L.createElement(Wpe,{props:t,data:e,animationElapsedTime:n,isAnimating:d||n<1,isEntrance:r}))),L.createElement(iX,{label:t.label}),t.children)}function qpe(e){var t=(0,L.useRef)(null);return L.createElement(Kpe,{previousRectanglesRef:t,props:e})}var y1=0,Jpe=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:uM(e,t)}},Ype=class extends L.PureComponent{render(){var e=this.props,t=e.hide,n=e.data,r=e.dataKey,i=e.className,a=e.xAxisId,o=e.yAxisId,s=e.needClip,c=e.background,l=e.id;if(t||n==null)return null;var u=mE(`recharts-bar`,i),d=l;return L.createElement(NE,{className:u,id:l},s&&L.createElement(`defs`,null,L.createElement(q$,{clipPathId:d,xAxisId:a,yAxisId:o})),L.createElement(NE,{className:`recharts-bar-rectangles`,clipPath:s?`url(#clipPath-${d})`:void 0},L.createElement(Bpe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),L.createElement(qpe,this.props)))}},Xpe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:`ease`,animationInterpolateFn:Gpe,animationMatchBy:oZ,background:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:y1,shape:o1,xAxisId:0,yAxisId:0,zIndex:qF.bar};function Zpe(e){var t=e.xAxisId,n=e.yAxisId,r=e.hide,i=e.legendType,a=e.minPointSize,o=e.activeBar,s=e.animationBegin,c=e.animationDuration,l=e.animationEasing,u=e.isAnimationActive,d=K$(t,n).needClip,f=XM(),p=jM(),m=PX(e.children,iJ),h=X(t=>ype(t,e.id,p,m));if(f!==`vertical`&&f!==`horizontal`)return null;var g,_=h?.[0];return g=_==null||_.height==null||_.width==null?0:f===`vertical`?_.height/2:_.width/2,L.createElement(G$,{xAxisId:t,yAxisId:n,data:h,dataPointFormatter:Jpe,errorBarOffset:g},L.createElement(Ype,h1({},e,{layout:f,needClip:d,data:h,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u})))}function Qpe(e){var t=e.layout,n=e.barSettings,r=n.dataKey,i=n.minPointSize,a=n.hasCustomShape,o=e.pos,s=e.bandSize,c=e.xAxis,l=e.yAxis,u=e.xAxisTicks,d=e.yAxisTicks,f=e.stackedData,p=e.displayedData,m=e.offset,h=e.cells,g=e.parentViewBox,_=e.dataStartIndex,v=t===`horizontal`?l:c,y=f?v.scale.domain():null,b=Ace({numericAxis:v}),x=v.scale.map(b);return p.map((e,n)=>{var p,v,S,C,w,T;if(f){var E=f[n+_];if(E==null)return null;p=Ece(E,y)}else p=uM(e,r),Array.isArray(p)||(p=[b,p]);var D=dpe(i,y1)(p[1],n);if(t===`horizontal`){var O=l.scale.map(p[0]),k=l.scale.map(p[1]);if(O==null||k==null)return null;v=hM({axis:c,ticks:u,bandSize:s,offset:o.offset,entry:e,index:n}),S=k??O??void 0,C=o.size;var A=O-k;if(w=JE(A)?0:A,T={x:v,y:m.top,width:C,height:m.height},Math.abs(D)>0&&Math.abs(w)<Math.abs(D)){var j=qE(w||D)*(Math.abs(D)-Math.abs(w));S-=j,w+=j}}else{var M=c.scale.map(p[0]),N=c.scale.map(p[1]);if(M==null||N==null)return null;if(v=M,S=hM({axis:l,ticks:d,bandSize:s,offset:o.offset,entry:e,index:n}),C=N-M,w=o.size,T={x:m.left,y:S,width:m.width,height:w},Math.abs(D)>0&&Math.abs(C)<Math.abs(D)){var P=qE(C||D)*(Math.abs(D)-Math.abs(C));C+=P}}return v==null||S==null||C==null||w==null||!a&&(C===0||w===0)?null:_1(_1({},e),{},{stackedBarStart:x,x:v,y:S,width:C,height:w,value:f?p:p[1],payload:e,background:T,tooltipPosition:{x:v+C/2,y:S+w/2},parentViewBox:g,originalDataIndex:n},h&&h[n]&&h[n].props)}).filter(Boolean)}function $pe(e){var t=TO(e,Xpe),n=Cpe(t.stackId),r=jM();return L.createElement(jZ,{id:t.id,type:`bar`},e=>L.createElement(L.Fragment,null,L.createElement(ZX,{legendPayload:Rpe(t)}),L.createElement(zpe,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),L.createElement(VZ,{type:`bar`,id:e,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r,hasCustomShape:t.shape!=null&&t.shape!==o1}),L.createElement(iq,{zIndex:t.zIndex},L.createElement(Zpe,h1({},t,{id:e})))))}var b1=L.memo($pe,sN);b1.displayName=`Bar`;var eme=[`domain`,`range`],tme=[`domain`,`range`];function x1(e,t){if(e==null)return{};var n,r,i=nme(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function nme(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function S1(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function C1(e,t){if(e===t)return!0;var n=e.domain,r=e.range,i=x1(e,eme),a=t.domain,o=t.range,s=x1(t,tme);return!S1(n,a)||!S1(r,o)?!1:sN(i,s)}var rme=[`type`],ime=[`dangerouslySetInnerHTML`,`ticks`,`scale`],ame=[`id`,`scale`];function w1(){return w1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},w1.apply(null,arguments)}function T1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function E1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?T1(Object(n),!0).forEach(function(t){ome(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T1(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ome(e,t,n){return(t=sme(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sme(e){var t=cme(e,`string`);return typeof t==`symbol`?t:t+``}function cme(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function D1(e,t){if(e==null)return{};var n,r,i=lme(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function lme(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ume(e){var t=Vk(),n=(0,L.useRef)(null),r=ZM(),i=e.type,a=D1(e,rme),o=ZF(r,`xAxis`,i),s=(0,L.useMemo)(()=>{if(o!=null)return E1(E1({},a),{},{type:o})},[a,o]);return(0,L.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(VQ(s)):n.current!==s&&t(HQ({prev:n.current,next:s})),n.current=s)},[s,t]),(0,L.useLayoutEffect)(()=>()=>{n.current&&=(t(UQ(n.current)),null)},[t]),null}var dme=e=>{var t=e.xAxisId,n=e.className,r=e.height,i=e.label,a=(0,L.useRef)(null),o=(0,L.useRef)(null),s=X(AM),c=jM(),l=Vk(),u=`xAxis`,d=X(e=>kW(e,u,t,c)),f=X(e=>_W(e,t)),p=X(e=>SW(e,t)),m=X(e=>OH(e,t));if((0,L.useLayoutEffect)(()=>{if(!(r!==`auto`||!f||FY(i)||(0,L.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedHeight();Math.round(f.height)!==Math.round(n)&&l(JQ({id:t,height:n}))}}},[d,f,l,i,t,r,m]),f==null||p==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=D1(e,ime);m.id,m.scale;var g=D1(m,ame);return L.createElement(N$,w1({},h,g,{ref:a,labelRef:o,x:p.x,y:p.y,width:f.width,height:f.height,className:mE(`recharts-${u} ${u}`,n),viewBox:s,ticks:d,axisType:u,axisId:t}))},fme={allowDataOverflow:DH.allowDataOverflow,allowDecimals:DH.allowDecimals,allowDuplicatedCategory:DH.allowDuplicatedCategory,angle:DH.angle,axisLine:M$.axisLine,height:DH.height,hide:!1,includeHidden:DH.includeHidden,interval:DH.interval,label:!1,minTickGap:DH.minTickGap,mirror:DH.mirror,orientation:DH.orientation,padding:DH.padding,reversed:DH.reversed,scale:DH.scale,tick:DH.tick,tickCount:DH.tickCount,tickLine:M$.tickLine,tickSize:M$.tickSize,type:DH.type,niceTicks:DH.niceTicks,xAxisId:0},O1=L.memo(e=>{var t=TO(e,fme);return L.createElement(L.Fragment,null,L.createElement(ume,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),L.createElement(dme,t))},C1);O1.displayName=`XAxis`;var pme=[`type`],mme=[`dangerouslySetInnerHTML`,`ticks`,`scale`],hme=[`id`,`scale`];function k1(){return k1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},k1.apply(null,arguments)}function A1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function j1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?A1(Object(n),!0).forEach(function(t){gme(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A1(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gme(e,t,n){return(t=_me(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _me(e){var t=vme(e,`string`);return typeof t==`symbol`?t:t+``}function vme(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function M1(e,t){if(e==null)return{};var n,r,i=yme(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function yme(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function bme(e){var t=Vk(),n=(0,L.useRef)(null),r=ZM(),i=e.type,a=M1(e,pme),o=ZF(r,`yAxis`,i),s=(0,L.useMemo)(()=>{if(o!=null)return j1(j1({},a),{},{type:o})},[o,a]);return(0,L.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(WQ(s)):n.current!==s&&t(GQ({prev:n.current,next:s})),n.current=s)},[s,t]),(0,L.useLayoutEffect)(()=>()=>{n.current&&=(t(KQ(n.current)),null)},[t]),null}function xme(e){var t=e.yAxisId,n=e.className,r=e.width,i=e.label,a=(0,L.useRef)(null),o=(0,L.useRef)(null),s=X(AM),c=jM(),l=Vk(),u=`yAxis`,d=X(e=>wW(e,t)),f=X(e=>CW(e,t)),p=X(e=>kW(e,u,t,c)),m=X(e=>jH(e,t));if((0,L.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||FY(i)||(0,L.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(qQ({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=M1(e,mme);m.id,m.scale;var g=M1(m,hme);return L.createElement(N$,k1({},h,g,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:mE(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u,axisId:t}))}var Sme={allowDataOverflow:AH.allowDataOverflow,allowDecimals:AH.allowDecimals,allowDuplicatedCategory:AH.allowDuplicatedCategory,angle:AH.angle,axisLine:M$.axisLine,hide:!1,includeHidden:AH.includeHidden,interval:AH.interval,label:!1,minTickGap:AH.minTickGap,mirror:AH.mirror,orientation:AH.orientation,padding:AH.padding,reversed:AH.reversed,scale:AH.scale,tick:AH.tick,tickCount:AH.tickCount,tickLine:M$.tickLine,tickSize:M$.tickSize,type:AH.type,niceTicks:AH.niceTicks,width:AH.width,yAxisId:0},N1=L.memo(e=>{var t=TO(e,Sme);return L.createElement(L.Fragment,null,L.createElement(bme,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),L.createElement(xme,t))},C1);N1.displayName=`YAxis`;var P1=Z([(e,t)=>t,YM,pI,SI,qG,YG,OK,kM],BK);function Cme(e){return`getBBox`in e.currentTarget&&typeof e.currentTarget.getBBox==`function`}function F1(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(Cme(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(e,i)=>({relativeX:Math.round((e-t.left)/n),relativeY:Math.round((i-t.top)/r)});return`touches`in e?Array.from(e.touches).map(e=>o(e.clientX,e.clientY)):o(e.clientX,e.clientY)}var I1=xj(`mouseClick`),L1=tM();L1.startListening({actionCreator:I1,effect:(e,t)=>{var n=e.payload,r=P1(t.getState(),F1(n));r?.activeIndex!=null&&t.dispatch(QW({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var R1=xj(`mouseMove`),z1=tM(),B1=null,V1=null,H1=null;z1.startListening({actionCreator:R1,effect:(e,t)=>{var n=e.payload,r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a?.includes(`mousemove`);B1!==null&&(cancelAnimationFrame(B1),B1=null),V1!==null&&(typeof i!=`number`||!o)&&(clearTimeout(V1),V1=null),H1=F1(n);var s=()=>{var e=t.getState(),n=IW(e,e.tooltip.settings.shared);if(!H1){B1=null,V1=null;return}if(n===`axis`){var r=P1(e,H1);r?.activeIndex==null?t.dispatch(YW()):t.dispatch(ZW({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}B1=null,V1=null};if(!o){s();return}i===`raf`?B1=requestAnimationFrame(s):typeof i==`number`&&V1===null&&(V1=setTimeout(s,i))}});function wme(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<<CHILDREN>>`:t}var U1={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},W1=Aj({name:`rootProps`,initialState:U1,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??U1.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),Tme=W1.reducer,Eme=W1.actions.updateOptions,G1=Aj({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)}}),Dme=G1.actions.updatePolarOptions,Ome=G1.reducer,K1=xj(`keyDown`),q1=xj(`focus`),J1=xj(`blur`),Y1=tM(),X1=null,Z1=null,Q1=null;Y1.startListening({actionCreator:K1,effect:(e,t)=>{Q1=e.payload,X1!==null&&(cancelAnimationFrame(X1),X1=null);var n=t.getState().eventSettings,r=n.throttleDelay,i=n.throttledEvents,a=i===`all`||i.includes(`keydown`);Z1!==null&&(typeof r!=`number`||!a)&&(clearTimeout(Z1),Z1=null);var o=()=>{try{var e=t.getState();if(e.rootProps.accessibilityLayer===!1)return;var n=e.tooltip.keyboardInteraction,r=Q1;if(r!==`ArrowRight`&&r!==`ArrowLeft`&&r!==`Enter`)return;var i=pG(n,FG(e),lU(e),WG(e)),a=i==null?-1:Number(i),o=!Number.isFinite(a)||a<0,s=YG(e),c=FG(e),l=IW(e,e.tooltip.settings.shared);if(r===`Enter`){if(o)return;var u=NK(e,l,`hover`,String(n.index));t.dispatch(eG({active:!n.active,activeIndex:n.index,activeCoordinate:u}));return}var d=MW(e)===`left-to-right`?1:-1,f=r===`ArrowRight`?1:-1,p;if(o){var m=lU(e),h=WG(e),g=f*d,_=e=>({active:!1,index:String(e),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(p=-1,g>0){for(var v=0;v<c.length;v++)if(pG(_(v),c,m,h)!=null){p=v;break}}else for(var y=c.length-1;y>=0;y--)if(pG(_(y),c,m,h)!=null){p=y;break}if(p<0)return}else{p=a+f*d;var b=s?.length||c.length;if(b===0||p>=b||p<0)return}var x=NK(e,l,`hover`,String(p));t.dispatch(eG({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}finally{X1=null,Z1=null}};if(!a){o();return}r===`raf`?X1=requestAnimationFrame(o):typeof r==`number`&&Z1===null&&(o(),Q1=null,Z1=setTimeout(()=>{Q1?o():(Z1=null,X1=null)},r))}}),Y1.startListening({actionCreator:q1,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;if(!r.active&&r.index==null){var i=`0`,a=NK(n,IW(n,n.tooltip.settings.shared),`hover`,String(i));t.dispatch(eG({active:!0,activeIndex:i,activeCoordinate:a}))}}}}),Y1.startListening({actionCreator:J1,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;r.active&&t.dispatch(eG({active:!1,activeIndex:r.index,activeCoordinate:r.coordinate}))}}});function $1(e){e.persist();var t=e.currentTarget;return new Proxy(e,{get:(e,n)=>{if(n===`currentTarget`)return t;var r=Reflect.get(e,n);return typeof r==`function`?r.bind(e):r}})}var e0=xj(`externalEvent`),t0=tM(),n0=new Map,r0=new Map,i0=new Map;t0.startListening({actionCreator:e0,effect:(e,t)=>{var n=e.payload,r=n.handler,i=n.reactEvent;if(r!=null){var a=i.type,o=$1(i);i0.set(a,{handler:r,reactEvent:o});var s=n0.get(a);s!==void 0&&(cancelAnimationFrame(s),n0.delete(a));var c=t.getState().eventSettings,l=c.throttleDelay,u=c.throttledEvents,d=u===`all`||u?.includes(a),f=r0.get(a);f!==void 0&&(typeof l!=`number`||!d)&&(clearTimeout(f),r0.delete(a));var p=()=>{var e=i0.get(a);try{if(!e)return;var n=e.handler,r=e.reactEvent,i=t.getState(),o={activeCoordinate:aK(i),activeDataKey:nK(i),activeIndex:eK(i),activeLabel:tK(i),activeTooltipIndex:eK(i),isTooltipActive:oK(i)};n&&n(o,r)}finally{n0.delete(a),r0.delete(a),i0.delete(a)}};if(!d){p();return}if(l===`raf`){var m=requestAnimationFrame(p);n0.set(a,m)}else if(typeof l==`number`){if(!r0.has(a)){p();var h=setTimeout(p,l);r0.set(a,h)}}else p()}}});var kme=Z([Z([_G],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var i=r.getPosition;if(i!=null)return i(t)}}}),a0=xj(`touchMove`),o0=tM(),s0=null,c0=null,l0=null,u0=null;o0.startListening({actionCreator:a0,effect:(e,t)=>{var n=e.payload;if(n.touches!=null&&n.touches.length!==0){u0=$1(n);var r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a.includes(`touchmove`);s0!==null&&(cancelAnimationFrame(s0),s0=null),c0!==null&&(typeof i!=`number`||!o)&&(clearTimeout(c0),c0=null),l0=Array.from(n.touches).map(e=>F1({clientX:e.clientX,clientY:e.clientY,currentTarget:n.currentTarget}));var s=()=>{if(u0!=null){var e=t.getState(),n=IW(e,e.tooltip.settings.shared);if(n===`axis`){var r=l0?.[0];if(r==null){s0=null,c0=null;return}var i=P1(e,r);i?.activeIndex!=null&&t.dispatch(ZW({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(n===`item`){var a=u0.touches[0];if(document.elementFromPoint==null||a==null)return;var o=document.elementFromPoint(a.clientX,a.clientY);if(!o||!o.getAttribute)return;var s=o.getAttribute(EM),c=o.getAttribute(`data-recharts-item-id`)??void 0,l=jG(e).find(e=>e.id===c);if(s==null||l==null||c==null)return;var u=l.dataKey,d=kme(e,s,c);t.dispatch(qW({activeDataKey:u,activeIndex:s,activeCoordinate:d,activeGraphicalItemId:c}))}s0=null,c0=null}};if(!o){s();return}i===`raf`?s0=requestAnimationFrame(s):typeof i==`number`&&c0===null&&(s(),u0=null,c0=setTimeout(()=>{u0?s():(c0=null,s0=null)},i))}}});var d0={throttleDelay:`raf`,throttledEvents:[`mousemove`,`touchmove`,`pointermove`,`scroll`,`wheel`]},f0=Aj({name:`eventSettings`,initialState:d0,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=yj(t.payload.throttledEvents))}}}),Ame=f0.actions.setEventSettings,jme=f0.reducer,Mme=cA({brush:lde,cartesianAxis:YQ,chartData:kq,errorBars:kfe,eventSettings:jme,graphicalItems:BZ,layout:xce,legend:yle,options:Sq,polarAxis:hX,polarOptions:Ome,referenceElements:fde,renderedTicks:Lde,rootProps:Tme,tooltip:tG,zIndex:rq}),Nme=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return qse({reducer:Mme,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([L1.middleware,z1.middleware,Y1.middleware,t0.middleware,o0.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(Oj({type:`raf`}))},devTools:hN.devToolsEnabled&&{serialize:{replacer:wme},name:`recharts-${t}`}})};function p0(e){var t=e.preloadedState,n=e.children,r=e.reduxStoreName,i=jM(),a=(0,L.useRef)(null);if(i)return n;a.current??=Nme(t,r);var o=Bk;return L.createElement(Nle,{context:o,store:a.current},n)}function Pme(e){var t=e.layout,n=e.margin,r=Vk(),i=jM();return(0,L.useEffect)(()=>{i||(r(vce(t)),r(_ce(n)))},[r,i,t,n]),null}var m0=(0,L.memo)(Pme,sN);function h0(e){var t=Vk();return(0,L.useEffect)(()=>{t(Eme(e))},[t,e]),null}var g0=(0,L.memo)(e=>{var t=Vk();return(0,L.useEffect)(()=>{t(Ame(e))},[t,e]),null},sN);function _0(e){var t=e.zIndex,n=e.isPanorama,r=(0,L.useRef)(null),i=Vk();return(0,L.useLayoutEffect)(()=>(r.current&&i(tq({zIndex:t,element:r.current,isPanorama:n})),()=>{i(nq({zIndex:t,isPanorama:n}))}),[i,t,n]),L.createElement(`g`,{tabIndex:-1,ref:r,className:`recharts-zIndex-layer_${t}`})}function v0(e){var t=e.children,n=e.isPanorama,r=X(HK);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return L.createElement(L.Fragment,null,i.map(e=>L.createElement(_0,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>L.createElement(_0,{key:e,zIndex:e,isPanorama:n})))}var Fme=[`children`];function Ime(e,t){if(e==null)return{};var n,r,i=Lme(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Lme(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function y0(){return y0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y0.apply(null,arguments)}var Rme={width:`100%`,height:`100%`,display:`block`},zme=(0,L.forwardRef)((e,t)=>{var n=qM(),r=JM(),i=xN();if(!sM(n)||!sM(r))return null;var a=e.children,o=e.otherAttributes,s=e.title,c=e.desc,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),L.createElement(OE,y0({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:Rme,ref:t}),a)}),Bme=e=>{var t=e.children,n=X(NM);if(!n)return null;var r=n.width,i=n.height,a=n.y,o=n.x;return L.createElement(OE,{width:r,height:i,x:o,y:a},t)},b0=(0,L.forwardRef)((e,t)=>{var n=e.children,r=Ime(e,Fme);return jM()?L.createElement(Bme,null,L.createElement(v0,{isPanorama:!0},n)):L.createElement(zme,y0({ref:t},r),L.createElement(v0,{isPanorama:!1},n))});function Vme(e,t){return Gme(e)||Wme(e,t)||Ume(e,t)||Hme()}function Hme(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
66
66
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ume(e,t){if(e){if(typeof e==`string`)return x0(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x0(e,t):void 0}}function x0(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Wme(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Gme(e){if(Array.isArray(e))return e}function Kme(){var e=Vk(),t=Vme((0,L.useState)(null),2),n=t[0],r=t[1],i=X(Ice);return(0,L.useEffect)(()=>{if(n!=null){var t=n.getBoundingClientRect().width/n.offsetWidth;oM(t)&&t!==i&&e(bce(t))}},[n,e,i]),r}function S0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function qme(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?S0(Object(n),!0).forEach(function(t){Jme(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Jme(e,t,n){return(t=Yme(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yme(e){var t=Xme(e,`string`);return typeof t==`symbol`?t:t+``}function Xme(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function C0(){return C0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},C0.apply(null,arguments)}function w0(e,t){return ehe(e)||$me(e,t)||Qme(e,t)||Zme()}function Zme(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
67
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qme(e,t){if(e){if(typeof e==`string`)return T0(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T0(e,t):void 0}}function T0(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function $me(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function ehe(e){if(Array.isArray(e))return e}var the=()=>(Bq(),null);function E0(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var nhe=(0,L.forwardRef)((e,t)=>{var n=(0,L.useRef)(null),r=w0((0,L.useState)({containerWidth:E0(e.style?.width),containerHeight:E0(e.style?.height)}),2),i=r[0],a=r[1],o=(0,L.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,L.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,L.useEffect)(()=>()=>{n.current?.disconnect()},[o]),L.createElement(L.Fragment,null,L.createElement($M,{width:i.containerWidth,height:i.containerHeight}),L.createElement(`div`,C0({ref:s},e)))}),rhe=(0,L.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=w0((0,L.useState)({containerWidth:E0(n),containerHeight:E0(r)}),2),a=i[0],o=i[1],s=(0,L.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,L.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return L.createElement(L.Fragment,null,L.createElement($M,{width:a.containerWidth,height:a.containerHeight}),L.createElement(`div`,C0({ref:c},e)))}),ihe=(0,L.forwardRef)((e,t)=>{var n=e.width,r=e.height;return L.createElement(L.Fragment,null,L.createElement($M,{width:n,height:r}),L.createElement(`div`,C0({ref:t},e)))}),ahe=(0,L.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?L.createElement(rhe,C0({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?L.createElement(ihe,C0({},e,{width:n,height:r,ref:t})):L.createElement(L.Fragment,null,L.createElement($M,{width:n,height:r}),L.createElement(`div`,C0({ref:t},e)))});function ohe(e){return e?nhe:ahe}var she=(0,L.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,v=e.responsive,y=e.dispatchTouchEvents,b=y===void 0||y,x=(0,L.useRef)(null),S=Vk(),C=w0((0,L.useState)(null),2),w=C[0],T=C[1],E=w0((0,L.useState)(null),2),D=E[0],O=E[1],k=Kme(),A=UM(),j=A?.width>0?A.width:_,M=A?.height>0?A.height:i,N=(0,L.useCallback)(e=>{k(e),typeof t==`function`&&t(e),T(e),O(e),e!=null&&(x.current=e)},[k,t,T,O]),P=(0,L.useCallback)(e=>{S(I1(e)),S(e0({handler:a,reactEvent:e}))},[S,a]),ee=(0,L.useCallback)(e=>{S(R1(e)),S(e0({handler:l,reactEvent:e}))},[S,l]),te=(0,L.useCallback)(e=>{S(YW()),S(e0({handler:u,reactEvent:e}))},[S,u]),ne=(0,L.useCallback)(e=>{S(R1(e)),S(e0({handler:d,reactEvent:e}))},[S,d]),re=(0,L.useCallback)(()=>{S(q1())},[S]),ie=(0,L.useCallback)(()=>{S(J1())},[S]),ae=(0,L.useCallback)(e=>{S(K1(e.key))},[S]),oe=(0,L.useCallback)(e=>{S(e0({handler:o,reactEvent:e}))},[S,o]),se=(0,L.useCallback)(e=>{S(e0({handler:s,reactEvent:e}))},[S,s]),ce=(0,L.useCallback)(e=>{S(e0({handler:c,reactEvent:e}))},[S,c]),le=(0,L.useCallback)(e=>{S(e0({handler:f,reactEvent:e}))},[S,f]),ue=(0,L.useCallback)(e=>{S(e0({handler:h,reactEvent:e}))},[S,h]),F=(0,L.useCallback)(e=>{b&&S(a0(e)),S(e0({handler:m,reactEvent:e}))},[S,b,m]),de=(0,L.useCallback)(e=>{S(e0({handler:p,reactEvent:e}))},[S,p]),fe=ohe(v);return L.createElement(mq.Provider,{value:w},L.createElement(gD.Provider,{value:D},L.createElement(fe,{width:j??g?.width,height:M??g?.height,className:mE(`recharts-wrapper`,r),style:qme({position:`relative`,cursor:`default`,width:j,height:M},g),onClick:P,onContextMenu:oe,onDoubleClick:se,onFocus:re,onBlur:ie,onKeyDown:ae,onMouseDown:ce,onMouseEnter:ee,onMouseLeave:te,onMouseMove:ne,onMouseUp:le,onTouchEnd:de,onTouchMove:F,onTouchStart:ue,ref:N},L.createElement(the,null),n)))}),che=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function lhe(e,t){if(e==null)return{};var n,r,i=uhe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function uhe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var D0=(0,L.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=bE(lhe(e,che));return c?L.createElement(L.Fragment,null,L.createElement($M,{width:n,height:r}),L.createElement(b0,{otherAttributes:d,title:l,desc:u},a)):L.createElement(she,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},L.createElement(b0,{otherAttributes:d,title:l,desc:u,ref:t},L.createElement(yde,null,a)))});function O0(){return O0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},O0.apply(null,arguments)}function k0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function dhe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?k0(Object(n),!0).forEach(function(t){fhe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function fhe(e,t,n){return(t=phe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function phe(e){var t=mhe(e,`string`);return typeof t==`symbol`?t:t+``}function mhe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var hhe=dhe({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},d0),A0=(0,L.forwardRef)(function(e,t){var n=TO(e.categoricalChartProps,hhe),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return L.createElement(p0,{preloadedState:{options:c},reduxStoreName:s.id??r},L.createElement(d$,{chartData:s.data}),L.createElement(m0,{layout:n.layout,margin:n.margin}),L.createElement(g0,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),L.createElement(h0,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),L.createElement(D0,O0({},n,{ref:t})))}),ghe=[`axis`],_he=(0,L.forwardRef)((e,t)=>L.createElement(A0,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:ghe,tooltipPayloadSearcher:bq,categoricalChartProps:e,ref:t})),vhe=[`axis`,`item`],j0=(0,L.forwardRef)((e,t)=>L.createElement(A0,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:vhe,tooltipPayloadSearcher:bq,categoricalChartProps:e,ref:t}));function yhe(e){var t=Vk();return(0,L.useEffect)(()=>{t(Dme(e))},[t,e]),null}var bhe=[`layout`];function M0(){return M0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},M0.apply(null,arguments)}function xhe(e,t){if(e==null)return{};var n,r,i=She(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function She(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function N0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Che(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?N0(Object(n),!0).forEach(function(t){whe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):N0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function whe(e,t,n){return(t=The(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function The(e){var t=Ehe(e,`string`);return typeof t==`symbol`?t:t+``}function Ehe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var P0=Che({accessibilityLayer:!0,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`,layout:`radial`,responsive:!1,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`},d0),Dhe=(0,L.forwardRef)(function(e,t){var n=TO(e.categoricalChartProps,P0),r=n.layout,i=xhe(n,bhe),a=e.chartName,o={chartName:a,defaultTooltipEventType:e.defaultTooltipEventType,validateTooltipEventTypes:e.validateTooltipEventTypes,tooltipPayloadSearcher:e.tooltipPayloadSearcher,eventEmitter:void 0};return L.createElement(p0,{preloadedState:{options:o},reduxStoreName:n.id??a},L.createElement(d$,{chartData:n.data}),L.createElement(m0,{layout:r,margin:n.margin}),L.createElement(g0,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),L.createElement(h0,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),L.createElement(yhe,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),L.createElement(D0,M0({},i,{ref:t})))});function F0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function I0(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?F0(Object(n),!0).forEach(function(t){Ohe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):F0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ohe(e,t,n){return(t=khe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function khe(e){var t=Ahe(e,`string`);return typeof t==`symbol`?t:t+``}function Ahe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var jhe=[`item`],Mhe=I0(I0({},P0),{},{layout:`centric`,startAngle:0,endAngle:360}),Nhe=(0,L.forwardRef)((e,t)=>{var n=TO(e,Mhe);return L.createElement(Dhe,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:jhe,tooltipPayloadSearcher:bq,categoricalChartProps:n,ref:t})}),L0=`flex items-center gap-2 rounded-md px-1 py-0.5`,R0=({resource:e,view:t,filter:n,color:r,label:i,children:a})=>{let o=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`size-2.5 shrink-0 rounded-full`,style:{background:r},"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate group-hover:text-primary-text`,children:i}),a]});return(0,z.jsx)(`li`,{children:n===void 0?(0,z.jsx)(`div`,{className:L0,children:o}):(0,z.jsx)(jS,{to:dE(t,e,n),className:`group ${L0} hover:bg-muted`,children:o})})},Phe=(e,t)=>t>0?`${Math.round(e/t*100)}%`:``,Fhe=({active:e,payload:t,measure:n})=>{let r=t?.[0]?.payload;return!e||!r?null:(0,z.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:r.label}),(0,z.jsx)(`div`,{className:`font-semibold tabular-nums`,children:uE(r.value,n)})]})},Ihe=({resource:e,view:t,slices:n,measure:r})=>{let i=n.filter(e=>e.value!==null&&e.value>0),a=i.reduce((e,t)=>e+t.value,0);return(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-4 sm:flex-row sm:items-center`,children:[(0,z.jsx)(`div`,{className:`size-36 shrink-0`,children:(0,z.jsx)(WM,{width:`100%`,height:`100%`,children:(0,z.jsxs)(Nhe,{children:[(0,z.jsx)(xQ,{data:i,dataKey:`value`,nameKey:`label`,innerRadius:`62%`,outerRadius:`100%`,paddingAngle:+(i.length>1),stroke:`var(--background)`,strokeWidth:2,isAnimationActive:!1,children:i.map(e=>(0,z.jsx)(iJ,{fill:e.color},e.key))}),(0,z.jsx)(rJ,{content:(0,z.jsx)(Fhe,{measure:r}),isAnimationActive:!1})]})})}),(0,z.jsx)(`ul`,{className:`flex w-full min-w-0 flex-col gap-0.5`,children:n.map(n=>(0,z.jsxs)(R0,{resource:e,view:t,filter:n.filter,color:n.color,label:n.label,children:[(0,z.jsx)(`span`,{className:`font-medium tabular-nums`,children:uE(n.value,r)}),(0,z.jsx)(`span`,{className:`w-9 text-right text-xs text-muted-foreground tabular-nums`,children:Phe(n.value??0,a)})]},n.key))})]})},z0={hour:`2-digit`,minute:`2-digit`,hour12:!1},B0={day:`numeric`,month:`short`,...z0},Lhe={minute:z0,"5_minutes":z0,"15_minutes":z0,hour:z0,day:{day:`numeric`,month:`short`},week:{day:`numeric`,month:`short`},month:{month:`short`,year:`2-digit`},year:{year:`numeric`}},V0={minute:B0,"5_minutes":B0,"15_minutes":B0,hour:B0,day:{day:`numeric`,month:`short`,year:`numeric`},week:{day:`numeric`,month:`short`,year:`numeric`},month:{month:`long`,year:`numeric`},year:{year:`numeric`}},H0=e=>{let t=new Intl.DateTimeFormat(l(),{...e,timeZone:`UTC`});return e=>t.format(e)},U0={fontSize:11,fill:`var(--muted-foreground)`},Rhe=864e5,zhe=new Set([`minute`,`5_minutes`,`15_minutes`,`hour`]),Bhe=(e,t)=>{let n=t.length>1?t.at(-1).at-t[0].at:0;return zhe.has(e)&&n>=Rhe?B0:Lhe[e]},Vhe=({active:e,payload:t,measure:n,bucket:r,series:i})=>{let a=t?.[0]?.payload;return!e||!a?null:(0,z.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:r===`week`?tE(`weekOf`,H0(V0[r])(a.at)):H0(V0[r])(a.at)}),i?.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{background:e.color},"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`flex-1`,children:e.label}),(0,z.jsx)(`span`,{className:`font-semibold tabular-nums`,children:uE(a[e.key]??null,e.measure??n)})]},e.key)),i&&(n.kind===`count`||n.kind===`sum`)&&(0,z.jsx)(`div`,{className:`mt-0.5 border-t pt-0.5 font-semibold tabular-nums`,children:uE(a.value,n)}),!i&&(0,z.jsx)(`div`,{className:`font-semibold tabular-nums`,children:uE(a.value,n)})]})},W0=({points:e,measure:t,bucket:n,type:r,series:i,resource:a,view:o})=>{let s=ju(`(min-width: 640px)`),c=H0(Bhe(n,e)),u=(0,z.jsx)(B$,{vertical:!1,stroke:`var(--border)`}),d=(0,z.jsx)(O1,{dataKey:`at`,tickFormatter:c,tick:U0,axisLine:!1,tickLine:!1,minTickGap:s?24:40,height:18}),f=(0,z.jsx)(N1,{width:s?48:36,tick:U0,axisLine:!1,tickLine:!1,tickCount:3,tickFormatter:e=>e.toLocaleString(l(),{notation:`compact`})}),p=(0,z.jsx)(rJ,{cursor:r===`bar`?{fill:`var(--muted)`}:{stroke:`var(--border-strong)`},content:(0,z.jsx)(Vhe,{measure:t,bucket:n,...i&&{series:i}}),isAnimationActive:!1}),m=i??[{key:`value`,label:``,color:`var(--chart-1)`}],h=(0,z.jsx)(`div`,{className:`h-40`,children:(0,z.jsx)(WM,{width:`100%`,height:`100%`,children:r===`line`?(0,z.jsxs)(_he,{data:e,margin:{top:6,right:6,bottom:0,left:0},children:[u,d,f,p,m.map(t=>(0,z.jsx)(r1,{dataKey:t.key,stroke:t.color,strokeWidth:2,dot:e.length<=31&&{r:3,fill:t.color,strokeWidth:0},activeDot:{r:4,stroke:`var(--background)`,strokeWidth:2},isAnimationActive:!1},t.key))]}):(0,z.jsxs)(j0,{data:e,margin:{top:6,right:0,bottom:0,left:0},barCategoryGap:`22%`,children:[u,d,f,p,m.map((e,t)=>(0,z.jsx)(b1,{dataKey:e.key,fill:e.color,...i&&{stackId:`split`},radius:t===m.length-1?[4,4,0,0]:0,isAnimationActive:!1},e.key))]})})});return!i||a===void 0?h:(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h,(0,z.jsx)(`ul`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-sm`,children:i.map(e=>(0,z.jsx)(R0,{resource:a,view:o,color:e.color,label:e.label,...e.filter!==void 0&&{filter:e.filter}},e.key))})]})},Hhe=1e-6,Uhe=(e,t,n,r,i,a=``)=>{let o=t.map((e,t)=>({key:`s${t}`,label:aE(n,r,e),color:iE(n,r,e.value,t),filter:oE(n,e.value,a)})),s=i.kind===`count`?0:null,c=(e,t)=>{let n=e.splits?.find(e=>e.value===t);return n?i.kind===`count`?n.count:n[i.kind]??null:s},l=lE(e,i).map((n,r)=>{let a=e[r],o=t.map(e=>c(a,e.value)),s=Object.fromEntries(o.map((e,t)=>[`s${t}`,e]));if(i.kind===`average`)return{...n,...s};let l=n.value===null?null:n.value-o.reduce((e,t)=>e+(t??0),0);return{...n,...s,other:l===null?null:l<Hhe?0:l}});return i.kind!==`average`&&l.some(e=>(e.other??0)>0)?{series:[...o,{key:`other`,label:tE(`other`),color:`var(--border-strong)`}],points:l}:{series:o,points:l.map(({other:e,...t})=>t)}},Whe=(e,t,n,r)=>{let i=n??r,a=i===void 0?void 0:e.fields[i];return!a||i===void 0?{kind:`count`}:{kind:n===void 0?`average`:`sum`,field:a,hints:t?.fields[i]}},G0=(e,t,n)=>{let r=e?.type===`relation`&&e.relation?t[e.relation.resource]:void 0;return r&&r.primaryKey.length===1?Vx(r,n[r.name]):void 0},K0=({model:e,view:t,groupBy:n,splitBy:r,type:i=`bar`,sum:a,average:o,filter:s=``,granularity:c=`day`,range:l=`30d`,limit:u=10,empty:d=tE(`nothingYet`)})=>{let{resources:f,views:p}=G(),m=e.fields[n],h=m?.type===`date`||m?.type===`timestamp`,g=G0(m,f,p),_=h&&r!==void 0?e.fields[r]:void 0,v=G0(_,f,p),y=_?{splitBy:_.name,splitLimit:8,...v&&{splitLabel:v}}:{},b=h?{granularity:c,range:l,timeZone:If(),...y}:{limit:u,...g&&{label:g}},x=$T(e.name,{groupBy:n,filter:s,...a&&{sum:a},...o&&{average:o},...b},!!m),S=Whe(e,t,a,o);if(!m)return null;if(x.isPending)return(0,z.jsx)(Yu,{className:`h-36 w-full`});if(x.error)return(0,z.jsx)(`p`,{className:`text-danger-text`,children:tE(`couldNotLoad`)});let{groups:C}=x.data;if(C.every(e=>e.count===0))return(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:d});let w=i===`line`?`line`:`bar`;if(h&&_&&x.data.splits){let{series:n,points:r}=Uhe(C,x.data.splits,_,t?.fields[_.name],S,s);return(0,z.jsx)(W0,{points:r,measure:S,bucket:c,type:w,series:n,resource:e.name,view:t})}if(h)return(0,z.jsx)(W0,{points:lE(C,S),measure:S,bucket:c,type:w});let T=cE(C,m,t?.fields[n],S,s);return i===`donut`?(0,z.jsx)(Ihe,{resource:e.name,view:t,slices:T,measure:S}):(0,z.jsx)(fE,{resource:e.name,view:t,slices:T,measure:S})},Ghe=({node:e,slots:t})=>{let{resource:n,title:r,description:i,actions:a,span:o,...s}=HT(e),{resources:c,views:l}=G(),u=c[n];return u?(0,z.jsx)(GT,{title:r,description:i,actions:t.actions,className:`h-full`,children:(0,z.jsx)(K0,{model:u,view:l[n],...s})}):null},Khe=Vn(),q0=async(e,t,n,r,i)=>{let a=n.primaryKey[0],o=[...new Set(r)].sort();if(o.length===0||n.primaryKey.length!==1)return new Map;let s=Vx(n,i),c=await e.fetchQuery({queryKey:U.labels(n.name,o.join(`,`)),staleTime:3e5,queryFn:async()=>(await t.list(n.name,{filter:Fn(Khe.in(a,o)),fields:[a,s],pageSize:o.length})).items.map(e=>[String(e[a]),String(e[s])])});return new Map(c)},J0=(e,t,n)=>n.flatMap(n=>{let r=t.fields[n],i=r?.type===`relation`&&r.relation?e[r.relation.resource]:void 0;return i?[{name:n,target:i}]:[]}),Y0=(e,t,n,r)=>Object.fromEntries(J0(e,n,r).filter(({target:e})=>e.primaryKey.length===1).map(({name:e,target:n})=>[e,Vx(n,t[n.name])])),X0=(e,t,n,r,i={})=>{let a=J0(e,t,n);return r.map(e=>{let t={...e};for(let{name:n}of a)e[n]!=null&&(t[n]={id:e[n],name:i[n]?.[String(e[n])]??String(e[n])});return t})},Z0=(e,t)=>{let n=String(t);return e&&Object.hasOwn(e,n)?e[n]:void 0},Q0=({value:e,hints:t,children:n})=>(0,z.jsx)(_d,{tone:Qx(String(e)),color:Z0(t?.valueColors,e),shape:t?.badgeShape,children:n}),qhe=({field:e,value:t,known:n})=>{let{resources:r,views:i}=G(),a=W(),o=Km(),s=e.relation?r[e.relation.resource]:void 0,c=String(t),l=Kh({queryKey:U.relatedLabel(s?.name??``,c),enabled:!!s&&n===void 0,queryFn:async()=>(await q0(o,a,s,[c],i[s.name])).get(c)??c});return s?(0,z.jsx)(jS,{to:{kind:`record`,resource:s.name,key:c},className:`font-medium text-primary-text hover:underline`,children:n??l.data??c}):(0,z.jsx)(`span`,{children:c})},Jhe=({model:e,field:t,value:n,format:r,relationLabel:i})=>{let{views:a}=G(),o={...a[e.name]?.fields[t.name],...r&&{format:r}};if(n==null||n===``)return(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});if(t.type===`relation`)return(0,z.jsx)(qhe,{field:t,value:n,known:i});let s=t.type===`file`?rx(n):void 0;if(s&&`url`in s&&s.url){let e=dx(n,{width:40,height:40});return(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[e&&(0,z.jsx)(fC,{image:e,className:`size-10 shrink-0 rounded border border-border object-cover`}),(0,z.jsx)(`a`,{href:s.url,target:`_blank`,rel:`noreferrer`,className:`truncate font-medium text-primary-text hover:underline`,children:s.name})]})}if(zx(t,o))return(0,z.jsx)(yC,{source:String(n)});let c=rS(t,n,o),l=t.type===`text`?Jx(o):void 0;return l?(0,z.jsx)(xC,{format:l,value:c}):t.type===`enum`||o.format===`badge`?(0,z.jsx)(Q0,{value:n,hints:o,children:c}):(0,z.jsx)(`span`,{title:iS(t,n,void 0,o),className:g(o.format===`code`&&`font-mono text-xs`,(t.type===`decimal`||t.type===`integer`)&&`tabular-nums`,o.multiline&&`whitespace-pre-line break-words`),children:c})},$0=e=>{let{views:t}=G(),n=_C(e.field,t[e.model.name]?.fields[e.field.name]),r=(0,z.jsx)(Jhe,{...e});return n?(0,z.jsx)(vC,{shown:n,part:`display`,field:e.field,value:e.value,fallback:r}):r},e2=(e,t,n)=>{if(!t)return[];let r=Sc(e,t.model.name,n);return r.ok?r.steps:[]},t2=(e,t,n,r,i)=>({queryKey:U.pathValue(n?.model.name??``,n?.key??``,r),enabled:i.length>1,queryFn:async()=>{let r=n.record;for(let n of i.slice(0,-1)){let i=r[n.field.name];if(i==null)return null;let a=n.field.relation.resource;r=(await t.fetchQuery({queryKey:U.record(a,String(i)),queryFn:()=>e.get(a,String(i))})).record}return r[i.at(-1).field.name]??null}}),n2=(e,t,n)=>{let r=t.at(-1);return!e||!r?{state:`missing`}:t.length===1?{state:`ready`,value:e.record[r.field.name],field:r.field,model:r.model}:n.isPending?{state:`loading`}:{state:`ready`,value:n.data??null,field:r.field,model:r.model}},r2=(e,t)=>{let{resources:n}=G(),r=e2(n,e,t);return n2(e,r,Kh(t2(W(),Km(),e,t,r)))},Yhe=(e,t)=>{let{resources:n}=G(),r=W(),i=Km(),a=t.map(t=>e2(n,e,t)),o=Wh({queries:t.map((t,n)=>t2(r,i,e,t,a[n]))});return t.map((t,n)=>n2(e,a[n],o[n]))},i2=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>q(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},Xhe=({node:e})=>{let{name:t,label:n,format:r}=HT(e),{views:i}=G(),a=r2(bT(),t);if(a.state===`missing`)return null;let o=a.state===`loading`?(0,z.jsx)(Yu,{className:`h-4 w-24`}):(0,z.jsx)($0,{model:a.model,field:a.field,value:a.value,format:r});if(n===!1)return(0,z.jsx)(`div`,{children:o});let s=n??i2(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-body text-muted-foreground`,children:s}),(0,z.jsx)(`div`,{className:`mt-0.5 truncate`,children:o})]})},Zhe={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},Qhe={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},$he={1:``,2:`md:col-span-2`,3:`md:col-span-2 xl:col-span-3`,4:`sm:col-span-2 md:col-span-2 xl:col-span-4`},ege=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,tge=({node:e,children:t})=>{let{columns:n=2}=HT(e),r=e.children,i=r.length>0&&r.every(ege);return(0,z.jsx)(`div`,{className:g(`grid grid-cols-1 gap-4`,i?Qhe[n]:Zhe[n]),children:t.map((e,t)=>{let n=r[t],i=typeof n==`object`?n.props.span:void 0;return(0,z.jsx)(`div`,{className:g(`min-w-0`,i&&$he[i]),children:e},t)})})},a2=`font-medium text-primary-text hover:underline`,nge=({node:e})=>{let t=HT(e),n=bT()?.record,r=e.children.filter(e=>typeof e==`string`).join(``);if(t.to){let e=Kn(t.to,n);return(0,z.jsx)(jS,{to:e,className:a2,children:r||Cs(e)})}let i=t.href??``;return(0,z.jsx)(`a`,{href:i,className:a2,...i.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:r||i})},rge=(e,t,n)=>Object.fromEntries(t.map(t=>{let r=e.fields[t];if(r.type===`file`)return[t,n?.record[t]??null];if(n)return[t,r.type===`boolean`?!!n.record[t]:zS(n.record[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:zS(i)]})),ige=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return XS(r)?r.key===zS(n.record[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:GS(i,r,n.record[t])?[[t,HS(i,r)]]:[]})),age=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=G(),u=W(),d=Hb(),f=RT(),p=l[e.name],[m,h]=(0,L.useState)(()=>rge(e,a,t)),[g,_]=(0,L.useState)({}),[v,y]=(0,L.useState)(0),b=MC(v),[x,S]=(0,L.useState)(),[C,w]=(0,L.useState)(!1),T=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...QS(e,c,m),...o}):u.update(e.name,t.key,ige(e,m,t),t.etag??`*`)).then(async()=>{await f(e.name),d.show({state:`success`,title:Ig(`saved`,i??r)}),s()},e=>{let t=AC(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,z.jsx)(_p,{title:i??r,onClose:s,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:s,children:Ig(`cancel`)}),(0,z.jsx)(V,{variant:`primary`,loading:C,onClick:()=>void T(),children:Ig(n===`create`?`create`:`save`)})]}),children:(0,z.jsxs)(`form`,{ref:b,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),T()},children:[x!==void 0&&Object.keys(g).length===0&&(0,z.jsx)(rC,{title:Ig(`notSaved`),error:x}),a.map(n=>{let r=e.fields[n],i=m[n],a=r.relation?c[r.relation.resource]:void 0,o=p?.fields[n]?.label??q(n),s=g[n];return(0,z.jsx)(Gb,{name:n,label:o,help:p?.fields[n]?.help,error:s&&kC(r,o,s),children:(0,z.jsx)(SC,{field:r,hints:p?.fields[n],value:XS(i)?i.key:i,stored:t?.record[n],relationLabel:XS(i)?i.label:void 0,relationPicker:a?{target:a,view:l[a.name]}:void 0,invalid:!!g[n],resource:e.name,onChange:e=>{_(({[n]:e,...t})=>t),h(t=>({...t,[n]:e}))}})},n)})]})})},oge=({model:e,recordKey:t,children:n})=>{let r=IT(e,{key:t});return(0,z.jsx)(z.Fragment,{children:n(r.data??void 0)})},sge=({node:e})=>{let t=HT(e),n=bT(),{resources:r}=G(),i=r[t.resource??n?.model.name??``],a=cg(i?.name??``),[o,s]=(0,L.useState)(!1);if(!i||!(t.mode===`create`?xT(a,`create`):xT(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,z.jsx)(age,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,z.jsx)(oge,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},cge=({node:e,children:t,slots:n})=>{let{title:r,description:i}=HT(e);return(0,z.jsx)(`div`,{className:`flex-1`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-[1200px] flex-col gap-6 px-4 pb-16 pt-6 md:px-10 md:py-8`,children:[(0,z.jsx)(ef,{title:r,subtitle:i,actions:n.actions}),t]})})},o2=(e,t)=>{let n=bT(),r=r2(typeof e==`string`?n:void 0,typeof e==`string`?e:``);return typeof e==`number`?e:e===void 0?t:r.state===`ready`?Number(r.value):r.state===`loading`?void 0:NaN},lge=({node:e})=>{let{value:t,max:n,label:r}=HT(e),i=o2(t,0),a=o2(n,100);if(i===void 0||a===void 0)return(0,z.jsx)(Yu,{className:`h-6 w-full`});if(!Number.isFinite(i)||!Number.isFinite(a))return null;let o=a>0?Math.min(1,Math.max(0,i/a)):0;return(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:r}),(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[i.toLocaleString(l()),` / `,a.toLocaleString(l())]})]}),(0,z.jsx)(`div`,{role:`progressbar`,"aria-label":r,"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":a,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{className:o>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${o*100}%`}})})]})},uge=({model:e,filter:t,sort:n,recordKey:r,title:i,description:a,empty:o,actions:s,children:c})=>{let l=IT(e,{filter:t,sort:n,key:r}),u=e=>l.data?(0,z.jsx)(yT,{value:l.data,children:e}):void 0,d=l.isPending?(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(Yu,{className:`h-4 w-1/2`}),(0,z.jsx)(Yu,{className:`h-4 w-1/3`})]}):l.error?(0,z.jsx)(rC,{title:Ig(`couldNotLoad`),error:l.error}):l.data?u((0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:c})):(0,z.jsx)(KT,{children:o??Ig(`nothingYet`)});return(0,z.jsx)(GT,{title:i,description:a,actions:s?u(s):void 0,className:`h-full`,children:d})},dge=({node:e,children:t,slots:n})=>{let{resource:r,filter:i,sort:a,recordKey:o,title:s,description:c,empty:l}=HT(e),u=G().resources[r];return u?(0,z.jsx)(uge,{model:u,filter:i,sort:a,recordKey:o,title:s,description:c,empty:l,actions:n.actions,children:t}):null},s2=a({en:{firstOf:(e,t)=>`The first ${e} of ${t}.`,firstOfAbout:(e,t)=>`The first ${e} of about ${t}.`,open:e=>`Open ${e}`,edit:e=>`Edit ${e}`,viewAll:`View all`,couldNotLoad:`Could not load`,nothingYet:`Nothing here yet.`},nl:{firstOf:(e,t)=>`De eerste ${e} van ${t}.`,firstOfAbout:(e,t)=>`De eerste ${e} van ongeveer ${t}.`,open:e=>`${e} openen`,edit:e=>`${e} bewerken`,viewAll:`Alles bekijken`,couldNotLoad:`Kon niet laden`,nothingYet:`Hier staat nog niets.`}}),c2=(e,t,n)=>{if(!(e>=t))return s2(n?`firstOfAbout`:`firstOf`,e,t.toLocaleString(l()))},fge=`protobase:embedded-display:`,pge=e=>`${fge}${e}`,mge=(e,t)=>u(()=>e.getItem(t)??void 0,void 0),hge=(e,t,n)=>u(()=>e.setItem(t,n),void 0),l2=(e,t,{picked:n,preferred:r})=>{let i=_S(e).map(e=>e.name);return n!==void 0&&i.includes(n)?n:pS(e,t,r!==void 0&&i.includes(r)?r:void 0)},u2=(e,t,n,{resource:r=e.name,...i})=>kS({kind:`list`,resource:r},i,{...OS(e,t,n),display:pS(t,n)}),d2=a({en:{showMore:`Show more`,showLess:`Show less`,couldNotLoad:`Could not load`,nothingYet:`Nothing here yet.`},nl:{showMore:`Meer tonen`,showLess:`Minder tonen`,couldNotLoad:`Kon niet laden`,nothingYet:`Hier staat nog niets.`}}),gge=({children:e})=>{let t=(0,L.useRef)(null),[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(!1);return(0,L.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=()=>a(e.scrollHeight>e.parentElement.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[n]),(0,z.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,z.jsx)(`div`,{className:g(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,z.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,z.jsx)(V,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:d2(n?`showLess`:`showMore`)})]})},_ge=e=>e==null||e===``,vge=({scope:e,path:t})=>{let{views:n}=G(),r=r2(e,t);if(r.state===`missing`||r.state===`ready`&&_ge(r.value))return null;let i=i2(t,r.state===`ready`?n[r.model.name]?.fields[r.field.name]?.label:void 0);return(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:i}),(0,z.jsx)(`dd`,{className:`mt-0.5`,children:r.state===`loading`?(0,z.jsx)(Yu,{className:`h-4 w-24`}):(0,z.jsx)(gge,{children:(0,z.jsx)($0,{model:r.model,field:r.field,value:r.value})})})]})},yge=({scope:e,view:t,fields:n,actions:r})=>(0,z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[(0,z.jsx)(jS,{to:{kind:`record`,resource:e.model.name,key:Kx(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:Ux(e.model,t,e.record,e.key)}),n.length>0&&(0,z.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,z.jsx)(vge,{scope:e,path:t},t))}),r.length>0&&(0,z.jsx)(yT,{value:e,children:(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:r.map(e=>(0,z.jsx)(UT,{name:e},e))})})]}),f2=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,limit:o,display:s,empty:c})=>{let l=Nu(),u=r||wS(e,t),d=LT(e,{filter:n,sort:u,pageSize:o}),f=FT(e,n);if(d.isPending)return(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:2},(e,t)=>(0,z.jsx)(Yu,{className:`h-24 w-full`},t))});if(d.error)return(0,z.jsx)(rC,{title:d2(`couldNotLoad`),error:d.error});let p=d.data.items;if(p.length===0)return(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:c??d2(`nothingYet`)});let m=f.data===void 0?void 0:c2(p.length,f.data,!1);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,z.jsx)(`ul`,{className:`flex flex-col gap-3`,children:p.map(n=>{let r=NT(e,n);return(0,z.jsx)(yge,{scope:r,view:t,fields:i,actions:a},r.key)})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m}),(0,z.jsxs)(jS,{to:u2(e,t,l,{filter:n,orderBy:u,display:l2(t,l,{preferred:s})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[s2(`viewAll`),` `,(0,z.jsx)(`span`,{className:`sr-only`,children:(t?.names?.plural??q(e.name)).toLowerCase()}),(0,z.jsx)(Vr,{className:`size-3.5`,"aria-hidden":!0})]})]})]})},bge=({node:e,slots:t})=>{let{resource:n,filter:r=``,sort:i=``,fields:a,cardActions:o=[],limit:s=10,display:c,title:l,description:u,empty:d}=HT(e),{resources:f,views:p}=G(),m=f[n];if(!m)return null;let h=p[m.name];return(0,z.jsx)(`section`,{className:`min-w-0`,"aria-label":l,children:(0,z.jsx)(Kb,{title:l,help:u,actions:t.actions,children:(0,z.jsx)(f2,{model:m,view:h,filter:r,sort:i,fields:a??eS(m,h),actions:o,limit:s,display:c,empty:d})})})};function xge(e){return Sge(e)||typeof e==`function`||Cge(e)}function Sge(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Cge(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function p2(e,t){return e==null?null:xge(e)?L.createElement(e,t):e}function wge(e){if(`cell`in e&&e.cell){let t=e.cell,n=t.column.columnDef,r=t,i=n;return r.getIsAggregated?.()?p2(i.aggregatedCell??n.cell,t.getContext()):r.getIsPlaceholder?.()?null:p2(n.cell,t.getContext())}return`header`in e&&e.header?p2(e.header.column.columnDef.header,e.header.getContext()):`footer`in e&&e.footer?p2(e.footer.column.columnDef.footer,e.footer.getContext()):null}function Tge({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(1)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(1)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function Ege(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var m2=[],h2=0,{link:g2,unlink:Dge,propagate:Oge,checkDirty:_2,shallowPropagate:v2}=Tge({update(e){return e._update()},notify(e){m2[b2++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,C2(e))}}),y2=0,b2=0,x2,S2=0;function kge(e){try{++S2,e()}finally{--S2||w2()}}function C2(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Dge(n,e)}function w2(){if(!(S2>0)){for(;y2<b2;){let e=m2[y2];m2[y2++]=void 0,e.notify()}y2=0,b2=0}}function Age(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return x2!==void 0&&g2(i,x2,h2),i._snapshot},subscribe(e){let t=Ege(e),n={current:!1},r=jge(()=>{i.get(),n.current?(x2=void 0,t.next?.(i._snapshot)):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=x2,o=t?.compare??Object.is;if(n)x2=i,++h2,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{x2=a,n&&(i.flags&=-5),C2(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&_2(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&v2(e)}}else e&32&&(i.flags=e&-33);return x2!==void 0&&g2(i,x2,h2),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Oge(e),v2(e),w2())}},i}function jge(e){let t=()=>{let t=x2;x2=n,++h2,n.depsTail=void 0,n.flags=6;try{return e()}finally{x2=t,n.flags&=-5,C2(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&_2(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,C2(this)}};return t(),n}function T2(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=E2(e);if(n.length!==E2(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}function E2(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function Mge(e,t){return e===t}function D2(e,t=e=>e,n){let r=n?.compare??Mge,i=(0,L.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,L.useCallback)(()=>e.get(),[e]);return(0,zk.useSyncExternalStoreWithSelector)(i,a,a,t,r)}function Nge(e){let t=D2(e.source,e.selector,{compare:T2});return typeof e.children==`function`?e.children(t):e.children}function Pge(e){let t=e;return Object.defineProperty(e,"state",{get(){return e.get()}}),`set`in e&&(t.setState=e.set.bind(e)),t}function Fge(e){let{createAtom:t,batch:n}=e,r=t(0);return{createOptionsStore:!1,wrapExternalAtoms:!1,addSubscription:()=>{throw Error(`Feature not supported in current reactivity implementation`)},unmount:()=>{throw Error(`Feature not supported in current reactivity implementation`)},schedule:e.schedule??(e=>queueMicrotask(e)),batch:n,untrack:e=>e(),createReadonlyAtom:(e,n)=>{let i=n?.compare??Object.is,a=!1,o,s=()=>{let t=e();return(!a||!i(o,t))&&(o=t,a=!0),o},c=t(()=>(r.get(),s()),{compare:i});return{get:s,subscribe:c.subscribe.bind(c)}},createWritableAtom:(e,n)=>t(e,{compare:n?.compare}),commit:()=>{r.set(e=>e+1)}}}function Ige(e,t=Object.is){let n=!1,r;return{get:e.get,markCommitted:e=>{r=e,n=!0},subscribe:i=>e.subscribe(e=>{(!n||!t(r,e))&&i(e)})}}function Lge(){return Fge({createAtom:Age,batch:kge})}function O2(e,t){return typeof e==`function`?e(t):e}function k2(e){if(Array.isArray(e))return e.map(k2);if(e&&typeof e==`object`){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=t===null?A2():{},r=Object.keys(e);for(let t=0;t<r.length;t++){let i=r[t];Object.defineProperty(n,i,{configurable:!0,enumerable:!0,value:k2(e[i]),writable:!0})}return n}return e}function Rge(e,t){let n=Object.keys(t),r=e;for(let e=0;e<n.length;e++){let i=n[e];!i.startsWith(`_memo_`)&&i!==`_cellsCache`&&(r[i]=t[i])}return e}function A2(){return Object.create(null)}function j2(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function M2(e,t){return n=>{(t.options.atoms?.[e]??t.baseAtoms[e]).set(e=>O2(n,e))}}function N2(e){if(typeof e!=`object`||!e)return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function P2(e){return Reflect.ownKeys(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}var zge=3;function Bge(e,t){return F2(e,t,zge)}function F2(e,t,n){if(Object.is(e,t))return!0;if(n<=0||!N2(e)||!N2(t)||(Array.isArray(e)||Array.isArray(t))&&(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length))return!1;let r=P2(e),i=P2(t);if(r.length!==i.length)return!1;let a=e,o=t;for(let e=0;e<r.length;e++){let i=r[e];if(!Object.prototype.propertyIsEnumerable.call(t,i)||!F2(a[i],o[i],n-1))return!1}return!0}function I2(e,t,n,r=Bge){let i=`on${t.charAt(0).toUpperCase()}${t.slice(1)}Change`,a=e.options[i];a&&a(e=>{let t=O2(n,e);return r(e,t)?e:t})}function Vge(e){return e instanceof Function}function Hge(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i.length&&r(i)})};return r(e),n}var Uge=({fn:e,memoDeps:t,onAfterCompare:n,onAfterUpdate:r,onBeforeCompare:i,onBeforeUpdate:a})=>{let o=[],s;return c=>{i?.();let l=t?.(c),u=!l||l.length!==o?.length;if(!u&&l){for(let e=0;e<l.length;e++)if(l[e]!==o[e]){u=!0;break}}return n?.(u),u?(o=l,a?.(),s=e(...l??[]),r?.(s),s):s}};function Wge(e){let t=!1;return()=>{if(!t){t=!0;return}e()}}function L2({feature:e,fnName:t,objectId:n,onAfterUpdate:r,table:i,...a}){let o=()=>{if(!r)return;let{schedule:e,untrack:t}=i._reactivity;e(()=>t(()=>r()))},s={onAfterUpdate:()=>{o()}};return Uge({...a,...s})}function R2(e,t=`_`){let[n,r]=e.split(t);return{fnKey:r,fnName:`${n}.${r}`,parentName:n}}function z2(e,t,n){for(let[r,{fn:i,memoDeps:a}]of Object.entries(n)){let{fnKey:n,fnName:o}=R2(r);t[n]=a?L2({memoDeps:a,fn:i,fnName:o,table:t,feature:e}):i}}function B2(e,t,n,r){for(let[i,{fn:a,memoDeps:o}]of Object.entries(r)){let{fnKey:r,fnName:s}=R2(i);if(o){let i=`_memo_${r}`;t[r]=function(...t){if(!this[i]){let t=this;this[i]=L2({memoDeps:e=>o(t,e),fn:(...e)=>a(t,...e),fnName:s,objectId:t.id,table:n,feature:e})}return this[i](...t)}}else t[r]=function(...e){return a(this,...e)}}}function V2(e,t,n,...r){return e[t]?.(...r)??n(e,...r)}function Gge(e){return e.row.getValue(e.column.id)}function Kge(e){return e.getValue()??e.table.options.renderFallbackValue}function qge(e){return{table:e.table,column:e.column,row:e.row,cell:e,getValue:()=>e.getValue(),renderValue:()=>e.renderValue()}}var Jge={assignCellPrototype:(e,t)=>{B2(`coreCellsFeature`,e,t,{cell_getValue:{fn:e=>Gge(e)},cell_renderValue:{fn:e=>Kge(e)},cell_getContext:{fn:e=>qge(e),memoDeps:e=>[e]}})}};function Yge(e){if(!e._headerPrototype){e._headerPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignHeaderPrototype?.(e._headerPrototype,e)}return e._headerPrototype}function H2(e,t,n){let r=Yge(e),i=Object.create(r);i.colSpan=0,i.column=t,i.depth=n.depth,i.headerGroup=null,i.id=n.id??t.id,i.index=n.index,i.isPlaceholder=!!n.isPlaceholder,i.placeholderId=n.placeholderId,i.rowSpan=0,i.subHeaders=[];let a=e._headerInstanceInitFns;for(let e=0;e<a.length;e++)a[e](i);return i}function Xge(){return{start:[],end:[]}}function U2(e){let t=e.table.atoms.columnVisibility?.get();if(!t)return!0;let n=e.columns;return n.length?n.some(e=>V2(e,`getIsVisible`,U2)):(j2(t,e.id)?t[e.id]:void 0)??!0}function Zge(e){return e.getAllLeafColumns().filter(e=>V2(e,`getIsVisible`,U2))}function W2(e,t=1){let n=t;for(let r=0;r<e.length;r++){let i=e[r];V2(i,`getIsVisible`,U2)&&i.columns.length&&(n=Math.max(n,W2(i.columns,t+1)))}return n}function Qge(e,t){return e?`${e}_${t}`:String(t)}function $ge(e,t,n,r){let i=e??``;return t&&(i=i?`${i}_${t}`:String(t)),n&&(i=i?`${i}_${n}`:n),r&&(i=i?`${i}_${r}`:r),i}function e_e(e,t){let n=0;for(let r=0;r<e.length;r++)e[r].column===t&&n++;return n}function G2(e,t,n,r,i,a){let o={depth:t,id:Qge(r,t),headers:[]},s=[];for(let i=0;i<e.length;i++){if(!(i in e))continue;let a=e[i],c=s[s.length-1],l=a.column.depth===o.depth,u,d=!1;if(l&&a.column.parent?u=a.column.parent:(u=a.column,d=!0),c&&c.column===u)c.subHeaders.push(a);else{let e=H2(n,u,{id:$ge(r,t,u.id,a.id),isPlaceholder:d,placeholderId:d?String(e_e(s,u)):void 0,depth:t,index:s.length});e.subHeaders.push(a),s.push(e)}o.headers.push(a),a.headerGroup=o}for(let e=0;e<a.length;e++)a[e](o);i.push(o),t>0&&G2(s,t-1,n,r,i,a)}function K2(e){for(let t=0;t<e.length;t++){let n=e[t];if(!V2(n.column,`getIsVisible`,U2))continue;let r=0;if(n.subHeaders.length){K2(n.subHeaders);for(let e=0;e<n.subHeaders.length;e++){let t=n.subHeaders[e];V2(t.column,`getIsVisible`,U2)&&(r+=t.colSpan)}}else r=1;if(n.colSpan=r,n.isPlaceholder&&n.subHeaders.length===1&&n.subHeaders[0].column===n.column){let e=1,t=n.subHeaders[0];for(;t;)t.rowSpan=0,e++,t=t.subHeaders.length===1&&t.subHeaders[0].column===n.column?t.subHeaders[0]:void 0;n.rowSpan=e}else n.rowSpan=1}}function q2(e,t,n,r){let i=W2(e),a=[],o=n._headerGroupInstanceInitFns,s=Array(t.length);for(let e=0;e<t.length;e++)e in t&&(s[e]=H2(n,t[e],{depth:i,index:e}));return G2(s,i-1,n,r,a,o),a.reverse(),K2(a[0]?.headers??[]),a}function t_e(e){if(!e._columnPrototype){e._columnPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignColumnPrototype?.(e._columnPrototype,e)}return e._columnPrototype}function n_e(e,t,n,r){let i={...e.getDefaultColumnDef(),...t},a=i.accessorKey,o=a===void 0?void 0:String(a),s=i.id??o?.replaceAll(`.`,`_`)??(typeof i.header==`string`?i.header:void 0),c;if(i.accessorFn)c=i.accessorFn;else if(a!==void 0){if(typeof a==`string`&&a.includes(`.`)){let e=a.split(`.`);c=t=>{let n=t;for(let t=0;t<e.length;t++){let r=e[t];n=n?.[r]}return n}}else c=e=>e[i.accessorKey]}if(!s)throw Error();let l=t_e(e),u=Object.create(l);u.accessorFn=c,u.columnDef=i,u.columns=[],u.depth=n,u.id=`${String(s)}`,u.parent=r;let d=e._columnInstanceInitFns;for(let e=0;e<d.length;e++)d[e](u);return u}function J2(e){let t=e.atoms.columnOrder?.get();return n=>{let r=[];if(!t?.length)r=n;else{let e=new Map;for(let t=0;t<n.length;t++){let r=n[t];e.set(r.id,r)}for(let n=0;n<t.length;n++){let i=t[n],a=e.get(i);a&&(r.push(a),e.delete(i))}for(let t=0;t<n.length;t++){let i=n[t];e.has(i.id)&&r.push(i)}}return r_e(e,r)}}function r_e(e,t){let n=e.atoms.grouping?.get()??[],{groupedColumnMode:r}=e.options;if(!n.length||!r)return t;let i=t.filter(e=>!n.includes(e.id));if(r===`remove`)return i;let a=new Map;for(let e=0;e<t.length;e++){let n=t[e];a.set(n.id,n)}let o=[];for(let e=0;e<n.length;e++){let t=a.get(n[e]);t&&o.push(t)}return[...o,...i]}function i_e(e){return[e,...e.columns.flatMap(e=>e.getFlatColumns())]}function a_e(e){if(e.columns.length){let t=e.columns.flatMap(e=>e.getLeafColumns());return V2(e.table,`getOrderColumns`,J2)(t)}return[e]}function o_e(e){return{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>e.renderValue()?.toString?.()??null,...Object.values(e._features).reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef?.()),{}),...e.options.defaultColumn}}function Y2(e,t,n,r=0){let i=Array(t.length);for(let a=0;a<t.length;a++){if(!(a in t))continue;let o=t[a],s=n_e(e,o,r,n),c=o;s.columns=c.columns?Y2(e,c.columns,s,r+1):[],i[a]=s}return i}function s_e(e){return Y2(e,e.options.columns)}function c_e(e){return e.getAllColumns().flatMap(e=>e.getFlatColumns())}function l_e(e){let t=A2(),n=e.getAllFlatColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function u_e(e){let t=e.getAllColumns().flatMap(e=>e.getLeafColumns());return V2(e,`getOrderColumns`,J2)(t)}function d_e(e){let t=A2(),n=e.getAllLeafColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function f_e(e,t){return e.getAllFlatColumnsById()[t]}var p_e={assignColumnPrototype:(e,t)=>{B2(`coreColumnsFeature`,e,t,{column_getFlatColumns:{fn:e=>i_e(e),memoDeps:e=>[e.table.options.columns]},column_getLeafColumns:{fn:e=>a_e(e),memoDeps:e=>[e.table.atoms.columnOrder?.get(),e.table.atoms.grouping?.get(),e.table.options.columns,e.table.options.groupedColumnMode]}})},constructTableAPIs:e=>{z2(`coreColumnsFeature`,e,{table_getDefaultColumnDef:{fn:()=>o_e(e),memoDeps:()=>[e.options.defaultColumn]},table_getAllColumns:{fn:()=>s_e(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumns:{fn:()=>c_e(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumnsById:{fn:()=>l_e(e),memoDeps:()=>[e.options.columns]},table_getAllLeafColumns:{fn:()=>u_e(e),memoDeps:()=>[e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.columns,e.options.groupedColumnMode]},table_getAllLeafColumnsById:{fn:()=>d_e(e),memoDeps:()=>[e.getAllLeafColumns()]},table_getColumn:{fn:t=>f_e(e,t)}})}};function X2(e,t){for(let n=0;n<e.subHeaders.length;n++)X2(e.subHeaders[n],t);t.push(e)}function m_e(e){let t=[];return X2(e,t),t}function h_e(e){return{column:e.column,header:e,table:e.column.table}}function g_e(e){let{start:t,end:n}=e.atoms.columnPinning?.get()??Xge(),r=e.getAllColumns(),i=V2(e,`getVisibleLeafColumns`,Zge);if(!t.length&&!n.length)return q2(r,i,e);let a=e.getAllLeafColumnsById(),o=[];for(let e=0;e<t.length;e++){let n=a[t[e]];n&&V2(n,`getIsVisible`,U2)&&o.push(n)}let s=[];for(let e=0;e<n.length;e++){let t=a[n[e]];t&&V2(t,`getIsVisible`,U2)&&s.push(t)}let c=i.filter(e=>!t.includes(e.id)&&!n.includes(e.id));return q2(r,[...o,...c,...s],e)}function __e(e){return[...e.getHeaderGroups()].reverse()}function v_e(e){let t=e.getHeaderGroups(),n=[];for(let e=0;e<t.length;e++){let r=t[e].headers;for(let e=0;e<r.length;e++)n.push(r[e])}return n}function y_e(e){let t=e.getHeaderGroups()[0]?.headers??[],n=[];for(let e=0;e<t.length;e++){let r=t[e].getLeafHeaders();for(let e=0;e<r.length;e++)n.push(r[e])}return n}var b_e={assignHeaderPrototype:(e,t)=>{B2(`coreHeadersFeature`,e,t,{header_getLeafHeaders:{fn:e=>m_e(e),memoDeps:e=>[e.column.table.options.columns]},header_getContext:{fn:e=>h_e(e),memoDeps:e=>[e.column.table.options.columns]}})},constructTableAPIs:e=>{z2(`coreHeadersFeature`,e,{table_getHeaderGroups:{fn:()=>g_e(e),memoDeps:()=>[e.options.columns,e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.options.groupedColumnMode]},table_getFooterGroups:{fn:()=>__e(e),memoDeps:()=>[e.getHeaderGroups()]},table_getFlatHeaders:{fn:()=>v_e(e),memoDeps:()=>[e.getHeaderGroups()]},table_getLeafHeaders:{fn:()=>y_e(e),memoDeps:()=>[e.getHeaderGroups()]}})}};function x_e(e){if(!e._rowPrototype){e._rowPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignRowPrototype?.(e._rowPrototype,e)}return e._rowPrototype}var S_e=(e,t,n,r,i,a,o)=>{let s=x_e(e),c=Object.create(s);c._displayIndexCache=-1,c._uniqueValuesCache=A2(),c._valuesCache=A2(),c.depth=i,c.id=t,c.index=r,c.original=n,c.parentId=o,c.subRows=a??[];let l=e._rowInstanceInitFns;for(let e=0;e<l.length;e++)l[e](c);return c},C_e=/([0-9]+)/gm;function Z2(e){let t=Object.assign((e,n,r)=>{let i=e.getValue(r),a=n.getValue(r),o=t.resolveDataValue;return o&&(i=o(i),a=o(a)),t.sort(i,a,e,n,r)},e);return t}Z2({resolveDataValue:e=>e4(e).toLowerCase(),sort:(e,t)=>t4(e,t)}),Z2({resolveDataValue:e=>e4(e),sort:(e,t)=>t4(e,t)}),Z2({resolveDataValue:e=>e4(e).toLowerCase(),sort:(e,t)=>$2(e,t)}),Z2({resolveDataValue:e=>e4(e),sort:(e,t)=>$2(e,t)}),Z2({resolveDataValue:e=>w_e(e),sort:(e,t)=>e>t?1:e<t?-1:0});var Q2=Z2({sort:(e,t)=>$2(e,t)});function $2(e,t){return e===t?0:e>t?1:-1}function w_e(e){return e instanceof Date?e.getTime():e}function e4(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function t4(e,t){let n=0,r=0,i=e.length,a=t.length;for(;n<i&&r<a;){let i=n4(e.charCodeAt(n)),a=n4(t.charCodeAt(r)),o=r4(e,n,i),s=r4(t,r,a);if(!i&&!a){let i=T_e(e,n,o,t,r,s);if(i)return i;n=o,r=s;continue}if(i!==a)return i?1:-1;let c=E_e(e,n,o,t,r,s);if(c)return c;n=o,r=s}return a4(e,n)-a4(t,r)}function n4(e){return e>=48&&e<=57}function r4(e,t,n){let r=t+1;for(;r<e.length&&n4(e.charCodeAt(r))===n;)r++;return r}function T_e(e,t,n,r,i,a){let o=n-t,s=a-i,c=o<s?o:s;for(let n=0;n<c;n++){let a=e.charCodeAt(t+n),o=r.charCodeAt(i+n);if(a>o)return 1;if(o>a)return-1}return o>s?1:s>o?-1:0}function E_e(e,t,n,r,i,a){let o=t;for(;o<n&&e.charCodeAt(o)===48;)o++;let s=i;for(;s<a&&r.charCodeAt(s)===48;)s++;let c=n-o,l=a-s;if(c===0&&l===0)return 0;if(c<=15&&l<=15){let t=i4(e,o,n),i=i4(r,s,a);return t>i?1:i>t?-1:0}let u=parseInt(e.slice(t,n),10),d=parseInt(r.slice(i,a),10);return u>d?1:d>u?-1:0}function i4(e,t,n){let r=0;for(let i=t;i<n;i++)r=r*10+e.charCodeAt(i)-48;return r}function a4(e,t){let n=0,r=t;for(;r<e.length;)n++,r=r4(e,r,n4(e.charCodeAt(r)));return n}function o4(){return[]}function D_e(e,t){I2(e,`cellSelection`,t?o4():k2(e.initialState.cellSelection)??o4())}function O_e(e){e.atoms.cellSelection&&(e.options.autoResetAll??e.options.autoResetCellSelection??!0)&&e._reactivity.schedule(()=>D_e(e))}function k_e(e){e.atoms.expanded&&(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding)&&e._reactivity.schedule(()=>A_e(e))}function A_e(e,t){let n=e.initialState.expanded;I2(e,`expanded`,t?A2():n===!0||Object.assign(A2(),k2(n??{})))}var s4=0;function j_e(e){if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if((e.atoms.pagination?.get()?.pageIndex??s4)===s4)return;P_e(e,!0)}}function M_e(e,t){I2(e,`pagination`,t)}function N_e(e,t){M_e(e,n=>{let r=O2(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})}function P_e(e,t){N_e(e,t?s4:e.initialState.pagination?.pageIndex??s4)}function F_e(){return[]}function c4(e,t){I2(e,`sorting`,t)}function l4(e,t){c4(e,t?[]:k2(e.initialState.sorting??[]))}function I_e(e){e.atoms.sorting&&(e.options.autoResetAll??e.options.autoResetSorting??!1)&&l4(e)}function u4(e){let t=e.table._rowModelFns.sortFns,n=e.table.getFilteredRowModel().flatRows.slice(0,10),r,i=!1;for(let t=0;t<n.length;t++){let a=n[t].getValue(e.id);if(Object.prototype.toString.call(a)===`[object Date]`){r=`datetime`;break}if(typeof a==`string`&&(i=!0,a.split(C_e).length>1)){r=`alphanumeric`;break}}if(!r&&i&&(r=`text`),r){let e=t?.[r];if(e||r===`alphanumeric`&&(e=t?.text),e)return e}return Q2}function d4(e){let t=e.table.getFilteredRowModel().flatRows.slice(0,10);for(let n=0;n<t.length;n++){let r=t[n].getValue(e.id);if(r!=null)return typeof r==`string`?`asc`:`desc`}return`desc`}function L_e(e){let t=e.table._rowModelFns.sortFns;return Vge(e.columnDef.sortFn)?e.columnDef.sortFn:e.columnDef.sortFn===`auto`?u4(e):t?.[e.columnDef.sortFn]??Q2}function f4(e,t,n){let r=m4(e,n&&g4(e)),i=t!==void 0;c4(e.table,a=>{let o=a.findIndex(t=>t.id===e.id),s=o===-1?void 0:a[o],c=[],l,u=i?t:r===`desc`,d=!!(a.length&&g4(e)&&n);return l=d?s?`toggle`:`add`:s?`toggle`:`replace`,l===`toggle`&&(i||r||(l=`remove`)),l===`add`?(c=[...a,{id:e.id,desc:u}],c.splice(0,c.length-(e.table.options.maxMultiSortColCount??2**53-1))):c=l===`toggle`?d?a.map(t=>t.id===e.id?{...t,desc:u}:t):[{id:e.id,desc:u}]:l===`remove`?d?a.filter(t=>t.id!==e.id):[]:[{id:e.id,desc:u}],c})}function p4(e){return e.columnDef.sortDescFirst??e.table.options.sortDescFirst??d4(e)===`desc`?`desc`:`asc`}function m4(e,t){let n=p4(e),r=_4(e);return r?r!==n&&(e.table.options.enableSortingRemoval??!0)&&(!t||(e.table.options.enableMultiRemove??!0))?!1:r===`desc`?`asc`:`desc`:n}function h4(e){return(e.columnDef.enableSorting??!0)&&(e.table.options.enableSorting??!0)&&!!e.accessorFn}function g4(e){return e.columnDef.enableMultiSort??e.table.options.enableMultiSort??!!e.accessorFn}function _4(e){let t=e.table.atoms.sorting?.get()?.find(t=>t.id===e.id);return t?t.desc?`desc`:`asc`:!1}function R_e(e){return e.table.atoms.sorting?.get()?.findIndex(t=>t.id===e.id)??-1}function z_e(e){c4(e.table,t=>t.length?t.filter(t=>t.id!==e.id):[])}function B_e(e){let t=h4(e);return n=>{t&&f4(e,void 0,g4(e)?e.table.options.isMultiSortEvent?.(n):!1)}}function V_e(){return e=>L2({feature:`coreRowModelsFeature`,table:e,fnName:`table.getCoreRowModel`,memoDeps:()=>[e.options.data],fn:()=>H_e(e,e.options.data),onAfterUpdate:Wge(()=>{k_e(e),j_e(e),I_e(e),O_e(e)})})}function v4(e,t,n,r=0,i){let a=[];for(let o=0;o<n.length;o++){let s=n[o],c=S_e(e,e.getRowId(s,o,i),s,o,r,void 0,i?.id);t.flatRows.push(c),t.rowsById[c.id]=c,a.push(c),e.options.getSubRows&&(c.originalSubRows=e.options.getSubRows(s,o),c.originalSubRows?.length&&(c.subRows=v4(e,t,c.originalSubRows,r+1,c)))}return a}function H_e(e,t){let n={rows:[],flatRows:[],rowsById:A2()};return n.rows=v4(e,n,t),n}function U_e(e){return e._rowModels.coreRowModel||(e._rowModels.coreRowModel=e.options.features.coreRowModel?.(e)??V_e()(e)),e._rowModels.coreRowModel()}function W_e(e){return e.getCoreRowModel()}function G_e(e){return e._rowModels.filteredRowModel||(e._rowModels.filteredRowModel=e.options.features.filteredRowModel?.(e)),e.options.manualFiltering||!e._rowModels.filteredRowModel?e.getPreFilteredRowModel():e._rowModels.filteredRowModel()}function K_e(e){return e.getFilteredRowModel()}function q_e(e){return e._rowModels.groupedRowModel||(e._rowModels.groupedRowModel=e.options.features.groupedRowModel?.(e)),e.options.manualGrouping||!e._rowModels.groupedRowModel?e.getPreGroupedRowModel():e._rowModels.groupedRowModel()}function J_e(e){return e.getGroupedRowModel()}function Y_e(e){return e._rowModels.sortedRowModel||(e._rowModels.sortedRowModel=e.options.features.sortedRowModel?.(e)),e.options.manualSorting||!e._rowModels.sortedRowModel?e.getPreSortedRowModel():e._rowModels.sortedRowModel()}function X_e(e){return e.getSortedRowModel()}function Z_e(e){return e._rowModels.expandedRowModel||(e._rowModels.expandedRowModel=e.options.features.expandedRowModel?.(e)),e.options.manualExpanding||!e._rowModels.expandedRowModel?e.getPreExpandedRowModel():e._rowModels.expandedRowModel()}function Q_e(e){return e.getExpandedRowModel()}function $_e(e){return e._rowModels.paginatedRowModel||(e._rowModels.paginatedRowModel=e.options.features.paginatedRowModel?.(e)),e.options.manualPagination||!e._rowModels.paginatedRowModel?e.getPrePaginatedRowModel():e._rowModels.paginatedRowModel()}function eve(e){return e.getPaginatedRowModel()}var tve={constructTableAPIs:e=>{z2(`coreRowModelsFeature`,e,{table_getCoreRowModel:{fn:()=>U_e(e)},table_getPreFilteredRowModel:{fn:()=>W_e(e)},table_getFilteredRowModel:{fn:()=>G_e(e)},table_getPreGroupedRowModel:{fn:()=>K_e(e)},table_getGroupedRowModel:{fn:()=>q_e(e)},table_getPreSortedRowModel:{fn:()=>J_e(e)},table_getSortedRowModel:{fn:()=>Y_e(e)},table_getPreExpandedRowModel:{fn:()=>X_e(e)},table_getExpandedRowModel:{fn:()=>Z_e(e)},table_getPrePaginatedRowModel:{fn:()=>Q_e(e)},table_getPaginatedRowModel:{fn:()=>$_e(e)},table_getRowModel:{fn:()=>eve(e)}})}};function nve(e){if(!e._cellPrototype){e._cellPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignCellPrototype?.(e._cellPrototype,e)}return e._cellPrototype}function rve(e,t,n){let r=nve(n),i=Object.create(r);i.column=e,i.id=`${t.id}_${e.id}`,i.row=t;let a=n._cellInstanceInitFns;for(let e=0;e<a.length;e++)a[e](i);return i}function ive(e){let t=e.table.getRowsInDisplayOrder(),n=e._displayIndexCache;return t[n]===e?n:-1}function ave(e){let t=e.getPrePaginatedRowModel().rows;if(e.options.paginateExpandedRows===!1){let e=[],n=t=>{t._displayIndexCache=e.length,e.push(t),t.subRows.length&&t.getIsExpanded?.()&&t.subRows.forEach(n)};return t.forEach(n),e}for(let e=0;e<t.length;e++)t[e]._displayIndexCache=e;return t}function ove(e,t){if(j2(e._valuesCache,t))return e._valuesCache[t];let n=e.table.getColumn(t);if(n?.accessorFn)return e._valuesCache[t]=n.accessorFn(e.original,e.index),e._valuesCache[t]}function sve(e,t){if(j2(e._uniqueValuesCache,t))return e._uniqueValuesCache[t];let n=e.table.getColumn(t);if(n?.accessorFn)return n.columnDef.getUniqueValues?(e._uniqueValuesCache[t]=n.columnDef.getUniqueValues(e.original,e.index),e._uniqueValuesCache[t]):(e._uniqueValuesCache[t]=[e.getValue(t)],e._uniqueValuesCache[t])}function cve(e,t){return e.getValue(t)??e.table.options.renderFallbackValue}function lve(e){return Hge(e.subRows,e=>e.subRows)}function uve(e){let t=e.getCoreRowModel().flatRows,n=0;for(let e=0;e<t.length;e++)n=Math.max(n,t[e].depth);return n}function dve(e){if(e.parentId)return e.table.getCoreRowModel().rowsById[e.parentId]??e.table.getRow(e.parentId,!0)}function fve(e){let t=[],n=e;for(;;){let e=n.getParentRow();if(!e)break;t.push(e),n=e}return t.reverse()}function pve(e){let t=e.table.getAllLeafColumns(),n=e._cellsCache;n||=e._cellsCache=new WeakMap;let r=Array(t.length);for(let i=0;i<t.length;i++){let a=t[i],o=n.get(a);o||(o=rve(a,e,e.table),n.set(a,o)),r[i]=o}return r}function mve(e){let t=A2(),n=e.getAllCells();for(let e=0;e<n.length;e++){let r=n[e];t[r.column.id]=r}return t}function hve(e,t,n,r){return t.options.getRowId?.(e,n,r)??(r?`${r.id}.${n}`:String(n))}function gve(e,t,n){let r=(n?e.getPrePaginatedRowModel():e.getRowModel()).rowsById[t];if(!r&&(r=e.getCoreRowModel().rowsById[t],!r))throw Error();return r}var _ve={assignRowPrototype:(e,t)=>{B2(`coreRowsFeature`,e,t,{row_getDisplayIndex:{fn:e=>ive(e)},row_getAllCellsByColumnId:{fn:e=>mve(e),memoDeps:e=>[e.getAllCells()]},row_getAllCells:{fn:e=>pve(e),memoDeps:e=>[e.table.getAllLeafColumns()]},row_getLeafRows:{fn:e=>lve(e),memoDeps:e=>[e.subRows]},row_getParentRow:{fn:e=>dve(e)},row_getParentRows:{fn:e=>fve(e)},row_getUniqueValues:{fn:(e,t)=>sve(e,t)},row_getValue:{fn:(e,t)=>ove(e,t)},row_renderValue:{fn:(e,t)=>cve(e,t)}})},constructTableAPIs:e=>{z2(`coreRowsFeature`,e,{table_getRowsInDisplayOrder:{fn:()=>ave(e),memoDeps:()=>[e.getPrePaginatedRowModel().rows,e.options.paginateExpandedRows,e.options.paginateExpandedRows===!1?e.atoms.expanded?.get():void 0]},table_getRowId:{fn:(t,n,r)=>hve(t,e,n,r)},table_getRow:{fn:(t,n)=>gve(e,t,n)},table_getMaxSubRowDepth:{fn:()=>uve(e),memoDeps:()=>[e.getCoreRowModel()]}})}};function y4(e,t,n=(e,t)=>e===t){let r=t===void 0?e.options.state:t;e._reactivity.batch(()=>{if(r)for(let t in r){let i=e.baseAtoms[t];if(!i)continue;let a=r[t],o=a===void 0?e.initialState[t]:a;n(e._reactivity.untrack(()=>i.get()),o)||i.set(()=>o)}})}function b4(e,t,n=(e,t)=>e===t){e._reactivity.batch(()=>{y4(e,t,n),e._reactivity.commit?.()})}function vve(e){let t=k2(e.initialState);e._reactivity.batch(()=>{let n=Object.keys(t);for(let r=0;r<n.length;r++){let i=n[r];e.baseAtoms[i].set(t[i])}});let n=Object.values(e._features);for(let t=0;t<n.length;t++)n[t].resetTableInstanceData?.(e)}function yve(e,t){let{features:n,atoms:r,initialState:i}=e.options;if(!e.options.mergeOptions)return{...e.options,...t,features:n,atoms:r,initialState:i};let a=e.options.mergeOptions(e.options,t),o={...Object.getOwnPropertyDescriptors(a)};return Object.defineProperties(Object.create(Object.getPrototypeOf(a)),{...o,features:{value:n,enumerable:!0,configurable:!0,writable:!0},atoms:{value:r,enumerable:!0,configurable:!0,writable:!0},initialState:{value:i,enumerable:!0,configurable:!0,writable:!0}})}function x4(e,t,n){let r=yve(e,O2(t,e.options));e.optionsStore?e.optionsStore.set(()=>r):e.options=r,n?.syncExternalState!==!1&&b4(e,r.state??null)}var bve={coreCellsFeature:Jge,coreColumnsFeature:p_e,coreHeadersFeature:b_e,coreRowModelsFeature:tve,coreRowsFeature:_ve,coreTablesFeature:{constructTableAPIs:e=>{z2(`coreTablesFeature`,e,{table_reset:{fn:()=>vve(e)},table_setOptions:{fn:t=>x4(e,t)}})}}};function xve(){return{accessor:(e,t)=>typeof e==`function`?{...t,accessorFn:e}:{...t,accessorKey:e},columns:e=>e,display:e=>e,group:e=>e}}function Sve(e){return e}function Cve(e,t={}){return Object.values(e).forEach(e=>{t=e.getInitialState?.(t)??t}),k2(t)}function wve(e){let t=e.features.coreReactivityFeature,{aggregationFns:n,columnMeta:r,coreRowModel:i,expandedRowModel:a,facetedMinMaxValues:o,facetedRowModel:s,facetedUniqueValues:c,filterFns:l,filterMeta:u,filteredRowModel:d,groupedRowModel:f,paginatedRowModel:p,sortFns:m,sortedRowModel:h,tableMeta:g,..._}=e.features,v={_cellInstanceInitFns:[],_columnInstanceInitFns:[],_features:{...bve,..._},_headerGroupInstanceInitFns:[],_headerInstanceInitFns:[],_reactivity:t,_rowInstanceInitFns:[],_rowModelFns:{aggregationFns:n,filterFns:l,sortFns:m},_rowModels:{},atoms:{},baseAtoms:{}},y=Object.values(v._features),b={...y.reduce((e,t)=>Object.assign(e,t.getDefaultTableOptions?.(v)),{}),...e};if(t.wrapExternalAtoms&&b.atoms)for(let[e,n]of Object.entries(b.atoms)){let r=n,i=t.createWritableAtom(r.get(),{debugName:`externalAtom/${e}`});b.atoms[e]=i;let a=!1,o=r.subscribe(e=>{a||i.set(e)}),s=i.subscribe(e=>{a=!0,r.set(e),a=!1});t.addSubscription(o),t.addSubscription(s)}t.createOptionsStore?(v.optionsStore=t.createWritableAtom(b,{debugName:`table/optionsStore`}),Object.defineProperty(v,"options",{configurable:!0,enumerable:!0,get(){return v.optionsStore.get()},set(e){v.optionsStore.set(()=>e)}})):v.options=b,v.initialState=Cve(v._features,v.options.initialState);let x=Object.keys(v.initialState);for(let e=0;e<x.length;e++){let n=x[e];v.baseAtoms[n]=t.createWritableAtom(v.initialState[n],{debugName:`table/baseAtoms/${n}`}),v.atoms[n]=t.createReadonlyAtom(()=>{let e=v.options,t=e.atoms?.[n],r=t?t.get():v.baseAtoms[n].get();if(t)return r;let i=e.state;if(i&&j2(i,n)){let e=i[n];return e===void 0?v.initialState[n]:e}return r},{debugName:`table/atoms/${n}`})}y4(v),v.store=Pge(t.createReadonlyAtom(()=>{let e={};for(let t=0;t<x.length;t++){let n=x[t];e[n]=v.atoms[n].get()}return e},{compare:T2,debugName:`table/store`}));for(let e=0;e<y.length;e++){let t=y[e];t.initTableInstanceData?.(v),t.initCellInstanceData&&v._cellInstanceInitFns.push(t.initCellInstanceData.bind(t)),t.initColumnInstanceData&&v._columnInstanceInitFns.push(t.initColumnInstanceData.bind(t)),t.initHeaderGroupInstanceData&&v._headerGroupInstanceInitFns.push(t.initHeaderGroupInstanceData.bind(t)),t.initHeaderInstanceData&&v._headerInstanceInitFns.push(t.initHeaderInstanceData.bind(t)),t.initRowInstanceData&&v._rowInstanceInitFns.push(t.initRowInstanceData.bind(t)),t.constructTableAPIs?.(v)}return v}function Tve(){return A2()}function S4(e,t){e.options.onRowSelectionChange?.(t)}function Eve(e,t){e._lastSelectedRowId=null,S4(e,t?A2():Object.assign(A2(),k2(e.initialState.rowSelection??{})))}function C4(e,t,n){e._lastSelectedRowId=null,S4(e,r=>{if(t=t===void 0?!V2(e,`getIsAllRowsSelected`,E4):t,n?.deselectAll&&!t)return A2();let i=Object.assign(A2(),r),a=e.getPreGroupedRowModel().flatRows;if(t){let e=new Map;a.forEach(t=>{I4(t,e)&&(i[t.id]=!0)})}else a.forEach(e=>{M4(e)&&delete i[e.id]});return i})}function w4(e,t,n){e._lastSelectedRowId=null,S4(e,r=>{let i=t===void 0?!V2(e,`getIsAllPageRowsSelected`,D4):t;if(n?.deselectAll&&!i)return A2();let a=Object.assign(A2(),r);return e.getRowModel().rows.forEach(t=>{F4(a,t.id,i,!0,e,!0)}),a})}function Dve(e){return e.getCoreRowModel()}function Ove(e){let t=e.getCoreRowModel();return V2(e,`getIsSomeRowsSelected`,O4)?z4(t,e):{rows:[],flatRows:[],rowsById:A2()}}function kve(e){let t=e.getFilteredRowModel();return V2(e,`getIsSomeRowsSelected`,O4)?z4(t,e):{rows:[],flatRows:[],rowsById:A2()}}function Ave(e){let t=e.getSortedRowModel();return V2(e,`getIsSomeRowsSelected`,O4)?z4(t,e):{rows:[],flatRows:[],rowsById:A2()}}function T4(e){return Object.keys(e.atoms.rowSelection?.get()??{})}function E4(e){let t=e.getFilteredRowModel().flatRows,n=e.atoms.rowSelection?.get()??{},r=!!(t.length&&Object.keys(n).length);if(r){let e=new Map;t.some(t=>!B4(t,n)&&I4(t,e))&&(r=!1)}return r}function D4(e){let t=e.getPaginatedRowModel().flatRows,n=e.atoms.rowSelection?.get()??{},r=new Map,i=!1;for(let e=0;e<t.length;e++){let a=t[e];if(B4(a,n))!i&&I4(a,r)&&(i=!0);else if(I4(a,r))return!1}return i}function O4(e){return V2(e,`getSelectedRowIds`,T4).length>0}function jve(e){return e.getPaginatedRowModel().flatRows.filter(e=>M4(e)).some(e=>A4(e)||V2(e,`getIsSomeSelected`,j4))}function Mve(e){return t=>{C4(e,t.target.checked)}}function Nve(e){return t=>{w4(e,t.target.checked)}}function k4(e,t,n){let r=A4(e);S4(e.table,i=>{t=t===void 0?!r:t;let a=Object.assign(A2(),i);return F4(a,e.id,t,(n?.selectChildren??!0)&&P4(e),e.table),!t&&n?.deselectParents&&L4(a,e),a})}function A4(e){return B4(e,e.table.atoms.rowSelection?.get()??{})}function j4(e){return V4(e)===`some`}function Pve(e){return V4(e)===`all`}function M4(e){let t=e.table.options;return typeof t.enableRowSelection==`function`?t.enableRowSelection(e):t.enableRowSelection??!0}function N4(e){let t=e.table.options;return typeof t.enableSubRowSelection==`function`?t.enableSubRowSelection(e):t.enableSubRowSelection??!0}function P4(e){let t=e.table.options;return typeof t.enableMultiRowSelection==`function`?t.enableMultiRowSelection(e):t.enableMultiRowSelection??!0}function Fve(e,t){let n=M4(e);return r=>{if(!n)return;let i=r,a=e.table,o=i.target.checked,s=a._lastSelectedRowId;(!(a.options.enableRowRangeSelection!==!1&&s!==null&&P4(e)&&(a.options.isRowRangeSelectionEvent?.(r)??!1))||!Ive(e,s,o,t))&&k4(e,o,t),a._lastSelectedRowId=e.id}}function Ive(e,t,n,r){let i=r?.selectChildren??!0,a=e.table,o=a.getRowsInDisplayOrder(),s=a.getPrePaginatedRowModel().rowsById[t]??a.getCoreRowModel().rowsById[t];if(!s)return!1;let c=s.getDisplayIndex(),l=e.getDisplayIndex(),u=o[c],d=o[l];if(c<0||l<0||c>=o.length||l>=o.length||u?.id!==s.id||d?.id!==e.id||!P4(s)||!P4(e))return!1;let f=Math.min(c,l),p=Math.max(c,l);return S4(a,e=>{let t=Object.assign(A2(),e);for(let e=f;e<=p;e++){let s=o[e];M4(s)&&P4(s)&&(F4(t,s.id,n,i,a),!n&&r?.deselectParents&&L4(t,s))}return t}),!0}function F4(e,t,n,r,i,a){let o=i.getRow(t,!0);n?(P4(o)||Object.keys(e).forEach(t=>delete e[t]),M4(o)&&(e[t]=!0)):(!a||M4(o))&&delete e[t],r&&o.subRows.length&&N4(o)&&o.subRows.forEach(t=>F4(e,t.id,n,r,i,a))}function I4(e,t){if(!M4(e))return!1;let n=e.table;if(n.options.enableSubRowSelection===!0)return!0;let r=e.parentId;if(r===void 0)return!0;let i=t.get(r);if(i!==void 0)return i;let a=n.getCoreRowModel().rowsById,o=[],s=!0,c=r;for(;c!==void 0;){let e=t.get(c);if(e!==void 0){s=e;break}o.push(c);let r=a[c]??n.getRow(c,!0);if(!N4(r)){s=!1;break}c=r.parentId}return o.forEach(e=>t.set(e,s)),s}function L4(e,t){let n=t.table.getCoreRowModel().rowsById,r=t.parentId;for(;r!==void 0;)delete e[r],r=(n[r]??t.table.getRow(r,!0)).parentId}function R4(e,t,n,r){let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=B4(o,t);if(s&&(n.push(o),r[o.id]=o),o.subRows.length){let e=R4(o.subRows,t,n,r);if(s){let t=Object.create(Object.getPrototypeOf(o));Rge(t,o),t.subRows=e,i.push(t)}}else s&&i.push(o)}return i}function z4(e,t){let n=[],r=A2(),i=t.atoms.rowSelection?.get()??{};return{rows:R4(e.rows,i,n,r),flatRows:n,rowsById:r}}function B4(e,t){return!!(j2(t,e.id)&&t[e.id])}function V4(e){if(!e.subRows.length)return!1;let t=e.table.atoms.rowSelection?.get()??{},n=!1,r=!0,i=!1;for(let a=0;a<e.subRows.length;a++){let o=e.subRows[a];if(n&&!r)break;if(M4(o)&&(i=!0,B4(o,t)?n=!0:r=!1),o.subRows.length){let e=V4(o);e===`all`?(n=!0,i=!0):e===`some`?(n=!0,r=!1,i=!0):r=!1}}return i?r?`all`:n?`some`:!1:!1}var Lve={initTableInstanceData:e=>{e._lastSelectedRowId=null},resetTableInstanceData:e=>{e._lastSelectedRowId=null},getInitialState:e=>({rowSelection:Tve(),...e}),getDefaultTableOptions:e=>({onRowSelectionChange:M2(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableRowRangeSelection:!0,enableSubRowSelection:!0,isRowRangeSelectionEvent:e=>{let t=e;return!!(t.shiftKey||t.nativeEvent?.shiftKey)}}),assignRowPrototype:(e,t)=>{B2(`rowSelectionFeature`,e,t,{row_toggleSelected:{fn:(e,t,n)=>k4(e,t,n)},row_getIsSelected:{fn:e=>A4(e)},row_getIsSomeSelected:{fn:e=>j4(e),memoDeps:e=>[e.subRows,e.table.atoms.rowSelection?.get(),e.table.options.enableRowSelection]},row_getIsAllSubRowsSelected:{fn:e=>Pve(e),memoDeps:e=>[e.subRows,e.table.atoms.rowSelection?.get(),e.table.options.enableRowSelection]},row_getCanSelect:{fn:e=>M4(e)},row_getCanSelectSubRows:{fn:e=>N4(e)},row_getCanMultiSelect:{fn:e=>P4(e)},row_getToggleSelectedHandler:{fn:(e,t)=>Fve(e,t)}})},constructTableAPIs:e=>{z2(`rowSelectionFeature`,e,{table_setRowSelection:{fn:t=>S4(e,t)},table_resetRowSelection:{fn:t=>Eve(e,t)},table_toggleAllRowsSelected:{fn:(t,n)=>C4(e,t,n)},table_toggleAllPageRowsSelected:{fn:(t,n)=>w4(e,t,n)},table_getPreSelectedRowModel:{fn:()=>Dve(e)},table_getSelectedRowModel:{fn:()=>Ove(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getCoreRowModel()]},table_getFilteredSelectedRowModel:{fn:()=>kve(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getFilteredRowModel()]},table_getGroupedSelectedRowModel:{fn:()=>Ave(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getSortedRowModel()]},table_getSelectedRowIds:{fn:()=>T4(e),memoDeps:()=>[e.atoms.rowSelection?.get()]},table_getIsAllRowsSelected:{fn:()=>E4(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getFilteredRowModel(),e.options.enableRowSelection,e.options.enableSubRowSelection]},table_getIsAllPageRowsSelected:{fn:()=>D4(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getPaginatedRowModel(),e.options.enableRowSelection,e.options.enableSubRowSelection]},table_getIsSomeRowsSelected:{fn:()=>O4(e),memoDeps:()=>[e.atoms.rowSelection?.get()]},table_getIsSomePageRowsSelected:{fn:()=>jve(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getPaginatedRowModel(),e.options.enableRowSelection]},table_getToggleAllRowsSelectedHandler:{fn:()=>Mve(e)},table_getToggleAllPageRowsSelectedHandler:{fn:()=>Nve(e)}})}},Rve={getInitialState(e){return{sorting:F_e(),...e}},getDefaultColumnDef(){return{sortFn:`auto`,sortUndefined:1}},getDefaultTableOptions(e){return{autoResetSorting:!1,onSortingChange:M2(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}},assignColumnPrototype(e,t){B2(`rowSortingFeature`,e,t,{column_getAutoSortFn:{fn:e=>u4(e)},column_getAutoSortDir:{fn:e=>d4(e)},column_getSortFn:{fn:e=>L_e(e)},column_toggleSorting:{fn:(e,t,n)=>f4(e,t,n)},column_getFirstSortDir:{fn:e=>p4(e)},column_getNextSortingOrder:{fn:(e,t)=>m4(e,t)},column_getCanSort:{fn:e=>h4(e)},column_getCanMultiSort:{fn:e=>g4(e)},column_getIsSorted:{fn:e=>_4(e)},column_getSortIndex:{fn:e=>R_e(e)},column_clearSorting:{fn:e=>z_e(e)},column_getToggleSortingHandler:{fn:e=>B_e(e)}})},constructTableAPIs(e){z2(`rowSortingFeature`,e,{table_setSorting:{fn:t=>c4(e,t)},table_resetSorting:{fn:t=>l4(e,t)}})}},zve=typeof window>`u`?L.useEffect:L.useLayoutEffect;function Bve(e,t){let[{table:n,rootSource:r}]=(0,L.useState)(()=>{let t=wve({...e,features:{coreReactivityFeature:Lge(),...e.features}});return t.Subscribe=(e=>Nge({...e,source:e.source??t.store})),t.FlexRender=wge,{table:t,rootSource:Ige(t.store,T2)}}),i=n;x4(i,t=>({...t,...e}),{syncExternalState:!1});let a=i.options.state,o=r.get(),s=D2(r,t,{compare:T2});return zve(()=>{r.markCommitted(o),b4(i,a??null,T2)}),(0,L.useMemo)(()=>({...n,options:e,state:s}),[n,e,s])}var Vve=e=>t=>{let n=t.currentTarget;n.scrollWidth>Math.ceil(n.getBoundingClientRect().width)?n.title=e:n.removeAttribute(`title`)},H4=({text:e,className:t})=>(0,z.jsx)(`span`,{className:g(`truncate`,t),onMouseEnter:Vve(e),children:e}),U4=e=>(0,z.jsx)(`span`,{className:`text-faint-foreground`,children:e}),W4=(e,t)=>{if(t==null)return U4(`—`);let n=_x(e,t)??``;switch(e.kind){case`text`:return e.link?(0,z.jsx)(xC,{format:e.link,value:n,className:`block min-w-0 truncate`}):(0,z.jsx)(H4,{text:n});case`id`:return(0,z.jsx)(H4,{text:n,className:`font-mono text-xs text-muted-foreground`});case`money`:return(0,z.jsx)(`span`,{className:`tabular-nums`,children:n});case`date`:return(0,z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n});case`datetime`:return(0,z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,title:e.relative?np(Number(t)):hx(`shownIn`,Gf(Number(t),If())),children:n});case`number`:return(0,z.jsx)(`span`,{className:`tabular-nums`,children:n});case`signed`:return(0,z.jsx)(`span`,{className:g(`tabular-nums`,Number(t)<0?`text-danger-text`:`text-success-text`),children:n});case`percent`:return Number(t)===0?U4(`—`):(0,z.jsx)(`span`,{className:`tabular-nums`,children:n});case`status`:return(0,z.jsx)(_d,{tone:e.tones?.[String(t)]??`neutral`,color:Z0(e.colors,t),shape:e.shape,children:n});case`relation`:return(0,z.jsx)(H4,{text:n,className:`font-medium text-primary-text hover:underline`});case`boolean`:return t?(0,z.jsx)(`span`,{className:`inline-flex size-4 items-center justify-center rounded-full bg-success-soft text-success-text`,children:(0,z.jsx)(xi,{className:`size-3`,strokeWidth:3})}):U4(hx(`no`));case`file`:{let e=rx(t);if(!e)return U4(`—`);if(`missing`in e)return(0,z.jsx)(H4,{text:e.name,className:`text-danger-text`});let n=dx(t,{width:20,height:20});return(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[n?(0,z.jsx)(fC,{image:n,className:`size-5 shrink-0 rounded-sm object-cover`}):(0,z.jsx)(Ya,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(H4,{text:e.name})]})}case`user`:{let e=hb(String(t));return(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2 truncate`,children:[(0,z.jsx)(cd,{initials:e.initials,hue:e.hue,size:`xs`,className:`ring-0`}),(0,z.jsx)(H4,{text:e.name,className:`text-muted-foreground`})]})}}},Hve=Sve({rowSortingFeature:Rve,rowSelectionFeature:Lve}),G4=xve(),Uve=e=>G4.columns(e.map(e=>G4.accessor(t=>e.value?e.value(t):t[e.id],{id:e.id,header:e.header,enableSorting:e.sortable??!1,cell:t=>e.render?e.render(t.row.original):W4(e,t.getValue())}))),Wve=(e,t)=>e.flatMap(e=>{let n=e.available?t.filter(e.available):t;return n.length===0?[]:[{action:e,rows:n,skipped:t.length-n.length}]}),Gve=({total:e,selectedCount:t,bulkActions:n=[],className:r})=>(0,z.jsx)(`div`,{className:g(`flex h-9 shrink-0 items-center border-t bg-surface px-3 text-xs text-muted-foreground`,r),children:(0,z.jsxs)(`span`,{className:`flex items-center tabular-nums`,children:[Ff(e),t>0&&(0,z.jsx)(`span`,{className:`ml-3 font-medium text-primary-text`,children:hx(`selected`,Mf(t))}),t>0&&n.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:e.onRun,className:g(`ml-3 rounded border bg-background px-2 py-0.5 font-medium hover:bg-muted`,e.destructive?`border-danger/40 text-danger-text`:`text-foreground`),children:e.label},e.label))]})}),Kve=(e,t)=>typeof e.label==`string`?e.label:e.label(t),qve=(e,t)=>e.filter(e=>e.available?.(t)??!0),Jve=({row:e,actions:t})=>{let{open:n,setOpen:r,place:i,button:a,menu:o}=FS();return(0,z.jsxs)(`div`,{className:`relative flex justify-center bg-inherit`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`button`,{ref:a,type:`button`,"aria-label":hx(`rowActions`),"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(!n),className:`inline-flex items-center justify-center rounded p-1 text-faint-foreground hover:bg-muted hover:text-foreground pointer-coarse:size-11`,children:(0,z.jsx)(qi,{className:`size-4`})}),n&&(0,ls.createPortal)((0,z.jsx)(`ul`,{ref:o,role:`menu`,onClick:e=>e.stopPropagation(),style:i??{visibility:`hidden`},className:`fixed z-50 min-w-36 rounded-md border bg-background py-1 shadow-pop`,children:t.map((t,n)=>{let i=Kve(t,e),a=t.blocked?.(e),o=g(`block w-full px-3 py-1.5 text-left hover:bg-muted disabled:cursor-default disabled:opacity-60 disabled:hover:bg-transparent`,t.destructive&&`text-danger-text`);return(0,z.jsx)(`li`,{role:`none`,children:t.link?(0,z.jsx)(Qu,{role:`menuitem`,to:t.link(e),onClick:()=>r(!1),className:o,children:i}):(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:a!==void 0,title:a,className:o,onClick:()=>{r(!1),t.onSelect(e)},children:i})},n)})}),document.body)]})},Yve=e=>52+Math.ceil(String(e).length*1.33)*7,K4=.6,q4=(e,t)=>Math.max(e.minWidth??0,e.width*t),Xve=(e,t)=>e.fixed?`${Math.max(e.minWidth??0,e.width)}px`:`minmax(${q4(e,t)}px, ${e.width}fr)`,J4=(e,t,n=0,r=K4)=>`${t}px ${e.map(e=>Xve(e,r)).join(` `)}${n>0?` ${n}px`:``}`,Zve=(e,t,n=0,r=K4)=>t+n+e.reduce((e,t)=>e+(t.fixed?Math.max(t.minWidth??0,t.width):q4(t,r)),0),Qve=()=>{let e=(0,L.useRef)(null),t=(0,L.useRef)(null),[n,r]=(0,L.useState)({scrolled:!1,more:!1}),i=(0,L.useCallback)(()=>{let t=e.current;if(!t)return;let n={scrolled:t.scrollLeft>1,more:t.scrollLeft+t.clientWidth<t.scrollWidth-1};r(e=>e.scrolled===n.scrolled&&e.more===n.more?e:n)},[]);return{ref:e,attach:(0,L.useCallback)(n=>{if(t.current?.disconnect(),t.current=null,e.current=n,!n)return;let r=new ResizeObserver(i);r.observe(n);for(let e of Array.from(n.children))r.observe(e);t.current=r,i()},[i]),onScroll:i,...n}},$ve=`protobase:pinned:`,eye=(e,t)=>`${$ve}${e}:${t}`,tye=(e,t)=>u(()=>{let n=e.getItem(t);if(n===null)return;let r=JSON.parse(n);return Array.isArray(r)&&r.every(e=>typeof e==`string`)?r:void 0},void 0),nye=(e,t,n)=>u(()=>e.setItem(t,JSON.stringify(n)),void 0),rye=(e,t=[])=>{let[n,r]=(0,L.useState)(()=>e?tye(localStorage,e):void 0),i=(0,L.useCallback)(t=>{r(t),e&&nye(localStorage,e,t)},[e]);return[n??t,i]},iye=e=>{let t=e.findIndex(e=>e.title);return t<0||t>1?[]:e.slice(0,t+1).map(e=>e.id)},aye=e=>Object.fromEntries(e.map(({id:e,width:t,minWidth:n,fixed:r})=>[e,{width:t,minWidth:n,fixed:r}])),oye=(e,t)=>{let n=e.map(e=>e.id).sort().join(` `),[r,i]=(0,L.useState)(),a=r?.key===n?r:void 0;!a&&t.length>0&&i({key:n,sizes:aye(Px(e,t))});let o=a?.sizes;return(0,L.useMemo)(()=>o?e.map(e=>({...e,...o[e.id]})):e,[e,o])},Y4=e=>e===`money`||e===`number`||e===`signed`||e===`percent`,X4=()=>hx(`unsortable`),sye=({header:e,pinned:t,sortable:n,onTogglePin:r})=>{let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(!i)return;let e=e=>{(e instanceof KeyboardEvent?e.key===`Escape`:!o.current?.contains(e.target))&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[i]),(0,z.jsxs)(`div`,{ref:o,className:`relative ml-auto shrink-0`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":hx(`columnMenu`,e),"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>a(!i),className:`relative inline-flex size-5 items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground focus-visible:opacity-100 after:absolute after:-inset-2 after:content-[''] md:opacity-0 md:group-hover/cell:opacity-100 aria-expanded:opacity-100`,children:(0,z.jsx)(qi,{className:`size-3.5`})}),i&&(0,z.jsxs)(`ul`,{role:`menu`,className:`absolute right-0 top-full z-30 mt-1 min-w-32 rounded-md border bg-background py-1 text-body font-normal text-foreground shadow-pop`,children:[!n&&(0,z.jsx)(`li`,{role:`none`,children:(0,z.jsx)(`span`,{role:`menuitem`,"aria-disabled":`true`,className:`block min-h-9 whitespace-nowrap px-3 py-1.5 text-muted-foreground`,children:X4()})}),(0,z.jsx)(`li`,{role:`none`,children:(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block min-h-9 w-full whitespace-nowrap px-3 py-1.5 text-left hover:bg-muted`,onClick:()=>{a(!1),r()},children:hx(t?`unpin`:`pinToLeft`)})})]})]})},cye=({sorted:e})=>e===`asc`?(0,z.jsx)(qr,{className:`size-3 text-foreground`}):e===`desc`?(0,z.jsx)(Lr,{className:`size-3 text-foreground`}):(0,z.jsx)(ki,{className:`size-3 opacity-0 group-hover/head:opacity-100`}),Z4=({spec:e})=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.header}),e.highlight&&(0,z.jsx)(`span`,{className:`rounded bg-primary px-1 text-[10px] font-semibold uppercase leading-4 text-primary-foreground`,children:hx(`new`)})]}),lye=({cells:e,specs:t,gutter:n,selectedCount:r,selectable:i,trailing:a,minScale:o,pins:s={},lastPinned:c,scrolled:l,onTogglePin:u,onClearSelection:d})=>(0,z.jsxs)(`div`,{className:`grid h-8 shrink-0 items-center border-b bg-surface text-body font-medium text-muted-foreground`,style:{gridTemplateColumns:J4(t,n,a,o)},role:`row`,children:[(0,z.jsxs)(`div`,{className:g(`sticky left-0 z-10 flex h-full items-center gap-2 bg-inherit pl-3`,l&&!c&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),style:{width:n},children:[i&&(0,z.jsx)(xg,{checked:!1,indeterminate:r>0,label:hx(r>0?`clearSelection`:`noRowsSelected`),disabled:r===0,onChange:d,className:g(r===0&&`opacity-60`)}),n>40&&(0,z.jsx)(`span`,{className:`w-6 text-right text-faint-foreground`,children:`#`})]}),e.map(({spec:e,sorted:t,onSort:n})=>{let r=e.id in s;return(0,z.jsxs)(`div`,{"data-col-id":e.id,style:r?{left:s[e.id]}:void 0,className:g(`group/cell flex h-full min-w-0 items-center`,r&&`sticky z-10 bg-inherit`,r&&l&&e.id===c&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`,e.highlight&&`bg-primary-soft text-primary-text`),children:[e.sortable?(0,z.jsxs)(`button`,{type:`button`,onClick:n,className:g(`group/head flex h-full min-w-0 flex-1 items-center gap-1 pl-3 pr-1 text-left`,Y4(e.kind)&&`justify-end`,`hover:text-foreground`,t&&`text-foreground`),children:[(0,z.jsx)(Z4,{spec:e}),(0,z.jsx)(cye,{sorted:t})]}):(0,z.jsx)(`div`,{title:X4(),className:g(`flex h-full min-w-0 flex-1 items-center gap-1 pl-3 pr-1 text-left`,Y4(e.kind)&&`justify-end`),children:(0,z.jsx)(Z4,{spec:e})}),(0,z.jsx)(`div`,{className:`pr-1.5`,children:(0,z.jsx)(sye,{header:e.header,pinned:r,sortable:!!e.sortable,onTogglePin:()=>u(e.id)})})]},e.id)}),a?(0,z.jsx)(`div`,{className:`sticky right-0 z-10 h-full bg-inherit`}):null]}),Q4=e=>({gridTemplateColumns:J4(e.specs,e.gutter,e.trailing,e.minScale),height:e.height,transform:`translateY(${e.offset}px)`}),$4=(e,t)=>g(`flex h-full min-w-0 items-center overflow-hidden whitespace-nowrap px-3`,Y4(e.kind)&&`justify-end`,e.highlight&&`bg-primary-soft/60`,t.pins&&e.id in t.pins&&`sticky z-10 bg-inherit`,t.scrolled&&e.id===t.lastPinned&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),e3=(e,t)=>t&&e.id in t?{left:t[e.id]}:void 0,t3=({width:e,index:t,selectable:n,selected:r,onToggle:i,edge:a})=>(0,z.jsxs)(`div`,{onClick:n?e=>{e.stopPropagation(),i?.()}:void 0,className:g(`sticky left-0 z-10 flex h-full items-center gap-2 bg-inherit pl-3`,n&&`cursor-default`,a&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),style:{width:e},children:[n&&(0,z.jsx)(xg,{checked:!!r,label:hx(`selectRow`,t+1)}),e>40&&(0,z.jsx)(`span`,{className:`min-w-6 text-right text-[11px] tabular-nums text-faint-foreground`,children:Mf(t+1)})]}),uye=(e,t,n)=>({gridTemplateColumns:J4(e.specs,e.gutter,e.trailing,e.minScale),height:e.height,top:e.offset,transform:t===0?void 0:`translateY(${t}px)`,transition:n}),dye=e=>t=>{t.target.closest(`a`)||e()},n3=({cells:e,selected:t,onToggle:n,onOpen:r,menu:i,handle:a,rowRef:o,dragY:s,transition:c,dragging:l,...u})=>(0,z.jsxs)(`div`,{ref:o,role:`row`,onClick:r&&dye(r),className:g(`absolute inset-x-0 top-0 grid items-center border-b`,t?`bg-primary-soft`:`bg-background hover:bg-surface`,r&&`cursor-pointer`,l&&`z-30 bg-surface shadow-pop`),style:s===void 0?Q4(u):uye(u,s,c),children:[a?(0,z.jsx)(`div`,{className:g(`sticky left-0 z-10 flex h-full items-center bg-inherit pl-1.5`,u.scrolled&&!u.lastPinned&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),style:{width:u.gutter},children:a}):(0,z.jsx)(t3,{width:u.gutter,index:u.index,selectable:u.selectable,selected:t,onToggle:n,edge:u.scrolled&&!u.lastPinned}),e.map(({spec:e,content:t,props:n,chosen:r,editing:i,editable:a})=>(0,z.jsx)(`div`,{role:n?`gridcell`:`cell`,...n,className:g($4(e,u),n&&`scroll-mb-[calc(var(--pb-sticky-bottom,0px)+3rem)] scroll-mt-[calc(var(--pb-sticky-top,0px)+2rem)] outline-none`,a&&!i&&`cursor-default`,r&&`shadow-[inset_0_0_0_2px_var(--primary)]`,i&&`z-30 overflow-visible bg-background px-1`),style:e3(e,u.pins),children:t},e.id)),i&&(0,z.jsx)(`div`,{className:`sticky right-0 z-10 flex h-full items-center justify-center bg-inherit`,children:i})]}),r3=[`w-3/4`,`w-1/2`,`w-2/3`,`w-5/6`,`w-2/5`],fye=e=>(0,z.jsxs)(`div`,{role:`row`,"aria-busy":!0,className:`absolute inset-x-0 top-0 grid items-center border-b bg-background`,style:Q4(e),children:[(0,z.jsx)(t3,{width:e.gutter,index:e.index,selectable:!1,edge:e.scrolled&&!e.lastPinned}),e.specs.map((t,n)=>(0,z.jsx)(`div`,{className:$4(t,e),style:e3(t,e.pins),children:(0,z.jsx)(Yu,{className:g(`h-2.5`,r3[(e.index+n)%r3.length],Y4(t.kind)&&`ml-auto`)})},t.id))]}),pye=(e,t)=>{let n=new Map;return{get:t=>n.get(Math.floor(t/e))?.[t%e],hasPage:e=>n.has(e),setPage:(e,r)=>{if(n.delete(e),n.set(e,r),n.size<=t)return;let i=n.keys().next();i.done||n.delete(i.value)},keepOnly:e=>{for(let t of[...n.keys()])e.includes(t)||n.delete(t)},get size(){return n.size}}},i3=(e,t,n)=>{let r=Math.floor(e/n),i=Math.floor(t/n);return Array.from({length:i-r+1},(e,t)=>r+t)},a3=(e,t)=>Math.max(0,Math.min(40,e-t*40)),o3=({total:e,rowAt:t,loadRows:n,revision:r,latencyMs:i},a,o)=>{let s=(0,L.useMemo)(()=>pye(40,60),[t,n]),[c,l]=(0,L.useState)(0),u=Math.floor(a/40),d=Math.floor(o/40),f=!n&&i===0;(0,L.useEffect)(()=>{if(f)return;let r=i3(u*40,d*40,40).filter(e=>!s.hasPage(e)),a=t=>a3(e,t),o=(e,t)=>{s.setPage(e,t),l(e=>e+1)};if(n){let e=!1;for(let t of r)n(t*40,a(t)).then(n=>{e||o(t,n)});return()=>{e=!0}}let c=r.map(e=>setTimeout(()=>o(e,Array.from({length:a(e)},(n,r)=>t(e*40+r))),i));return()=>c.forEach(clearTimeout)},[s,u,d,i,e,t,n,f]);let p=(0,L.useRef)(r);return(0,L.useEffect)(()=>{if(!n||r===p.current)return;p.current=r;let t=i3(u*40,d*40,40);s.keepOnly(t);for(let r of t.filter(e=>s.hasPage(e)))n(r*40,a3(e,r)).then(e=>{s.setPage(r,e),l(e=>e+1)})},[s,r,n,u,d,e]),(0,L.useCallback)(e=>f?t(e):s.get(e),[s,f,t,c])},mye=1e7,s3=(e,t,n)=>{let r=e*t,i=Math.min(r,mye);return{rowHeight:t,trueHeight:r,contentHeight:i,scaled:r>i,maxTop:Math.max(0,r-n),maxScroll:Math.max(0,i-n)}},hye=(e,t)=>!e.scaled||t<=0?t:t>=e.maxScroll?e.maxTop+t-e.maxScroll:t/e.maxScroll*e.maxTop,c3=(e,t)=>!e.scaled||t<=0?t:t>=e.maxTop?e.maxScroll+t-e.maxTop:t/e.maxTop*e.maxScroll,gye=(e,t,n,r)=>{let i=t*e.rowHeight;return e.scaled?i-n+r:i},l3=(e,t,n,r,i)=>{let a=Math.min(e,Math.max(0,Math.floor(t/n)-i)),o=Math.min(e-1,Math.floor((t+r)/n)+i);return{first:a,last:Math.max(a-1,o)}},_ye=e=>{let t=document.scrollingElement??document.documentElement;for(let n=e.parentElement;n&&n!==t&&n!==document.body;n=n.parentElement)if(/auto|scroll/.test(getComputedStyle(n).overflowY))return n;return t},u3=e=>e===(document.scrollingElement??document.documentElement),vye=e=>u3(e)?window:e,d3=e=>Number.parseFloat(e)||0,yye=e=>{let t=getComputedStyle(e),n=u3(e)?{top:0,height:e.clientHeight}:{top:e.getBoundingClientRect().top+e.clientTop,height:e.clientHeight},r=d3(t.scrollPaddingTop);return{top:n.top+r,height:Math.max(0,n.height-r-d3(t.scrollPaddingBottom))}},f3=6,p3=(e,t,n)=>{let r=s3(t,n,e.height),i=hye(r,e.position);return{geometry:r,top:i,topIndex:Math.floor(Math.max(0,i)/n),...l3(t,i,n,e.height,f3)}},m3=({total:e,rowHeight:t,initialIndex:n,inset:r=0,settle:i,ready:a=!0,onScroll:o})=>{let s=(0,L.useRef)(null),c=(0,L.useRef)(null),[l,u]=(0,L.useState)({position:0,height:0}),d=(0,L.useRef)({total:e,rowHeight:t,initialIndex:n,inset:r,ready:a,onScroll:o});d.current={total:e,rowHeight:t,initialIndex:n,inset:r,ready:a,onScroll:o};let f=(0,L.useCallback)(()=>{let e=s.current;if(!e||!c.current)return;let t=yye(c.current),n=d.current.inset;return{position:t.top+n-e.getBoundingClientRect().top,height:Math.max(0,t.height-n)}},[]),p=(0,L.useRef)({pending:!0,laidOut:!1}),m=(0,L.useRef)(l);m.current=l;let h=(0,L.useCallback)(()=>{let e=f();if(!e)return;let t=m.current,{total:n,rowHeight:r,onScroll:i}=d.current,a=p3(t,n,r),o=p3(e,n,r);p.current.pending||i?.(Math.max(0,o.top));let s=!o.geometry.scaled&&a.first===o.first&&a.last===o.last&&a.topIndex===o.topIndex;(t.height!==e.height||t.position!==e.position&&!s)&&(m.current=e,u(e))},[f]),g=(0,L.useCallback)(()=>{if(!p.current.pending||!p.current.laidOut||!d.current.ready)return;let e=f(),t=c.current;if(!e||!t)return;p.current.pending=!1;let{total:n,rowHeight:r,initialIndex:i}=d.current;i>0?t.scrollTop+=c3(s3(n,r,e.height),i*r)-e.position:e.position>0&&(t.scrollTop=0)},[f]);(0,L.useLayoutEffect)(()=>{let e=s.current;if(!e)return;let t=_ye(e);c.current=t;let n=vye(t);n.addEventListener(`scroll`,h,{passive:!0}),window.addEventListener(`resize`,h,{passive:!0});let r=new ResizeObserver(()=>{p.current.laidOut=!0,g(),h()});return r.observe(t),r.observe(e),h(),()=>{n.removeEventListener(`scroll`,h),window.removeEventListener(`resize`,h),r.disconnect(),c.current=null}},[h,g]),(0,L.useLayoutEffect)(()=>{g(),h()});let _=(0,L.useCallback)(e=>{let t=f();if(!t||!c.current)return;let n=s3(d.current.total,d.current.rowHeight,t.height);c.current.scrollTop+=c3(n,e)-t.position,h()},[f,h]),v=p3(l,e,t),y=i?i(v.top):v.top,{first:b,last:x}=i?l3(e,y,t,l.height,f3):v,S=Array.from({length:x-b+1},(e,t)=>({index:b+t,offset:gye(v.geometry,b+t,y,l.position)}));return{ref:s,height:l.height,top:y,geometry:v.geometry,rows:S,first:b,last:x,scrollTo:_}},bye=e=>e===`ArrowUp`||e===`ArrowDown`||e===`ArrowLeft`||e===`ArrowRight`,xye=(e,t,n,r)=>{let i=n.indexOf(e.column);if(t===`ArrowUp`)return e.index>0?{...e,index:e.index-1}:void 0;if(t===`ArrowDown`)return e.index<r-1?{...e,index:e.index+1}:void 0;let a=n[t===`ArrowLeft`?i-1:i+1];return i>=0&&a!==void 0?{...e,column:a}:void 0},Sye=(e,t,n,r)=>{let i=t.indexOf(e);return(r===1?t.slice(i+1):t.slice(0,Math.max(0,i)).reverse()).find(n)},h3=e=>`${e.index}:${e.column}`,Cye=({editor:e,columns:t,total:n,rowAt:r,onOpenRow:i,container:a})=>{let[o,s]=(0,L.useState)(),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(!1),d=(0,L.useRef)(!1);if((0,L.useEffect)(()=>{if(!o||c||!u.current)return;u.current=!1;let e=a.current?.querySelector(`[data-cell="${h3(o)}"]`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`nearest`,inline:`nearest`}))},[o,c,a]),!e)return;let f=t=>{let n=r(t.index);return n!==void 0&&e.editable(n,t.column)},p=(e,t=!1)=>{u.current=!0,s(e),l(t&&f(e))},m=n=>{if(!o)return;let i=r(o.index),s=n&&i?Sye(o.column,t,t=>e.editable(i,t),n):void 0,c=!!a.current?.contains(document.activeElement);p(s?{...o,column:s}:o,s!==void 0),u.current=c};return{cell:(n,r,i,a)=>{let l={index:n,column:i},u=o?.index===n&&o.column===i,f=e.editable(r,i),h=u||!o&&n===0&&i===t[0];return{content:u&&c?e.render(r,i,m):a,chosen:u,editing:u&&c,editable:f,props:{"data-cell":h3(l),tabIndex:h?0:-1,"aria-selected":u,onMouseDown:()=>{d.current=u},onFocus:e=>{e.target===e.currentTarget&&!u&&s(l)},onClick:e=>{f&&(e.stopPropagation(),d.current&&!c&&p(l,!0))},onDoubleClick:e=>{f&&(e.stopPropagation(),u&&c||p(l,!0))}}}},onKeyDown:e=>{if(c||!o||!(e.target instanceof HTMLElement)||e.target.dataset.cell!==h3(o))return;let a=e.key===`Tab`?e.shiftKey?`ArrowLeft`:`ArrowRight`:e.key;if(bye(a)){let i=xye(o,a,t,n);if(!i&&e.key===`Tab`)return;e.preventDefault(),i&&r(i.index)&&p(i);return}if(e.key===`Enter`||e.key===`F2`){e.preventDefault();let t=r(o.index);f(o)?p(o,!0):e.key===`Enter`&&t&&i?.(t);return}e.key===`Escape`&&s(void 0)}}},wye=({ids:e,rowAt:t,reorder:n,children:r})=>{let i=ev($_($v,{activationConstraint:{distance:4}}),$_(ty,{activationConstraint:{delay:250,tolerance:5}}),$_(Gv,{coordinateGetter:cb})),a=t=>e.indexOf(String(t)),o=e=>{let r=t(a(e));return r?n.label(r):hx(`row`)};return(0,z.jsx)(Cy,{sensors:i,collisionDetection:sv,onDragEnd:({active:e,over:t})=>{t&&e.id!==t.id&&n.onMove(a(e.id),a(t.id))},accessibility:{announcements:{onDragStart:({active:t})=>hx(`pickedUp`,o(t.id),a(t.id)+1,e.length),onDragOver:({active:t,over:n})=>n?hx(`isOver`,o(t.id),a(n.id)+1,e.length):void 0,onDragEnd:({active:t,over:n})=>n?hx(`droppedAt`,o(t.id),a(n.id)+1,e.length):hx(`putBack`,o(t.id)),onDragCancel:({active:e})=>hx(`cancelled`,o(e.id),a(e.id)+1)},screenReaderInstructions:{draggable:hx(`reorderInstructions`)}},children:(0,z.jsx)(Xy,{items:e,strategy:Ky,children:r})})},Tye=({row:e,label:t,...n})=>{let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,transition:c,isDragging:l}=ib({id:e.id}),u=(0,z.jsx)(`button`,{ref:o,type:`button`,"aria-label":hx(`move`,t),...r,...i,onClick:e=>e.stopPropagation(),style:{touchAction:`none`},className:`flex size-7 cursor-grab items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground focus-visible:text-foreground active:cursor-grabbing pointer-coarse:size-9`,children:(0,z.jsx)(ra,{className:`size-4`})});return(0,z.jsx)(n3,{...n,rowRef:a,handle:u,dragY:s?.y??0,transition:c,dragging:l})},g3=32,_3=({columns:e,source:t,naturalSort:n,initialScrollIndex:r=0,onScrollIndex:i,latencyMs:a=150,sort:o,onSortChange:s,onOpenRow:c,rowLink:l,rowActions:u,cellEditor:d,rowPatches:f,bulkActions:p,pinKey:m,defaultPinned:h,rowNumbers:_=!0,compact:v=!1,selectable:y=!0,reorder:b,fit:x=!1,scroll:S=`own`,className:C})=>{let w=y&&!b,T=v?28:36,E=!Mu(),D=(h??(E?[]:iye(e))).join(` `),[O,k]=rye(m,(0,L.useMemo)(()=>D?D.split(` `):[],[D])),A=(0,L.useMemo)(()=>[...O.flatMap(t=>e.find(e=>e.id===t)??[]),...e.filter(e=>!O.includes(e.id))],[e,O]),j=A.slice(0,A.filter(e=>O.includes(e.id)).length).map(e=>e.id),{total:M}=t,[N,P]=(0,L.useState)(n?[{id:n.columnId,desc:n.direction===`desc`}]:[]),ee=o?[{id:o.columnId,desc:o.direction===`desc`}]:N,te=e=>{let t=typeof e==`function`?e(ee):e,n=t[0];s&&n&&s({columnId:n.id,direction:n.desc?`desc`:`asc`}),o||P(t)},[ne,re]=(0,L.useState)({}),ie=(0,L.useMemo)(()=>Uve(A),[A]),ae=ee[0],oe=!!(!o&&n&&ae&&ae.id===n.columnId&&(ae.desc?`desc`:`asc`)!==n.direction),se=t.rowAt,ce=(0,L.useCallback)(e=>se(oe?M-1-e:e),[se,oe,M]),[le]=(0,L.useState)(r),{ref:ue,geometry:F,rows:de,first:fe,last:pe}=m3({total:M,rowHeight:T,initialIndex:le,inset:g3,onScroll:i&&(e=>i(e/T))}),me=E||!_?40:Yve(M),I=o3({total:M,rowAt:se?ce:void 0,loadRows:t.loadRows,revision:t.revision,latencyMs:a},fe,pe),he=(0,L.useCallback)(e=>{let t=I(e),n=t&&f?.get(t.id);return n?{...t,...n}:t},[I,f]),ge=de.map(({index:e,offset:t})=>({index:e,offset:t,row:he(e)})),_e=(0,L.useMemo)(()=>ge.flatMap(({row:e})=>e?[e]:[]),[he,fe,pe]),ve=oye(A,_e),ye=Bve({features:Hve,columns:ie,data:_e,state:{sorting:ee,rowSelection:ne},onSortingChange:te,onRowSelectionChange:re,manualSorting:!0,enableMultiSort:!1,enableSortingRemoval:!1,getRowId:e=>e.id}),be=new Map(ye.getRowModel().rows.map(e=>[e.id,e])),xe=Object.keys(ne).length,Se=(0,L.useRef)(new Map);for(let e of ye.getRowModel().rows)e.getIsSelected()&&Se.current.set(e.id,e.original);let Ce=u&&u.length>0?40:0,we=E?1:K4,Te=Qve(),Ee=(0,L.useRef)(null),De=()=>{Te.onScroll(),Ee.current&&Te.ref.current&&(Ee.current.scrollLeft=Te.ref.current.scrollLeft)},[Oe,ke]=(0,L.useState)({});(0,L.useLayoutEffect)(()=>{let e=Ee.current?.querySelector(`[role=row]`);if(!e)return;let t=me,n={};for(let r of j)n[r]=t,t+=e.querySelector(`[data-col-id="${r}"]`)?.offsetWidth??0;JSON.stringify(Oe)!==JSON.stringify(n)&&ke(n)});let Ae=j.at(-1),je=e=>k(O.includes(e)?O.filter(t=>t!==e):[...O,e]),Me=ye.getHeaderGroups().flatMap(e=>e.headers.map(e=>({spec:A.find(t=>t.id===e.column.id),sorted:e.column.getIsSorted(),onSort:t=>e.column.getToggleSortingHandler()?.(t)}))),Ne=(0,L.useRef)(null),Pe=Cye({editor:d,columns:(0,L.useMemo)(()=>A.map(e=>e.id),[A]),total:M,rowAt:he,onOpenRow:c,container:Ne}),Fe=(A.find(e=>e.title)??A[0])?.id,Ie=Zve(ve,me,Ce,we),Le=S===`own`,Re=(0,z.jsx)(`div`,{ref:Ee,className:g(`sticky z-20 shrink-0 overflow-hidden`,Le?`top-0`:`top-[var(--pb-sticky-top,0px)]`),children:(0,z.jsx)(`div`,{style:{minWidth:Ie},children:(0,z.jsx)(lye,{cells:Me,specs:ve,gutter:me,trailing:Ce,minScale:we,pins:Oe,lastPinned:Ae,scrolled:Te.scrolled,onTogglePin:je,selectable:w,selectedCount:xe,onClearSelection:()=>re({})})})}),ze=ge.map(({index:e,offset:t,row:n})=>{let r={specs:ve,gutter:me,index:e,offset:t,height:T,selectable:w,trailing:Ce,minScale:we,scrolled:Te.scrolled,pins:Oe,lastPinned:Ae},i=n?be.get(n.id):void 0;if(!i||!n)return(0,z.jsx)(fye,{...r},`skeleton-${e}`);let a=Ce?qve(u,n):[],o={...r,selected:i.getIsSelected(),onToggle:()=>i.toggleSelected(),onOpen:c?()=>c(n):void 0,menu:a.length>0?(0,z.jsx)(Jve,{row:n,actions:a}):void 0,cells:i.getAllCells().map(t=>{let r=(0,z.jsx)(ye.FlexRender,{cell:t}),i=!!d?.editable(n,t.column.id),a=l&&t.column.id===Fe&&!i?(0,z.jsx)(Qu,{to:l(n),className:`flex min-w-0 items-center hover:underline`,children:r}):r;return{spec:A.find(e=>e.id===t.column.id),...Pe?Pe.cell(e,n,t.column.id,a):{content:a}}})};return b?(0,z.jsx)(Tye,{...o,row:n,label:b.label(n)},n.id):(0,z.jsx)(n3,{...o},n.id)}),Be=(0,z.jsx)(`div`,{ref:Te.attach,onScroll:De,className:`overflow-x-auto overflow-y-hidden overscroll-x-contain [-webkit-overflow-scrolling:touch]`,children:(0,z.jsx)(`div`,{ref:ue,className:`relative`,style:{minWidth:Ie,height:F.contentHeight},children:b?(0,z.jsx)(wye,{ids:Array.from({length:M},(e,t)=>he(t)?.id??`missing-${t}`),rowAt:he,reorder:b,children:ze}):ze})});return(0,z.jsxs)(`div`,{ref:Ne,role:`grid`,"aria-rowcount":M,onKeyDown:Pe?.onKeyDown,className:g(`flex flex-col rounded-lg border bg-background`,Le?`min-h-0 overflow-hidden`:`overflow-clip`,C),style:x&&Le?{height:g3+M*T+2}:void 0,children:[(0,z.jsxs)(`div`,{className:g(`relative`,Le&&`flex min-h-0 flex-1 flex-col`),children:[Le?(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,children:[Re,Be]}):(0,z.jsxs)(z.Fragment,{children:[Re,Be]}),Te.more&&(0,z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 right-0 z-20 w-8 bg-gradient-to-l from-backdrop/15 to-transparent`})]}),!x&&(0,z.jsx)(Gve,{total:M,className:Le?void 0:`sticky bottom-[var(--pb-sticky-bottom,0px)] z-20`,selectedCount:xe,bulkActions:Wve(p??[],Object.keys(ne).flatMap(e=>Se.current.get(e)??[])).map(({action:e,rows:t,skipped:n})=>({label:e.label(t.length),destructive:e.destructive,onRun:()=>{e.onRun(t,n),re({}),Se.current.clear()}}))})]})},Eye=500,v3=async(e,t,n)=>{let r=[],i={},a;do{let o=await e.search(t,{...n,pageSize:Eye,...a&&{pageToken:a}});r.push(...o.items);for(let[e,t]of Object.entries(o.labels??{}))i[e]={...i[e],...t};a=o.nextPageToken||void 0}while(a);return{items:r,labels:i}},y3=Vn(),b3=(...e)=>{let t=e.filter(e=>!!e);return t.length===1?t[0]:t.map(e=>`(${e})`).join(` AND `)},x3=e=>e==null?void 0:String(e),Dye=(e,t,n)=>{let r=new Map;for(let[t,n]of e)r.set(n,(r.get(n)??new Set).add(t));let i=new Map;for(let e of t){let t=e[n],a=x3(typeof t==`object`&&t&&`id`in t?t.id:t);for(let t of a===void 0?[]:r.get(a)??[])i.set(t,[...i.get(t)??[],e])}return i},Oye=async(e,t,n,r)=>{let i=n.through;if(!i)return r.map(e=>[e,e]);let a=t[i.resource],o=i.key??a?.primaryKey[0];if(!a||o===void 0)throw Error(`The related column ${n.name} names a join resource the app does not have: ${i.resource}`);return(await v3(e,a.name,{filter:b3(Fn(y3.in(i.field,r)),i.filter),fields:[i.field,o]})).items.flatMap(e=>{let t=x3(e[i.field]),n=x3(e[o]);return t===void 0||n===void 0?[]:[[t,n]]})},kye=async({client:e,resources:t,views:n,load:r,owners:i})=>{let{column:a,fields:o}=r,s=t[a.resource];if(!s)throw Error(`The related column ${a.name} shows a resource the app does not have: ${a.resource}`);if(i.length===0)return new Map;let c=await Oye(e,t,a,i),l=[...new Set(c.map(([,e])=>e))];if(l.length===0)return new Map;let u=[...new Set([...s.primaryKey,a.field,a.status,...o])],d=Y0(t,n,s,u),f=await v3(e,s.name,{filter:b3(Fn(y3.in(a.field,l)),a.filter),...a.sort&&{orderBy:a.sort},fields:u,labels:d});return Dye(c,X0(t,s,u,f.items,f.labels),a.field)},Aye=5e3,jye=({queryClient:e,client:t,resources:n,views:r,model:i,columns:a,filter:o,orderBy:s,related:c=[]})=>{let l=c.map(e=>e.column.name).join(`,`),u=e=>c.length===0?U.page(i.name,o,s,40,e):[...U.page(i.name,o,s,40,e),l],d=Y0(n,r,i,a),f=oS(r[i.name]),p=async e=>e.nextPageToken===``?e.items.length:e.totalSizeEstimate>Aye?e.totalSizeEstimate:(await t.list(i.name,{filter:o,orderBy:s,pageSize:1,count:`exact`})).totalSize??e.totalSizeEstimate,m=async t=>{if(t===0)return``;let n=u(t-1),r=e.getQueryData(n);if(r)return r.nextPageToken;if(e.getQueryState(n)?.fetchStatus===`fetching`)return(await g(t-1)).nextPageToken},h=async e=>{let l=await m(e);if(e>0&&l===``)return{rows:[],total:0,nextPageToken:``};let u={filter:o,orderBy:s,pageSize:40,labels:d,photos:f},h=l===void 0?await t.seek(i.name,{...u,position:e*40}):await t.list(i.name,{...u,pageToken:l});if(h.items.length===0&&e>0)return{rows:[],total:0,nextPageToken:``};let g=h.items.map(e=>Gx(i,e)),_=X0(n,i,a,sS(i,h.items,h.photos),h.labels),v=await Promise.all(c.map(e=>kye({client:t,resources:n,views:r,load:e,owners:g})));return{rows:_.map((e,t)=>({...e,...Object.fromEntries(c.map((e,n)=>[e.column.name,v[n].get(g[t])??[]])),id:g[t]})),total:e===0?await p(h):h.totalSizeEstimate,nextPageToken:h.nextPageToken}},g=t=>e.fetchQuery({queryKey:u(t),staleTime:6e4,queryFn:()=>h(t)});return{page:g,loadRows:async e=>(await g(Math.floor(e/40))).rows}},S3=({resources:e,views:t,model:n,columns:r,filter:i,orderBy:a,related:o})=>{let s=W(),c=Km(),l=r.join(`,`),u=JSON.stringify(o??[]),d=(0,L.useMemo)(()=>jye({queryClient:c,client:s,resources:e,views:t,model:n,columns:r,filter:i,orderBy:a,...o&&{related:o}}),[c,s,e,t,n,l,i,a,u]),f=Kh({queryKey:[...U.first(n.name,i,a),l],queryFn:async()=>(await c.invalidateQueries({queryKey:U.pages(n.name,i,a),refetchType:`none`}),d.page(0))});return{source:(0,L.useMemo)(()=>f.data?{total:f.data.total,loadRows:d.loadRows,revision:f.dataUpdatedAt}:void 0,[f.data,f.dataUpdatedAt,d]),error:f.error,isLoading:f.isLoading,page:d.page,key:[...U.first(n.name,i,a),l]}},Q=a({en:{saveSearch:`Save search`,saveAsNew:e=>`Save as new ${e}`,updateName:e=>`Update ${e}`,updateNameQuestion:e=>`Update ${e}?`,updateNounQuestion:e=>`Update this ${e}?`,couldNotLoadYour:e=>`Could not load your ${e}`,noneYet:e=>`No ${e} yet.`,somethingWrong:`Something went wrong`,couldNotRename:`Could not rename the search`,renameTitle:e=>`Rename ${e}`,deleteTitle:e=>`Delete ${e}`,unreadableFilter:`A filter that cannot be read`,notFound:`Not found`,noResource:`There is no resource called {}.`,noSavedYet:e=>`No ${e} yet. Filter the {} and save the search.`,on:`On`,off:`Off`,saved:e=>`${e} saved`,couldNotChange:`Could not change the search`,asMany:e=>`As many ${e}`,more:(e,t)=>`${e} more ${t}`,fewer:(e,t)=>`${e} fewer ${t}`,cancel:`Cancel`,save:`Save`,optional:`Optional`,added:`Added`,removed:`Removed`,changed:`Changed`,filterChanges:`Filter changes`,firstOf:(e,t)=>`The first ${e} of ${t}.`,noPlural:e=>`No ${e}.`,update:`Update`,addedRemoved:(e,t)=>`${e} added, ${t} removed`,searchSaved:`Search saved`,openPlural:e=>`Open ${e.toLowerCase()}`,couldNotSave:`Could not save the search`,couldNotTakeOff:`Could not take the search off`,searchUpdated:`Search updated`,couldNotUpdate:`Could not update the search`,noneMatch:e=>`No ${e} match.`,noNew:e=>`No new ${e} since you last looked.`,viewAll:`View all results`,filters:`Filters`},nl:{saveSearch:`Zoekopdracht bewaren`,saveAsNew:e=>`Als extra ${e} bewaren`,updateName:e=>`${e} bijwerken`,updateNameQuestion:e=>`${e} bijwerken?`,updateNounQuestion:e=>`${e} bijwerken?`,couldNotLoadYour:e=>`Kon je ${e} niet laden`,noneYet:e=>`Nog geen ${e}.`,somethingWrong:`Er ging iets mis`,couldNotRename:`Kon de zoekopdracht niet hernoemen`,renameTitle:e=>`${e} hernoemen`,deleteTitle:e=>`${e} verwijderen`,unreadableFilter:`Een filter dat niet kan worden gelezen`,notFound:`Niet gevonden`,noResource:`Er is geen onderdeel met de naam {}.`,noSavedYet:e=>`Nog geen ${e}. Filter de {} en bewaar de zoekopdracht.`,on:`Aan`,off:`Uit`,saved:e=>`${e} bewaard`,couldNotChange:`Kon de zoekopdracht niet wijzigen`,asMany:e=>`Evenveel ${e}`,more:(e,t)=>`${e} ${t} meer`,fewer:(e,t)=>`${e} ${t} minder`,cancel:`Annuleren`,save:`Bewaren`,optional:`Optioneel`,added:`Erbij`,removed:`Eraf`,changed:`Gewijzigd`,filterChanges:`Wijzigingen in het filter`,firstOf:(e,t)=>`De eerste ${e} van ${t}.`,noPlural:e=>`Geen ${e}.`,update:`Bijwerken`,addedRemoved:(e,t)=>`${e} erbij, ${t} eraf`,searchSaved:`Zoekopdracht bewaard`,openPlural:e=>`${e} openen`,couldNotSave:`Kon de zoekopdracht niet bewaren`,couldNotTakeOff:`Kon de zoekopdracht niet weghalen`,searchUpdated:`Zoekopdracht bijgewerkt`,couldNotUpdate:`Kon de zoekopdracht niet bijwerken`,noneMatch:e=>`Geen ${e} gevonden.`,noNew:e=>`Geen nieuwe ${e} sinds je laatst keek.`,viewAll:`Alle resultaten bekijken`,filters:`Filters`}}),C3=`inline-flex h-6 items-center rounded-full border border-primary-border bg-primary-soft px-2.5 text-xs font-medium text-primary-text`,w3=({chips:e,className:t})=>(0,z.jsx)(`ul`,{className:g(`flex flex-wrap gap-1.5`,t),"aria-label":Q(`filters`),children:e.map(e=>(0,z.jsx)(`li`,{className:C3,children:e.label},e.key))}),T3=({chips:e})=>(0,z.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,t)=>(0,z.jsxs)(`span`,{className:C3,children:[t>0&&(0,z.jsx)(`span`,{className:`sr-only`,children:`, `}),e.label]},e.key))}),Mye=e=>e.map(e=>e.label).join(`, `),E3=a({en:{today:`Today`,yesterday:`Yesterday`,"24h":`Last 24 hours`,"7d":`Last 7 days`,"30d":`Last 30 days`,"90d":`Last 90 days`,month:`This month`,quarter:`This quarter`,year:`This year`,unknownPreset:e=>`The server offers the preset "${e}", which this UI does not know`,unsupported:e=>`${e} (unsupported)`,remove:e=>`Remove ${e}`,clearAll:`Clear all`,searchIn:e=>`Search ${e.toLowerCase()}`,noMatches:`No matches`,moreFilters:`More filters`,filters:`Filters`,date:`Date`,showOnly:`Show only`,minimum:e=>`${e} minimum`,maximum:e=>`${e} maximum`},nl:{today:`Vandaag`,yesterday:`Gisteren`,"24h":`Afgelopen 24 uur`,"7d":`Afgelopen 7 dagen`,"30d":`Afgelopen 30 dagen`,"90d":`Afgelopen 90 dagen`,month:`Deze maand`,quarter:`Dit kwartaal`,year:`Dit jaar`,unknownPreset:e=>`De server biedt de periode "${e}", die deze UI niet kent`,unsupported:e=>`${e} (niet ondersteund)`,remove:e=>`${e} verwijderen`,clearAll:`Alles wissen`,searchIn:e=>`Zoeken in ${e.toLowerCase()}`,noMatches:`Niets gevonden`,moreFilters:`Meer filters`,filters:`Filters`,date:`Datum`,showOnly:`Alleen tonen`,minimum:e=>`${e} minimum`,maximum:e=>`${e} maximum`}}),Nye=`inline-flex h-6 items-center gap-1 rounded-full border border-primary-border bg-primary-soft pl-2.5 pr-1.5 text-xs font-medium text-primary-text`,D3=({chips:e,lockedLabels:t=[],onRemove:n,onClear:r,scroll:i})=>e.length===0&&t.length===0?null:(0,z.jsxs)(`div`,{className:i?`flex flex-nowrap items-center gap-1.5 overflow-x-auto pb-1 [&>*]:shrink-0`:`flex flex-wrap items-center gap-1.5`,children:[t.map(e=>(0,z.jsxs)(`span`,{className:`inline-flex h-6 items-center gap-1.5 rounded-full border border-border-strong bg-muted px-2.5 text-xs font-medium text-foreground`,children:[(0,z.jsx)(ste,{className:`size-3 text-muted-foreground`}),e]},e)),e.map(e=>(0,z.jsxs)(`span`,{className:Nye,children:[e.label,(0,z.jsx)(`button`,{type:`button`,"aria-label":E3(`remove`,e.label),onClick:()=>n(e.key),className:`rounded-full p-0.5 hover:bg-primary-border/60`,children:(0,z.jsx)(ss,{className:`size-3`})})]},e.key)),e.length>0&&(0,z.jsx)(`button`,{type:`button`,onClick:r,className:`ml-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:E3(`clearAll`)})]}),Pye=[`today`,`7d`,`30d`,`year`],Fye=new Set([`today`,`yesterday`,`24h`,`7d`,`30d`,`90d`,`month`,`quarter`,`year`]),O3=e=>Fye.has(e)?E3(e):void 0,Iye=({value:e,presets:t=Pye,onChange:n})=>(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let r=O3(t);return(0,z.jsx)(`button`,{type:`button`,disabled:!r,title:r?void 0:E3(`unknownPreset`,t),onClick:()=>n(e===t?void 0:t),className:g(`h-7 rounded-md border px-2.5 text-body font-medium transition-colors`,!r&&`border-dashed text-danger-text`,e===t?`border-primary-border bg-primary-soft text-primary-text`:`border-border-strong bg-background text-muted-foreground hover:bg-muted`),children:r??E3(`unsupported`,t)},t)})}),k3=({label:e,onRemove:t})=>(0,z.jsxs)(`span`,{className:`inline-flex h-5 max-w-full items-center gap-0.5 rounded bg-primary-soft pl-1.5 pr-0.5 text-xs font-medium text-primary-text`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:e}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Kd(`remove`,e),className:`rounded p-0.5 hover:bg-primary-border/60`,onMouseDown:e=>e.preventDefault(),onClick:t,children:(0,z.jsx)(ss,{className:`size-3`})})]}),A3={facets:{},toggles:[]},j3=(e,t,n)=>{let r=e.facets[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{...e,facets:{...e.facets,[t]:i}}},M3=(e,t)=>({...e,toggles:e.toggles.includes(t)?e.toggles.filter(e=>e!==t):[...e.toggles,t]}),N3=(e,t,n)=>{let{[t]:r,...i}=e.ranges??{};return{...e,ranges:n?{...i,[t]:n}:i}},P3=(e,t)=>e.options.find(e=>e.value===t)?.label??e.labels?.[t]??t,F3=(e,t)=>{let n=e.facets.flatMap(e=>(t.facets[e.id]??[]).map(t=>({key:`facet:${e.id}:${t}`,label:`${e.label}: ${P3(e,t)}`}))),r=(e.ranges??[]).flatMap(e=>{let n=t.ranges?.[e.id];return n?[{key:`range:${e.id}`,label:`${e.label}: ${e.format(n[0])} – ${e.format(n[1])}`}]:[]}),i=t.date?[{key:`date`,label:O3(t.date)??t.date}]:[],a=t.toggles.map(t=>({key:`toggle:${t}`,label:e.toggles?.find(e=>e.id===t)?.label??t}));return[...n,...r,...i,...a]},I3=(e,t)=>{if(t===`date`)return{...e,date:void 0};let[n,r,i]=t.split(`:`);if(n===`range`)return N3(e,r,void 0);if(n===`toggle`)return M3(e,r);if(n===`facet`)return j3(e,r,i);throw Error(`Unknown filter chip key: ${t}`)},L3=(e,t)=>e.toLowerCase().includes(t.trim().toLowerCase()),Lye=(e,t)=>e.onSearch?e.options:e.options.filter(e=>L3(e.label,t)),Rye=(e,t,n)=>t===0?-1:n===`ArrowDown`?e<0?0:(e+1)%t:e<0?t-1:(e-1+t)%t,zye=({config:e,selected:t,onToggle:n,inline:r=!1})=>{let i=(0,L.useId)(),a=(0,L.useRef)(null),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(-1),f=r||c,p=Lye(e,o),m=(0,L.useRef)(e.onSearch);m.current=e.onSearch,(0,L.useEffect)(()=>()=>m.current?.(``),[]);let h=t=>{s(t),d(-1),e.onSearch?.(t)};return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-h-8 cursor-text flex-wrap items-center gap-1 rounded-md border border-border-strong bg-background px-2 py-1 shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20`,onClick:()=>a.current?.focus(),children:[(0,z.jsx)(_o,{className:`size-3.5 shrink-0 text-muted-foreground`}),t.map(t=>(0,z.jsx)(k3,{label:P3(e,t),onRemove:()=>n(t)},t)),(0,z.jsx)(`input`,{ref:a,autoFocus:r,role:`combobox`,"aria-label":e.label,"aria-expanded":f,"aria-controls":`${i}-options`,"aria-autocomplete":`list`,"aria-activedescendant":p[u]?`${i}-${u}`:void 0,placeholder:t.length>0?``:E3(`searchIn`,e.label),className:`h-6 min-w-16 flex-1 bg-transparent text-foreground outline-none placeholder:text-faint-foreground`,value:o,onChange:e=>h(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),d(Rye(u,p.length,e.key));return}if(e.key===`Enter`&&p[u]){e.preventDefault(),n(p[u].value);return}if(e.key===`Backspace`&&o===``&&t.length>0){n(t[t.length-1]);return}e.key===`Escape`&&o!==``&&(e.stopPropagation(),h(``))},onFocus:()=>l(!0),onBlur:()=>{l(!1),d(-1),!r&&o!==``&&h(``)}})]}),f&&(0,z.jsxs)(`ul`,{id:`${i}-options`,role:`listbox`,"aria-label":e.label,"aria-multiselectable":!0,className:g(`flex max-h-60 flex-col gap-px overflow-y-auto`,!r&&`rounded-md border bg-background p-1 shadow-sm`),children:[p.map((e,r)=>{let a=t.includes(e.value);return(0,z.jsxs)(`li`,{id:`${i}-${r}`,role:`option`,"aria-selected":a,tabIndex:-1,className:g(`flex cursor-pointer items-center gap-2 rounded px-1.5 py-1 hover:bg-muted`,r===u&&`bg-muted`),onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.value),children:[(0,z.jsx)(`span`,{className:g(`inline-flex size-4 shrink-0 items-center justify-center rounded border`,a?`border-primary bg-primary text-primary-foreground`:`border-border-strong bg-background`),children:a&&(0,z.jsx)(xi,{className:`size-3`,strokeWidth:3})}),(0,z.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,z.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:Mf(e.count)})]},e.value)}),p.length===0&&(0,z.jsx)(`li`,{className:`px-1.5 py-1 text-xs text-faint-foreground`,children:E3(`noMatches`)})]})]})},Bye=({config:e,selected:t,onToggle:n})=>{let[r,i]=(0,L.useState)(``),a=e.options.filter(e=>L3(e.label,r));return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.searchable&&(0,z.jsx)(Wd,{wrapperClassName:`mb-1 h-7`,leading:(0,z.jsx)(_o,{className:`size-3.5`}),placeholder:E3(`searchIn`,e.label),value:r,onChange:e=>i(e.target.value)}),a.map(e=>(0,z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-1 hover:bg-muted`,children:[(0,z.jsx)(xg,{checked:t.includes(e.value),onChange:()=>n(e.value),label:e.label}),(0,z.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,z.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:Mf(e.count)})]},e.value)),a.length===0&&(0,z.jsx)(`span`,{className:`px-1 py-1 text-xs text-faint-foreground`,children:E3(`noMatches`)})]})},R3=({label:e,activeCount:t,width:n=240,defaultOpen:r=!1,children:i})=>{let[a,o]=(0,L.useState)(r),[s,c]=(0,L.useState)(!1),l=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{a&&l.current&&c(l.current.getBoundingClientRect().left+n>document.documentElement.clientWidth)},[a,n]),(0,L.useEffect)(()=>{if(!a)return;let e=e=>{e.target instanceof Node&&!l.current?.contains(e.target)&&o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]),(0,z.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,z.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(!a),className:g(`inline-flex h-8 items-center gap-1.5 rounded-md border bg-background px-2.5 font-medium shadow-sm transition-colors hover:bg-muted`,t>0?`border-primary-border text-primary-text`:`border-border-strong text-foreground`),children:[e,t>0&&(0,z.jsx)(`span`,{className:`rounded-full bg-primary px-1.5 text-[11px] leading-4 text-primary-foreground`,children:t}),(0,z.jsx)(Ci,{className:`size-3.5 text-muted-foreground`})]}),a&&(0,z.jsx)(`div`,{className:g(`absolute top-full z-30 mt-1.5 rounded-lg border bg-background p-3 shadow-pop`,s?`right-0`:`left-0`),style:{width:n},children:typeof i==`function`?i(()=>o(!1)):i})]})},z3=({title:e,children:t})=>(0,z.jsxs)(`section`,{className:`flex flex-col gap-2 border-b py-3 last:border-b-0`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),t]}),B3=(e,t,n)=>{if(n!==0){if(e===`Home`)return 0;if(e===`End`)return n-1;if(e===`ArrowDown`)return t<0?0:(t+1)%n;if(e===`ArrowUp`)return t<0?n-1:(t-1+n)%n}},Vye=({items:e,onPick:t,close:n})=>{let r=(0,L.useRef)([]);return(0,L.useEffect)(()=>r.current[0]?.focus(),[]),(0,z.jsx)(`ul`,{role:`menu`,"aria-label":E3(`moreFilters`),onKeyDown:t=>{if(t.key===`Escape`)return n();let i=B3(t.key,r.current.indexOf(document.activeElement),e.length);i!==void 0&&(t.preventDefault(),r.current[i]?.focus())},className:`-mx-3 -my-3`,children:e.map((e,i)=>(0,z.jsx)(`li`,{role:`none`,children:(0,z.jsx)(`button`,{ref:e=>{r.current[i]=e},type:`button`,role:`menuitem`,className:goe,onClick:()=>{n(),t(e.key)},children:e.label})},e.key))})},Hye=({items:e,onPick:t})=>e.length===0?null:(0,z.jsx)(R3,{label:E3(`moreFilters`),activeCount:0,children:n=>(0,z.jsx)(Vye,{items:e,onPick:t,close:n})}),V3=(e,t)=>{let[n,r]=(0,L.useState)(e);return(0,L.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n},Uye=(e,t,n,r,i)=>{let a=n+(r-n)*e/t;return n+(r-n)*(e+1)/t>i[0]&&a<i[1]},H3=(e,t,n)=>n===t?0:(e-t)/(n-t),Wye=(e,t,n)=>t===0?[Math.min(n,e[1]),e[1]]:[e[0],Math.max(n,e[0])],Gye=1e3,Kye=({config:e,value:t,onChange:n})=>{let{min:r,max:i,step:a,histogram:o,format:s}=e,[c,l]=(0,L.useState)(),u=c??t??[r,i],d=Math.max(...o),f=()=>{c&&(l(void 0),n(c[0]===r&&c[1]===i?void 0:c))},p=V3(c,Gye);return(0,L.useEffect)(()=>{p&&f()},[p]),(0,z.jsxs)(`div`,{className:`w-full`,children:[(0,z.jsxs)(`div`,{className:`px-[7px]`,children:[o.length>0&&(0,z.jsx)(`div`,{className:`mb-1 flex h-12 items-end gap-0.5`,children:o.map((e,t)=>(0,z.jsx)(`span`,{className:g(`flex-1 rounded-t-sm`,Uye(t,o.length,r,i,u)?`bg-primary/70`:`bg-border`),style:{height:`${Math.max(6,e/d*100)}%`}},t))}),(0,z.jsxs)(`div`,{className:`relative h-4`,children:[(0,z.jsx)(`span`,{className:`absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-border`}),(0,z.jsx)(`span`,{className:`absolute top-1/2 h-1 -translate-y-1/2 rounded-full bg-primary`,style:{left:`${H3(u[0],r,i)*100}%`,right:`${100-H3(u[1],r,i)*100}%`}})]})]}),(0,z.jsx)(`div`,{className:`relative -mt-4 h-4`,children:[0,1].map(t=>(0,z.jsx)(`input`,{type:`range`,className:`pb-range`,"aria-label":E3(t===0?`minimum`:`maximum`,e.label),min:r,max:i,step:a,value:u[t],onChange:e=>l(Wye(u,t,Number(e.target.value))),onPointerUp:f,onTouchEnd:f,onBlur:f},t))}),(0,z.jsxs)(`div`,{className:`mt-2 flex justify-between text-xs tabular-nums text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:s(u[0])}),(0,z.jsx)(`span`,{children:s(u[1])})]})]})},qye=e=>[...new Set(e.map(e=>e.key.split(`:`).slice(0,2).join(`:`)))],U3=(e,t)=>{let n=t.filter(t=>!e.includes(t));return n.length===0?e:[...e,...n]},Jye=(e,t)=>{let n=[...e.facets.map(e=>({key:`facet:${e.id}`,label:e.label,secondary:e.secondary})),...(e.ranges??[]).map(e=>({key:`range:${e.id}`,label:e.label,secondary:e.secondary})),...e.datePresets?[{key:`date`,label:E3(`date`),secondary:e.dateSecondary}]:[],...(e.toggles??[]).map(e=>({key:`toggle:${e.id}`,label:e.label,secondary:e.secondary}))],r=new Set,i=[];for(let e of n)!e.secondary||t.includes(e.key)?r.add(e.key):i.push({key:e.key,label:e.label});return{shown:r,more:i}},W3=({label:e,checked:t,onChange:n})=>(0,z.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between gap-3 py-1`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(iC,{checked:t,onChange:n,label:e})]}),G3=(e,t)=>e.some(e=>e.length>0)||!!t,K3=({groups:e,trailing:t})=>{if(!G3(e,t))return null;let n=e.filter(e=>e.length>0);return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.map((e,t)=>(0,z.jsxs)(L.Fragment,{children:[t>0&&(0,z.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`}),e]},t)),t&&(0,z.jsx)(`div`,{className:`flex min-w-32 flex-1 justify-end`,children:t})]})},Yye=(e,t,n)=>{let[r,i]=(0,L.useState)(t??A3);return[e??r,e=>{i(e),n?.(e)}]},q3=({config:e,layout:t,value:n,defaultValue:r,onChange:i,lockedLabels:a,defaultOpenMenu:o,fullWidth:s,leading:c,trailing:l})=>{let[u,d]=Yye(n,r,i),f=F3(e,u),p=qye(f),[m,h]=(0,L.useState)(()=>p),[g,_]=(0,L.useState)();(0,L.useEffect)(()=>h(e=>U3(e,p)),[p.join(`,`)]);let v=(0,z.jsx)(D3,{chips:f,lockedLabels:a,onRemove:e=>d(I3(u,e)),onClear:()=>d(A3)}),y=(e,t=!1)=>{let n=u.facets[e.id]??[],r=t=>d(j3(u,e.id,t));return e.combobox?(0,z.jsx)(zye,{config:e,selected:n,onToggle:r,inline:t}):(0,z.jsx)(Bye,{config:e,selected:n,onToggle:r})},b=e.ranges??[],x=e=>(0,z.jsx)(Kye,{config:e,value:u.ranges?.[e.id],onChange:t=>d(N3(u,e.id,t))}),S=e.datePresets&&(0,z.jsx)(Iye,{value:u.date,presets:Array.isArray(e.datePresets)?e.datePresets:void 0,onChange:e=>d({...u,date:e})}),C=(e.toggles??[]).map(e=>(0,z.jsx)(W3,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(M3(u,e.id))},e.id));if(t===`panel`)return(0,z.jsxs)(`aside`,{className:s?`flex w-full flex-col gap-1`:`flex w-64 shrink-0 flex-col gap-1 overflow-y-auto rounded-lg border bg-background px-4 py-3`,children:[(0,z.jsx)(`div`,{className:`flex items-center justify-between pb-1`,children:(0,z.jsx)(`h2`,{className:`font-semibold`,children:E3(`filters`)})}),(f.length>0||(a?.length??0)>0)&&(0,z.jsx)(`div`,{className:`border-b pb-3`,children:v}),c,e.facets.map(e=>(0,z.jsx)(z3,{title:e.label,children:y(e)},e.id)),b.map(e=>(0,z.jsx)(z3,{title:e.label,children:x(e)},e.id)),S&&(0,z.jsx)(z3,{title:E3(`date`),children:S}),C.length>0&&(0,z.jsx)(z3,{title:E3(`showOnly`),children:C})]});let{shown:w,more:T}=Jye(e,m),E=e=>{h(t=>U3(t,[e])),_(e)},D=[...e.facets.filter(e=>w.has(`facet:${e.id}`)).map(e=>(0,z.jsx)(R3,{label:e.label,activeCount:(u.facets[e.id]??[]).length,width:e.combobox?280:void 0,defaultOpen:o===e.id||g===`facet:${e.id}`,children:y(e,!0)},e.id)),...b.filter(e=>w.has(`range:${e.id}`)).map(e=>(0,z.jsx)(R3,{label:e.label,activeCount:+!!u.ranges?.[e.id],width:280,defaultOpen:o===e.id||g===`range:${e.id}`,children:x(e)},`range:${e.id}`)),...S&&w.has(`date`)?[(0,z.jsx)(L.Fragment,{children:S},`date`)]:[]],O=(e.toggles??[]).filter(e=>w.has(`toggle:${e.id}`)).map(e=>(0,z.jsx)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:(0,z.jsx)(W3,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(M3(u,e.id))})},e.id)),k=[c?[(0,z.jsx)(L.Fragment,{children:c},`leading`)]:[],D,O,T.length>0?[(0,z.jsx)(Hye,{items:T,onPick:E},`more`)]:[]];return!G3(k,l)&&f.length===0&&!a?.length?null:(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(K3,{groups:k,trailing:l}),v]})},J3=Vn(),Y3={start:0,end:0},X3={"24h":{amount:24,unit:`h`},"7d":{amount:7,unit:`d`},"30d":{amount:30,unit:`d`},"90d":{amount:90,unit:`d`}},Xye=e=>new Date(e).toISOString().replace(`.000Z`,`Z`),Z3=(e,t,n)=>{let r=Hf(t.getTime(),n),[i,a]=[Number(r.slice(0,4)),Number(r.slice(5,7))-1],o=e=>new Date(e).toISOString().slice(0,10);return e===`year`?o(Date.UTC(i,0,1)):e===`quarter`?o(Date.UTC(i,Math.floor(a/3)*3,1)):e===`month`?o(Date.UTC(i,a,1)):e===`yesterday`?o(Date.parse(`${r}T00:00:00Z`)-864e5):r},Q3=[`year`,`quarter`,`month`,`yesterday`,`today`],$3=(e,t,n)=>t===`date`?e:Xye(Wf(e,n)),e6=(e,t,n)=>t===`date`?{kind:`string`,value:$3(e,t,n),span:Y3}:{kind:`timestamp`,value:$3(e,t,n),span:Y3},Zye=(e,t,n,r,i)=>{if(t in X3)return[J3.gte(e,J3.ago(t))];let a=J3.gte(e,e6(Z3(t,n,i),r,i));return t===`yesterday`?[a,J3.lt(e,e6(Z3(`today`,n,i),r,i))]:[a]},Qye=(e,t,n=new Date,r=If())=>{let i=e.facets.flatMap(e=>{let n=t.facets[e.id]??[];if(n.length===0)return[];if(e.flags){let t=e.options.filter(e=>n.includes(e.value)).map(e=>J3.eq(e.value,!0));return t.length===0?[]:[t.length===1?t[0]:J3.or(...t)]}return[n.length===1?J3.eq(e.id,n[0]):J3.in(e.id,n)]}),a=(e.ranges??[]).flatMap(e=>{let n=t.ranges?.[e.id];return n?[J3.gte(e.id,n[0]),J3.lte(e.id,n[1])]:[]}),o=e.dateField&&t.date?Zye(e.dateField,t.date,n,e.dateKind,r):[],s=(e.toggles??[]).filter(e=>t.toggles.includes(e.id)).map(e=>J3.eq(e.id,!0));return[...i,...a,...o,...s]},$ye=e=>e.length===0?``:Fn(J3.and(...e)),t6=(e,t,n=[],r=new Date,i=If())=>$ye([...Qye(e,t,r,i),...n]),n6=e=>e.kind===`and`?e.args.flatMap(n6):[e],r6=e=>e.field.path.join(`.`),ebe=e=>e.kind===`compare`&&e.op===`=`&&e.value.kind===`boolean`&&e.value.value,tbe=(e,t)=>{let n=e.kind===`or`?e.args:[e];if(!n.every(ebe))return;let r=n.map(r6),i=t.get(r[0]);return i!==void 0&&r.every(e=>t.get(e)===i)?{group:i,fields:r}:void 0},i6=e=>e.kind===`number`?String(e.raw):e.kind===`string`?String(e.value):void 0,a6=(e,t,n)=>{let r=e.value;if(r.kind===`now`&&r.offset?.sign===`-`){let{amount:e,unit:t}=r.offset.duration;return Object.entries(X3).find(([,n])=>n.amount===e&&n.unit===t)?.[0]}if(r.kind===`timestamp`)return Q3.find(e=>$3(Z3(e,t,n),`timestamp`,n)===r.value);if(r.kind===`string`)return Q3.find(e=>Z3(e,t,n)===r.value)},o6=(e,t,n=new Date,r=If())=>{let i=Xt(t);if(!i.ok)return{ok:!1,errors:i.errors};let a={facets:{},toggles:[]},o=[],s=new Set(e.facets.filter(e=>!e.flags).map(e=>e.id)),c=new Map(e.facets.filter(e=>e.flags).flatMap(e=>e.options.map(t=>[t.value,e.id]))),l=new Set((e.toggles??[]).map(e=>e.id)),u=new Set((e.ranges??[]).map(e=>e.id)),d=new Map,f,p;for(let t of i.ast?n6(i.ast):[]){let i=tbe(t,c);if(i&&!a.facets[i.group])a.facets[i.group]=i.fields;else if(t.kind===`compare`&&s.has(r6(t))&&t.op===`=`&&i6(t.value)!==void 0)a.facets[r6(t)]=[...a.facets[r6(t)]??[],i6(t.value)];else if(t.kind===`in`&&s.has(r6(t))&&t.values.every(e=>i6(e)!==void 0))a.facets[r6(t)]=[...a.facets[r6(t)]??[],...t.values.map(e=>i6(e))];else if(t.kind===`compare`&&e.dateField===r6(t)&&t.op===`>=`&&a6(t,n,r)&&!a.date)a.date=a6(t,n,r),f=t;else if(t.kind===`compare`&&e.dateField===r6(t)&&t.op===`<`&&(t.value.kind===`timestamp`||t.value.kind===`string`)&&t.value.value===$3(Z3(`today`,n,r),t.value.kind===`string`?`date`:`timestamp`,r))p=t;else if(t.kind===`compare`&&l.has(r6(t))&&t.op===`=`&&t.value.kind===`boolean`&&t.value.value)a.toggles.push(r6(t));else if(t.kind===`compare`&&u.has(r6(t))&&(t.op===`>=`||t.op===`<=`)&&t.value.kind===`number`){let e=d.get(r6(t))??{clauses:[]};t.op===`>=`?e.low=t.value.value:e.high=t.value.value,e.clauses.push(t),d.set(r6(t),e)}else o.push(t)}a.date===`yesterday`&&!p&&(o.push(f),a.date=void 0),p&&a.date!==`yesterday`&&o.push(p);for(let[e,t]of d)t.low!==void 0&&t.high!==void 0?a.ranges={...a.ranges,[e]:[t.low,t.high]}:o.push(...t.clauses);return{ok:!0,state:a,extras:o}},nbe=[`integer`,`bigint`,`decimal`],rbe=(e,t)=>{let n=e?.fields[t]?.type;return n!==void 0&&nbe.includes(n)},s6=(e,t)=>e.kind===`range`||e.kind===`facets`&&rbe(t,e.field),c6=e=>e.secondary?{secondary:!0}:{},ibe=e=>({id:e.field,label:e.field,min:0,max:0,step:1,histogram:[],format:String,...c6(e)}),l6=(e,t)=>{let n=e?.filters??[],r=n.find(e=>e.kind===`dateRange`);return{facets:n.flatMap(e=>e.kind===`facets`&&!s6(e,t)?[{id:e.field,label:e.field,options:[],searchable:e.search,...t?.fields[e.field]?.type===`relation`&&{combobox:!0},...c6(e)}]:e.kind===`flags`?[{id:e.fields.join(`|`),label:e.label,options:e.fields.map(e=>({value:e,label:e,count:0})),flags:!0,...c6(e)}]:[]),ranges:n.flatMap(e=>e.kind!==`flags`&&s6(e,t)?[ibe(e)]:[]),...r&&{dateField:r.field,...r.secondary&&{dateSecondary:!0},dateKind:t?.fields[r.field]?.type===`date`?`date`:`timestamp`,...r.presets.length>0&&{datePresets:r.presets}},toggles:n.flatMap(e=>e.kind===`toggle`?[{id:e.field,label:e.field,...c6(e)}]:[])}},u6=(e,t)=>(e?.filters??[]).some(e=>e.kind===`range`&&e.field===t&&e.histogram),d6=(e,t)=>{let n=e?.fields[t],r=n?.suffix??``;return e=>`${n?.prefix===`€`?kf(e*100).replace(`.00`,``):String(e)}${r}`},f6=Vn(),abe={start:0,end:0},obe=(e,t,n)=>{let r=o6(l6(t,e),n);return r.ok?Object.fromEntries(Object.entries(r.state.facets).filter(([t,n])=>e.fields[t]?.type===`relation`&&n.length>0)):{}},sbe=(e,t,n)=>{let r=e=>t?.fields[e]?.label??q(e),i=l6(t,e);return{...i,facets:i.facets.map(i=>{if(i.flags)return{...i,options:i.options.map(e=>({...e,label:r(e.value)}))};let a=e.fields[i.id]?.enumValues??[],o=e.fields[i.id]?.type===`enum`?Object.fromEntries(a.map(e=>[e,ps(e,t?.fields[i.id]?.valueLabels)])):n[i.id]??{};return{...i,label:r(i.id),labels:o}}),ranges:(i.ranges??[]).map(e=>({...e,label:r(e.id),format:d6(t,e.id)})),toggles:i.toggles?.map(e=>({...e,label:r(e.id)}))}},p6=(e,t,n,r={})=>{let i=sbe(e,t,r),a=o6(i,n);if(!a.ok)return[{key:`unreadable`,label:Q(`unreadableFilter`)}];let o=a.extras.map((e,t)=>({key:`extra:${t}`,label:e.kind===`search`?`"${e.text}"`:Fn(e)}));return[...F3(i,a.state),...o]},cbe=e=>Object.fromEntries(e.facets.filter(e=>!e.flags).map(e=>[e.id,{...e.labels,...Object.fromEntries(e.options.map(e=>[e.value,e.label]))}])),lbe=(e,t,n)=>{if(typeof n!=`string`||n===``)return e;let r=f6.gt(t,{kind:`timestamp`,value:new Date(n).toISOString(),span:abe}),i=Xt(e);if(!i.ok)throw Error(`The saved filter cannot be read: ${i.errors.map(e=>e.message).join(`; `)}`);return Fn(i.ast?f6.and(i.ast,r):r)},ube=(e,t)=>typeof t!=`string`||t===``?!0:typeof e!=`string`||e===``?!1:new Date(e).getTime()>new Date(t).getTime(),m6=(e,t)=>{let n=W(),r=Km(),{resources:i,views:a}=G(),o=a[e.name],s=Object.entries(obe(e,o,t)),c=Wh({queries:s.map(([t,o])=>{let s=i[e.fields[t].relation.resource];return{queryKey:U.labels(`chips:${e.name}.${t}`,o.join(`,`)),enabled:s!==void 0,queryFn:async()=>Object.fromEntries(await q0(r,n,s,o,a[s.name]))}})});return p6(e,o,t,Object.fromEntries(s.flatMap(([e],t)=>c[t]?.data?[[e,c[t].data]]:[])))},dbe=(e,t)=>({record:Object.fromEntries(Object.entries(t).filter(([t])=>Object.hasOwn(e.fields,t))),etag:typeof t.etag==`string`?t.etag:``,...typeof t.permissions==`object`&&t.permissions!==null&&{permissions:t.permissions}}),h6=e=>{let t=Km();return(0,L.useCallback)(n=>t.setQueryData(U.recordPreview(e.name,sr(Kx(e,n))),dbe(e,n)),[t,e])},fbe=Vn(),g6=e=>{if(typeof e==`string`||typeof e==`number`)return e;if(e&&typeof e==`object`&&`id`in e)return g6(e.id)},pbe=(e,t,n)=>n.flatMap(n=>{let r=g6(n[t]);return r===void 0?[]:[{key:sr(Kx(e,n)),target:r}]}),mbe=(e,t)=>e.find(e=>sr(e.target)===t),hbe=(e,t)=>[...e,{key:``,target:t}],gbe=(e,t)=>e.filter(e=>sr(e.target)!==t),_6=(e,t)=>{let[n]=e.primaryKey;if(e.primaryKey.length!==1||n===void 0)throw Error(`${e.name} has a composite key, so its saved records cannot be listed`);let r=[...new Set(t.map(e=>e.target))];return r.length===0?void 0:fbe.in(n,r)},v6=(e,t)=>U.list(e,``,``,500,`saved:${t}`),y6=(e,t,n)=>{let r=W(),i=G().resources[e];return Kh({queryKey:v6(e,t),enabled:n&&i!==void 0,queryFn:async()=>{let n=[],a;do{let o=await r.list(e,{pageSize:500,fields:[...i.primaryKey,t],...a&&{pageToken:a}});n.push(...o.items),a=o.nextPageToken||void 0}while(a);return pbe(i,t,n)}})},b6=a({en:{favorite:`Favorite`,couldNotLoadYour:e=>`Could not load your ${e}`,noneYet:e=>`No ${e} yet.`,somethingWrong:`Something went wrong`,couldNotTakeOff:`Could not take it off`,couldNotSave:`Could not save it`},nl:{favorite:`Favoriet`,couldNotLoadYour:e=>`Kon je ${e} niet laden`,noneYet:e=>`Nog geen ${e}.`,somethingWrong:`Er ging iets mis`,couldNotTakeOff:`Kon het niet weghalen`,couldNotSave:`Kon het niet bewaren`}}),_be=e=>e instanceof Error?e.message:b6(`somethingWrong`),vbe=(e,t,n)=>{let r=G(),i=W(),a=Km(),o=Hb(),s=RT(),{resource:c,field:l}=e,u=r.permissions[c],d=r.resources[c]!==void 0&&u!==void 0&&xT(u,`create`)&&xT(u,`delete`),f=r.signIn?.[c]?.signIn,p=y6(c,l,d),m=p.data&&mbe(p.data,t),h=v6(c,l),g=qh({mutationFn:async e=>{e?await i.remove(c,e.key):await i.create(c,{[l]:n})},onMutate:async e=>{await a.cancelQueries({queryKey:h,exact:!0});let r=a.getQueryData(h);return a.setQueryData(h,(r=[])=>e?gbe(r,t):hbe(r,n)),{before:r}},onError:(e,t,n)=>{a.setQueryData(h,n?.before),o.show({state:`error`,title:b6(t?`couldNotTakeOff`:`couldNotSave`),description:_be(e)})},onSettled:()=>s(c)});return{mode:d?`save`:f?`sign-in`:void 0,prompt:f,saved:m!==void 0,ready:p.data!==void 0&&!g.isPending,toggle:()=>g.mutate(m)}},ybe=({favorite:e,recordKey:t,target:n,className:r})=>{let i=vbe(e,t,n),[a,o]=(0,L.useState)(!1);if(!i.mode)return null;let s=e.label??b6(`favorite`),c=g(`absolute right-2 top-2 flex size-8 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm transition-colors hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,r);return i.mode===`sign-in`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":s,"aria-haspopup":`dialog`,className:c,onClick:()=>o(!0),children:(0,z.jsx)(oa,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(Wm,{as:`dialog`,prompt:i.prompt,open:a,onClose:()=>o(!1)})]}):(0,z.jsx)(`button`,{type:`button`,"aria-label":s,"aria-pressed":i.saved,"aria-disabled":!i.ready,className:c,onClick:()=>i.ready&&i.toggle(),children:(0,z.jsx)(oa,{className:g(`size-4`,i.saved&&`fill-current text-danger`),"aria-hidden":!0})})},x6=6,bbe=(e,t,n)=>{let r=e.bottom+x6;return{top:r+t.height>n.height-x6?Math.max(x6,e.top-x6-t.height):r,left:Math.max(x6,Math.min(e.left,n.width-x6-t.width))}},S6=(e,t)=>{let n=fS(e).find(e=>e.kind===`cards`);if(!n)return{kind:`cards`,name:`dot`,badge:t};let{photos:r,favorite:i,dots:a,...o}=n;return o},xbe=(e,t,n,r)=>(e?.list?.relatedColumns??[]).filter(e=>r.includes(e.name)).flatMap(e=>{let r=t[e.resource];return r?[{column:e,fields:xS(r,n[r.name],S6(n[r.name],e.status))}]:[]}),Sbe=a({en:{none:e=>`No ${e}`},nl:{none:e=>`Geen ${e}`}}),Cbe=(e,{values:t,label:n,singular:r,plural:i})=>{if(e.length===0)return Sbe(`none`,i);let a=new Map;for(let t of e)t!=null&&a.set(String(t),(a.get(String(t))??0)+1);let o=[...t,...[...a.keys()].filter(e=>!t.includes(e))].filter(e=>a.has(e)).map(e=>`${a.get(e)} ${n(e)}`),s=`${e.length} ${e.length===1?r:i}`;return o.length===0?s:`${s}: ${o.join(`, `)}`},C6=`flex shrink-0 items-center justify-center rounded-full p-0.5 pointer-coarse:p-1.5`,w6=`size-2.5 rounded-full`,T6=`flex min-w-0 items-center gap-0.5`,wbe=150,E6=288,Tbe=({shown:e,row:t,target:n,view:r,column:i,Card:a,onEnter:o,onLeave:s})=>{let c=(0,L.useRef)(null),[l,u]=(0,L.useState)();return(0,L.useLayoutEffect)(()=>{c.current&&u(bbe(e.dot,{width:E6,height:c.current.offsetHeight},{width:window.innerWidth,height:window.innerHeight}))},[e]),(0,ls.createPortal)((0,z.jsx)(`div`,{ref:c,"data-dot-card":!0,onMouseEnter:o,onMouseLeave:s,style:{width:E6,...l??{visibility:`hidden`,top:0,left:0}},className:`fixed z-50 rounded-lg shadow-pop`,children:(0,z.jsx)(a,{model:n,view:r,display:S6(r,i.status),row:t})}),document.body)},D6=({column:e,records:t,target:n,view:r,wrap:i=!1,Card:a})=>{let o=(0,L.useMemo)(()=>t.map(e=>CS(n,e)),[t,n]),[s,c]=(0,L.useState)(),l=(0,L.useRef)(void 0),u=(0,L.useRef)(`mouse`),d=(0,L.useRef)(null),f=n.fields[e.status],p=r?.fields[e.status],m=t=>f?rS(f,t.record[e.status],p):``,h=Hx(n,r),_=e=>e.labels[h]??String(e.record[h]??e.key),v=(r?.names?.singular??q(n.name)).toLowerCase(),y=(r?.names?.plural??q(n.name)).toLowerCase(),b=Cbe(o.map(t=>t.record[e.status]),{values:f?.enumValues??[],label:e=>f?rS(f,e,p):e,singular:v,plural:y}),x=()=>window.clearTimeout(l.current),S=()=>{x(),l.current=window.setTimeout(()=>c(void 0),wbe)},C=(e,t)=>{x(),c({key:e,dot:t.getBoundingClientRect()})};(0,L.useEffect)(()=>x,[]),(0,L.useEffect)(()=>{if(!s)return;let e=()=>c(void 0),t=t=>t.key===`Escape`&&e(),n=t=>{let n=t.target;!d.current?.contains(n)&&!n?.closest?.(`[data-dot-card]`)&&e()};return document.addEventListener(`keydown`,t),document.addEventListener(`pointerdown`,n),document.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{document.removeEventListener(`keydown`,t),document.removeEventListener(`pointerdown`,n),document.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[s]);let w=e=>t=>{u.current===`touch`&&s?.key!==e&&(t.preventDefault(),C(e,t.currentTarget))},T=e=>{e.relatedTarget?.closest?.(`[data-dot-card]`)||S()},E=s&&o.find(e=>e.key===s.key);return(0,z.jsxs)(`div`,{ref:d,className:g(T6,i&&`pointer-events-none flex-wrap`),onClick:e=>e.stopPropagation(),onPointerDown:e=>u.current=e.pointerType,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:b}),o.map(t=>{let r=t.record[e.status],i=Z0(p?.valueColors,r);return(0,z.jsx)(jS,{to:{kind:`record`,resource:n.name,key:t.key},"aria-label":`${_(t)}, ${m(t)}`,onPointerEnter:e=>e.pointerType!==`touch`&&C(t.key,e.currentTarget),onPointerLeave:e=>e.pointerType!==`touch`&&S(),onFocus:e=>e.currentTarget.matches(`:focus-visible`)&&C(t.key,e.currentTarget),onBlur:T,onClick:w(t.key),className:g(C6,`pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`),children:(0,z.jsx)(`span`,{"aria-hidden":!0,style:i===void 0?void 0:{backgroundColor:i},className:g(w6,i===void 0&&hd[Qx(String(r))],s?.key===t.key&&`ring-2 ring-foreground/30`)})},t.key)}),s&&E&&(0,z.jsx)(Tbe,{shown:s,row:E,target:n,view:r,column:e,Card:a,onEnter:x,onLeave:S})]})},Ebe=({count:e})=>(0,z.jsx)(`span`,{"aria-hidden":!0,className:g(T6,`invisible flex-wrap`),children:Array.from({length:e},(e,t)=>(0,z.jsx)(`span`,{className:C6,children:(0,z.jsx)(`span`,{className:w6})},t))}),O6=`flex flex-col gap-1.5`,Dbe=({dots:e})=>(0,z.jsx)(`span`,{className:O6,children:e.map(({column:e,records:t})=>(0,z.jsx)(Ebe,{count:t.length},e.name))}),Obe=({dots:e,Card:t})=>{let{resources:n,views:r}=G();return(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-[calc(0.75rem+1px)] bottom-[calc(0.75rem+1px)] ${O6}`,children:e.map(({column:e,records:i})=>{let a=n[e.resource];return a&&(0,z.jsx)(D6,{column:e,records:i,target:a,view:r[a.name],Card:t,wrap:!0},e.name)})})},kbe=(e,t,n)=>(t.dots??[]).flatMap(t=>{let r=e?.list?.relatedColumns?.find(e=>e.name===t),i=n.record[t];return r&&Array.isArray(i)&&i.length>0?[{column:r,records:i}]:[]}),k6=({value:e})=>{let t=dx(e,{width:320,height:240});return t?(0,z.jsx)(fC,{image:t,loading:`lazy`,className:`size-full object-cover`}):null},A6=({children:e})=>(0,z.jsx)(`span`,{className:`-mx-3 -mt-3 mb-1.5 block aspect-[4/3] overflow-hidden rounded-t-lg border-b border-border bg-muted`,children:e}),Abe=({value:e})=>(0,z.jsx)(A6,{children:(0,z.jsx)(k6,{value:e})}),jbe=10,Mbe=(e,t)=>{let n=tx(e)?e.uri:void 0,r=t.filter(e=>tx(e)&&e.uri!==n);return(n===void 0?r:[e,...r]).slice(0,jbe)},Nbe=(e,t)=>t===0?0:(e%t+t)%t,Pbe=(e,t,n)=>t<=0||n===0?0:Math.min(n-1,Math.max(0,Math.round(e/t))),j6=`pointer-events-auto absolute top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm opacity-0 transition-opacity group-has-[[data-card-photos]:hover]/card:opacity-100 group-hover/arrows:opacity-100 group-has-[:focus-visible]/arrows:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,M6=`[@media(hover:none)]:opacity-100`,Fbe=({photos:e,cover:t,swipe:n=!0,children:r})=>{let i=(0,L.useRef)(null),a=(0,L.useRef)(void 0),[o,s]=(0,L.useState)(0),c=Mbe(t,e),l=e=>{let t=i.current;t&&t.scrollTo({left:e*t.clientWidth})},u=e=>{a.current=Nbe((a.current??o)+e,c.length),l(a.current)},d=()=>{a.current=void 0},f=e=>{s(Pbe(e.scrollLeft,e.clientWidth,c.length)),a.current!==void 0&&Math.abs(e.scrollLeft-a.current*e.clientWidth)<1&&(a.current=void 0)},p=(0,z.jsx)(A6,{children:(0,z.jsx)(`span`,{ref:i,tabIndex:-1,"data-card-photos":!0,onPointerDown:d,onScroll:e=>f(e.currentTarget),className:g(`flex size-full snap-x snap-mandatory outline-none [scrollbar-width:none] motion-safe:scroll-smooth [&::-webkit-scrollbar]:hidden`,n?`overflow-x-auto overscroll-x-contain`:`overflow-x-hidden`),children:c.map((e,t)=>(0,z.jsx)(`span`,{className:`block size-full shrink-0 snap-start snap-always`,children:(0,z.jsx)(k6,{value:e})},t))})});return(0,z.jsxs)(z.Fragment,{children:[r(p),c.length>1&&(0,z.jsxs)(`div`,{className:`group/arrows pointer-events-none absolute inset-x-px top-px aspect-[4/3]`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":J(`previousPhoto`),className:g(j6,!n&&M6,`left-2`),onClick:()=>u(-1),children:(0,z.jsx)(Ti,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(`button`,{type:`button`,"aria-label":J(`nextPhoto`),className:g(j6,!n&&M6,`right-2`),onClick:()=>u(1),children:(0,z.jsx)(Di,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{className:`absolute inset-x-0 bottom-2 flex justify-center`,"aria-live":`polite`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:J(`photoOf`,o+1,c.length)}),(0,z.jsx)(`span`,{className:`flex items-center gap-1 rounded-full bg-background/70 px-1.5 py-1 leading-none`,"aria-hidden":!0,children:c.map((e,t)=>(0,z.jsx)(`span`,{className:g(`size-1.5 rounded-full`,t===o?`bg-foreground`:`bg-foreground/35`)},t))})]})]})]})},Ibe=({icon:e,children:t})=>{let n=km(e);return(0,z.jsxs)(`dd`,{className:`flex items-center gap-1 tabular-nums`,children:[n&&(0,z.jsx)(n,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t]})},N6=({model:e,view:t,display:n,row:r,swipe:i=!0,mark:a})=>{let{image:o,title:s,subtitle:c,amount:l,badge:u,meta:d,footer:f,flags:p}=vS(e,t,n),m=e=>t?.fields[e]?.label??q(e),h=n=>{let i=e.fields[n];if(!i)return``;let a=r.record[n];return r.labels[n]===void 0&&zx(i,t?.fields[n])&&typeof a==`string`&&a!==``?Rx(a):r.labels[n]??rS(i,a,t?.fields[n])},{fields:g,components:_}=hC(),v=h6(e),y=n.card===void 0?void 0:_?.[n.card],b=n=>{let i=e.fields[n],a=i&&gC(g,i,t?.fields[n]);return a?(0,z.jsx)(vC,{shown:a,part:`display`,field:i,value:r.record[n],fallback:h(n)}):h(n)},x=n=>{let i=e.fields[n],a=r.record[n];return!i||!zx(i,t?.fields[n])||gC(g,i,t?.fields[n])||typeof a!=`string`||a===``?b(n):(0,z.jsx)(yC,{source:a,inLink:!0})},S=n=>{let i=e.fields[n],a=t?.fields[n],o=r.record[n];return!i||a?.format!==`badge`||gC(g,i,a)||o==null||o===``?b(n):(0,z.jsx)(Q0,{value:o,hints:a,children:h(n)})},C=n=>{let i=e.fields[n];if(!i)return;if(r.labels[n]!==void 0||gC(g,i,t?.fields[n]))return(0,z.jsx)(`strong`,{className:`font-semibold text-foreground`,children:b(n)});let a=loe(i,r.record[n],t?.fields[n]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`strong`,{className:`font-semibold text-foreground`,children:a.amount}),a.suffix]})},w=y?void 0:n.photos,T=u===void 0?void 0:r.record[u],E=p.filter(e=>r.record[e]===!0),D=o===void 0?void 0:r.record[o],O=coe(r,l),k=yS(r,f),A=o!==void 0||w!==void 0,j=n.favorite,M=y?[]:kbe(t,n,r),N=e=>(0,z.jsxs)(z.Fragment,{children:[A&&e,(0,z.jsxs)(`span`,{className:`flex items-start justify-between gap-2 ${j&&!A?`pr-8`:``}`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:b(s)}),u!==void 0&&T!=null&&(0,z.jsx)(Q0,{value:T,hints:t?.fields[u],children:h(u)})]}),c!==void 0&&(0,z.jsx)(`span`,{className:t?.fields[c]?.markdown?`line-clamp-3 break-words text-muted-foreground`:t?.fields[c]?.multiline?`line-clamp-3 whitespace-pre-line break-words text-muted-foreground`:`truncate text-muted-foreground`,children:x(c)}),O!==void 0&&(0,z.jsx)(`span`,{className:`truncate tabular-nums text-muted-foreground`,children:C(O)}),d.length>0&&(0,z.jsx)(`dl`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-0.5 pt-1 text-xs text-muted-foreground`,children:yS(r,d).map(e=>(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[(0,z.jsx)(`dt`,{className:`sr-only`,children:m(e)}),(0,z.jsx)(Ibe,{icon:t?.fields[e]?.icon,children:S(e)})]},e))}),E.length>0&&(0,z.jsx)(`ul`,{className:`flex flex-wrap gap-1`,"aria-label":J(`features`),children:E.map(e=>(0,z.jsx)(`li`,{children:(0,z.jsx)(_d,{dot:!1,children:m(e)})},e))}),k.length>0&&(0,z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground ${d.length>0?``:`mt-auto`}`,children:k.map((e,t)=>(0,z.jsxs)(`span`,{children:[t>0&&(0,z.jsx)(`span`,{"aria-hidden":!0,children:` • `}),b(e)]},e))}),M.length>0&&(0,z.jsx)(Dbe,{dots:M})]}),P=t=>(0,z.jsxs)(jS,{to:{kind:`record`,resource:e.name,key:r.key},onClick:()=>v(r.record),className:`flex h-full flex-col gap-1.5 rounded-lg border border-border bg-background p-3 hover:border-border-strong hover:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,children:[a&&!A&&(0,z.jsx)(_d,{tone:`blue`,className:`self-start`,children:a}),y?(0,z.jsx)(Lg,{name:n.card,fallback:N(t),children:(0,z.jsx)(y,{row:r})}):N(t)]});return(0,z.jsxs)(`div`,{className:w?`group/card relative h-full`:j||a||M.length>0?`relative h-full`:`h-full`,children:[w?(0,z.jsx)(Fbe,{photos:r.photos??[],cover:D,swipe:i,children:P},r.key):P((0,z.jsx)(Abe,{value:D})),a&&A&&(0,z.jsx)(_d,{tone:`blue`,className:`pointer-events-none absolute top-2 left-2 shadow-sm`,children:a}),M.length>0&&(0,z.jsx)(Obe,{dots:M,Card:N6}),j&&(0,z.jsx)(ybe,{favorite:j,recordKey:r.key,target:Kx(e,r.record),className:A?void 0:`right-1.5 top-1.5`})]})},P6=268,F6=3,I6=(e,t,n)=>{let r=Math.floor(Math.max(0,e)/P6),i=Math.ceil((Math.max(0,e)+t)/P6);return{start:Math.max(0,r-F6),end:Math.min(n,i+F6)}},L6=e=>e*P6,Lbe=e=>{let t=(0,L.useRef)(null),[n,r]=(0,L.useState)({left:0,width:0});(0,L.useLayoutEffect)(()=>{let n=t.current;if(!n)return;let i=()=>r(t=>{let r={left:n.scrollLeft,width:n.clientWidth};return((t,n)=>{let[r,i]=[I6(t.left,t.width,e),I6(n.left,n.width,e)];return r.start===i.start&&r.end===i.end&&t.width===n.width&&t.left>0==n.left>0&&Math.abs(t.left-n.left)<1})(t,r)?t:r});i();let a=new ResizeObserver(i);return a.observe(n),n.addEventListener(`scroll`,i,{passive:!0}),()=>{a.disconnect(),n.removeEventListener(`scroll`,i)}},[e]);let i=Math.max(0,L6(e)-12),a=e=>t.current?.scrollBy({left:e*Math.max(L6(1),n.width-12),behavior:`smooth`});return{ref:t,...I6(n.left,n.width,e),back:n.left>0,on:n.left+n.width<i-1,page:a}},R6=a({en:{couldNotLoad:`Could not load`,noneMatch:e=>`No ${e} match.`,viewAll:`View all`,new:`New`,previous:e=>`Previous ${e}`,next:e=>`Next ${e}`,couldNotLoadYour:e=>`Could not load your ${e}`,noneYet:e=>`No ${e} yet.`},nl:{couldNotLoad:`Kon niet laden`,noneMatch:e=>`Geen ${e} gevonden.`,viewAll:`Alles bekijken`,new:`Nieuw`,previous:e=>`Terug in ${e}`,next:e=>`Verder in ${e}`,couldNotLoadYour:e=>`Kon je ${e} niet laden`,noneYet:e=>`Nog geen ${e}.`}}),z6=`absolute top-1/2 z-10 hidden size-8 -translate-y-1/2 items-center justify-center rounded-full border border-border-strong bg-background shadow-pop hover:bg-muted sm:flex`,B6=({cards:e})=>e>0?(0,z.jsx)(`li`,{"aria-hidden":!0,className:`shrink-0`,style:{width:L6(e)-12}}):null,Rbe=({model:e,view:t,display:n,source:r,label:i,isNew:a})=>{let{total:o}=r,s=Lbe(o),c=o3({total:o,rowAt:r.rowAt,loadRows:r.loadRows,revision:r.revision,latencyMs:0},s.start,Math.max(s.start,s.end-1)),l=Array.from({length:s.end-s.start},(e,t)=>s.start+t);return(0,z.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,z.jsxs)(`ul`,{ref:s.ref,"aria-label":i,className:`relative flex snap-x gap-3 overflow-x-auto overflow-y-hidden pb-1`,style:{scrollbarWidth:`thin`},children:[(0,z.jsx)(B6,{cards:s.start}),l.map(r=>{let i=c(r);if(!i)return(0,z.jsx)(`li`,{"aria-hidden":!0,className:`shrink-0`,style:{width:256},children:(0,z.jsx)(Yu,{className:`h-full min-h-24 rounded-lg`})},`skeleton-${r}`);let s=CS(e,i);return(0,z.jsx)(`li`,{"aria-posinset":r+1,"aria-setsize":o,className:`grid shrink-0 snap-start grid-cols-[minmax(0,1fr)]`,style:{width:256},children:(0,z.jsx)(N6,{model:e,view:t,display:n,row:s,swipe:!1,mark:a?.(s)?R6(`new`):void 0})},s.key)}),(0,z.jsx)(B6,{cards:o-s.end})]}),s.back&&(0,z.jsx)(`button`,{type:`button`,"aria-label":R6(`previous`,i.toLowerCase()),onClick:()=>s.page(-1),className:`${z6} -left-3`,children:(0,z.jsx)(Ti,{className:`size-4`,"aria-hidden":!0})}),s.on&&(0,z.jsx)(`button`,{type:`button`,"aria-label":R6(`next`,i.toLowerCase()),onClick:()=>s.page(1),className:`${z6} -right-3`,children:(0,z.jsx)(Di,{className:`size-4`,"aria-hidden":!0})})]})},zbe=Vn(),Bbe=(e,t)=>{if(!t)return e;let n=Xt(e);if(!n.ok)throw Error(`The filter cannot be read: ${n.errors.map(e=>e.message).join(`; `)}`);return Fn(n.ast?zbe.and(n.ast,t):t)},Vbe=(e,t)=>{let n=fS(e).filter(e=>e.kind===`cards`);return n.find(e=>e.name===t)??n[0]??{kind:`cards`,name:`cards`}},Hbe=()=>(0,z.jsx)(`div`,{className:`flex gap-3 overflow-hidden`,children:Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-24 w-64 shrink-0`},t))}),V6=({model:e,view:t,filter:n,sort:r=``,display:i,limit:a,chips:o=!0,empty:s,note:c,isNew:u,viewAll:d,scope:f,list:p})=>{let{resources:m,views:h}=G(),g=Nu(),_=Vbe(t,i),v=r||wS(e,t),y=S3({resources:m,views:h,model:e,columns:(0,L.useMemo)(()=>SS(e,t,[]),[e,t]),filter:(0,L.useMemo)(()=>Bbe(n,f),[n,f]),orderBy:v}),b=m6(e,n),x=(t?.names?.singular??q(e.name)).toLowerCase(),S=t?.names?.plural??q(e.name),C=y.source?.total,w=(0,L.useMemo)(()=>y.source&&{...y.source,total:Math.min(y.source.total,a??1/0)},[y.source,a]);return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[o&&b.length>0||C!==void 0||c?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[o&&b.length>0?(0,z.jsx)(w3,{chips:b}):(0,z.jsx)(`span`,{}),(0,z.jsxs)(`p`,{className:`flex flex-wrap gap-x-3 text-muted-foreground`,children:[c&&(0,z.jsx)(`span`,{children:c}),C!==void 0&&(0,z.jsx)(`span`,{className:`tabular-nums`,children:`${C.toLocaleString(l())} ${C===1?x:S.toLowerCase()}`})]})]}):null,y.isLoading?(0,z.jsx)(Hbe,{}):y.error?(0,z.jsx)(rC,{title:R6(`couldNotLoad`),error:y.error}):!w||w.total===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:s??R6(`noneMatch`,S.toLowerCase())}):(0,z.jsx)(Rbe,{model:e,view:t,display:_,source:w,label:S,isNew:u}),(0,z.jsxs)(jS,{to:u2(e,t,g,{filter:n,orderBy:v,display:_.name,savedSearch:d?.savedSearch,resource:p}),onClick:d?.onOpen,className:`flex items-center gap-1 self-end font-medium text-primary-text hover:underline`,children:[d?.label??(0,z.jsxs)(z.Fragment,{children:[R6(`viewAll`),` `,(0,z.jsx)(`span`,{className:`sr-only`,children:S.toLowerCase()})]}),(0,z.jsx)(Vr,{className:`size-3.5`,"aria-hidden":!0})]})]})},Ube=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=G(),o=DS(i,a,e.name),s=y6(e.name,t.listOf,!0),c=(t.names?.plural??q(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,z.jsx)(rC,{title:R6(`couldNotLoadYour`,c),error:s.error});if(!s.data)return(0,z.jsx)(Yu,{className:`h-24`});let l=_6(o.model,s.data);return l?(0,z.jsx)(V6,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:n??R6(`noneYet`,c)})},Wbe=e=>U.list(e,``,``,500,`saved-searches`),H6=(e,t)=>{let n=W(),{resources:r,views:i}=G(),a=r[e];return Kh({queryKey:Wbe(e),enabled:t&&a!==void 0,queryFn:async()=>{let t=[],r;do{let o=await n.list(e,{pageSize:500,orderBy:wS(a,i[e]),...r&&{pageToken:r}});t.push(...o.items),r=o.nextPageToken||void 0}while(r);return t}})},U6=({model:e,of:t,target:n,targetView:r,row:i,recordKey:a})=>{let o=W(),s=RT(),c=String(i[t.filter]??``),l=m6(n,c),u=t.name===void 0?void 0:i[t.name],d=typeof u==`string`&&u!==``?u:void 0,f=t.unseen,p=qh({mutationFn:t=>o.update(e.name,a,{[f.seenAt]:t},i.etag??`*`),onSettled:()=>s(e.name)}),m=Kh({...PT(o,n,f?lbe(c,f.field,i[f.seenAt]):``),enabled:f!==void 0}),h=(r?.names?.plural??q(n.name)).toLowerCase(),g={model:n,view:r,filter:c,sort:f?`${f.field} desc`:void 0,limit:t.limit,chips:d!==void 0,empty:Q(`noneMatch`,h),note:f&&m.data===0&&Q(`noNew`,h),isNew:f&&(e=>ube(e.record[f.field],i[f.seenAt])),viewAll:{label:Q(`viewAll`),savedSearch:a,...f&&{onOpen:()=>p.mutate(new Date().toISOString())}}};return{name:d,chips:l,title:d??Mye(l),body:g}},Gbe=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=sr(Kx(e,i)),{name:o,chips:s,title:c,body:l}=U6({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,z.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,z.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:(0,z.jsx)(jS,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,z.jsx)(T3,{chips:s})})}),(0,z.jsx)(V6,{...l})]})},Kbe=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=G(),a=t.searchesOf,o=r[a.resource],s=H6(e.name,!0),c=(t.names?.plural??q(e.name)).toLowerCase();return o?s.error?(0,z.jsx)(rC,{title:Q(`couldNotLoadYour`,c),error:s.error}):s.data?s.data.length===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:n??Q(`noneYet`,c)}):(0,z.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,z.jsx)(Gbe,{model:e,view:t,target:o,targetView:i[a.resource],row:n},sr(Kx(e,n))))}):(0,z.jsx)(Yu,{className:`h-40`}):null},qbe=({node:e,slots:t})=>{let{resource:n,filter:r=``,sort:i,limit:a,display:o,title:s,description:c,empty:l}=HT(e),{resources:u,views:d}=G(),f=u[n];if(!f)return null;let p=d[f.name];return(0,z.jsx)(GT,{title:s,description:c,actions:t.actions,children:p?.searchesOf?(0,z.jsx)(Kbe,{model:f,view:p,empty:l}):p?.listOf===void 0?(0,z.jsx)(V6,{model:f,view:p,filter:r,sort:i,limit:a,display:o,empty:l}):(0,z.jsx)(Ube,{model:f,view:p,limit:a,display:o,empty:l})})},W6=(e,t)=>{let{resources:n}=G(),r=W(),i=JSON.stringify(e),a=(0,L.useMemo)(()=>JSON.parse(i).map(yc),[i]),o=e=>!!(t&&Object.hasOwn(t.model.fields,e)),s=[...new Set(a.flatMap(e=>e.ok?e.paths:[]))],c=new Map(s.flatMap(e=>{let t=xc(e,o);return t===void 0?[]:[[e,t]]})),l=s.filter(e=>!c.has(e)),u=[...new Set(c.values())].flatMap(e=>n[e]?[n[e]]:[]),d=Yhe(t,l),f=Wh({queries:u.map(e=>PT(r,e))});return a.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=c.get(n);if(e===void 0){let e=d[l.indexOf(n)];if(e.state===`loading`)return;e.state===`ready`&&(t[n]=e.value);continue}let r=u.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(f[r].isPending)return;else t[n]=f[r].data??0}return bc(e,t)})},Jbe=({node:e,children:t})=>{let{when:n}=HT(e),[r]=W6([n],bT());return r?(0,z.jsx)(z.Fragment,{children:t}):null},G6=`text-2xl font-semibold tracking-tight tabular-nums`,Ybe=({model:e,filter:t})=>{let{views:n}=G(),r=FT(e,t);return r.isPending?(0,z.jsx)(Yu,{className:`h-8 w-16`}):r.error?(0,z.jsx)(`span`,{className:`text-danger-text`,children:Ig(`couldNotCount`)}):(0,z.jsx)(jS,{to:dE(n[e.name],e.name,t),className:`${G6} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:r.data.toLocaleString(l())})},Xbe=({field:e,format:t})=>{let n=r2(bT(),e);return n.state===`loading`?(0,z.jsx)(Yu,{className:`h-8 w-16`}):n.state===`missing`?null:(0,z.jsx)(`span`,{className:G6,children:(0,z.jsx)($0,{model:n.model,field:n.field,value:n.value,format:t})})},Zbe=({node:e})=>{let{label:t,value:n,resource:r,filter:i,field:a,format:o,description:s}=HT(e),{resources:c}=G(),l=r===void 0?void 0:c[r];return(0,z.jsxs)(GT,{className:`relative h-full`,bodyClassName:`flex flex-col`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground break-words`,children:t}),(0,z.jsxs)(`div`,{className:`mt-auto pt-1`,children:[n!==void 0&&(0,z.jsx)(`span`,{className:G6,children:n}),l&&(0,z.jsx)(Ybe,{model:l,filter:i}),a!==void 0&&(0,z.jsx)(Xbe,{field:a,format:o})]}),s&&(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s})]})},K6=(e,t)=>{let n=e.position;if(!n||!xT(t,`update`))return;let r=e.fields[n.field];return r&&!r.readOnly?n.field:void 0},q6=(e,t)=>e.position?.within===void 0?K6(e,t):void 0,Qbe=(e,t,n)=>t.position?.within!==void 0&&e.field===t.position.within&&!e.through&&!e.from&&!e.filter?K6(t,n):void 0,$be=(e,t,n,r)=>{if(t===void 0||e?.list?.drag?.rank!==!0||r!==``)return!1;let i=TS(n);return i.columnId===t&&i.direction===`asc`},J6=e=>e===null?`none`:`value:${e}`,Y6=e=>e.data.current?.sortable!==void 0,X6=e=>{let t=vae(e),n=t.find(e=>e.data?.droppableContainer&&Y6(e.data.droppableContainer));return n?[n]:t.length>0?t:cv(e)},exe=(e,{context:{collisionRect:t,droppableRects:n,droppableContainers:r,over:i}})=>{let a=e.code===`ArrowRight`?1:e.code===`ArrowLeft`?-1:0;if(a===0||!t)return;e.preventDefault();let o=r.getEnabled(),s=o.filter(e=>!Y6(e)).flatMap(e=>{let t=n.get(e.id);return t?[{id:e.id,rect:t}]:[]}).sort((e,t)=>e.rect.left-t.rect.left),c=t.left+t.width/2,l=i?.data.current?.sortable?.containerId??i?.id,u=l===void 0?s.findIndex(e=>e.rect.left<=c&&c<=e.rect.right):s.findIndex(e=>e.id===l),d=s[u+a];if(u===-1||!d)return;let f=Z6(o,n,d.id)[0];return{x:d.rect.left+(d.rect.width-t.width)/2,y:f?.rect.top??d.rect.top}},Z6=(e,t,n)=>e.filter(e=>e.data.current?.sortable?.containerId===n).flatMap(e=>{let n=t.get(e.id);return n?[{id:e.id,rect:n}]:[]}).sort((e,t)=>e.rect.top-t.rect.top),txe=(e,t)=>{let n=e.code===`ArrowDown`?1:e.code===`ArrowUp`?-1:0;if(n===0)return exe(e,t);let{droppableRects:r,droppableContainers:i,over:a}=t.context,o=a?.data.current?.sortable?.containerId??a?.id;if(o===void 0)return;let s=Z6(i.getEnabled(),r,o),c=s[(a?.id===o?s.length:s.findIndex(e=>e.id===a?.id))+n];if(c)return e.preventDefault(),{x:c.rect.left,y:c.rect.top}},Q6=(e,t,n,r)=>{let i=Jh({queryKey:[...n,`display`],enabled:r,initialPageParam:0,queryFn:({pageParam:e})=>t(e),getNextPageParam:(e,t)=>e.rows.length===40&&t.length*40<(t[0]?.total??0)?t.length:void 0}),a=i.data?.pages??[];return{resource:e.name,rows:a.flatMap(t=>t.rows.map(t=>CS(e,t))),total:a[0]?.total??0,loading:i.isPending,error:i.error,more:i.hasNextPage,loadMore:()=>void i.fetchNextPage()}},nxe=({model:e,by:t,value:n,fields:r,filter:i,orderBy:a})=>{let{resources:o,views:s}=G(),c=S3({resources:o,views:s,model:e,columns:r,filter:noe(i,t,n),orderBy:a});return Q6(e,c.page,c.key,!0)},rxe=(e,t)=>{if(!t)return e;let n=new Map(e.map(e=>[e.key,e])),r=new Set(t);return[...t.flatMap(e=>n.get(e)??[]),...e.filter(e=>!r.has(e.key))]},ixe=({model:e,view:t,display:n,column:r,fields:i,filter:a,orderBy:o,limit:s,moves:c,movable:u,placeable:d,dragged:f})=>{let p=nxe({model:e,by:n.by,value:r.value,fields:i,filter:a,orderBy:o}),m=uS(e,t,n),h=new Set(p.rows.map(e=>e.key)),_=new Map(c.map(e=>[e.row.key,e])),v=p.rows.filter(e=>_.has(e.key)&&_.get(e.key).to!==r.value),y=c.filter(e=>e.to===r.value&&!h.has(e.row.key)).map(e=>e.row),b=p.rows.filter(e=>!v.includes(e)).map(e=>_.has(e.key)?_.get(e.key).row:e),x=c.findLast(e=>e.to===r.value&&e.order),S=rxe([...y,...b],x?.order).slice(0,s),{setNodeRef:C,isOver:w}=Dy({id:J6(r.value),data:{column:r,rows:S}}),T=p.total-v.length+y.length;if(r.value===null&&!p.loading&&T===0&&!w)return null;let E=(t?.names?.plural??q(e.name)).toLowerCase(),D=t?.fields[n.by];return(0,z.jsxs)(`section`,{ref:C,"aria-label":`${r.label}, ${T}`,className:g(`flex w-72 shrink-0 snap-start flex-col gap-2 rounded-lg bg-surface p-2`,w&&`ring-2 ring-primary/30`),children:[(0,z.jsxs)(`header`,{className:`flex items-center justify-between gap-2 px-1 pt-0.5`,children:[(0,z.jsx)(`h2`,{className:`min-w-0 truncate text-body font-medium`,children:r.value===null?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:r.label}):(0,z.jsx)(Q0,{value:r.value,hints:D,children:r.label})}),!p.loading&&(0,z.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:T.toLocaleString(l())})]}),p.loading?Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-20`},t)):p.error?(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:p.error}):S.length===0?(0,z.jsx)(`p`,{className:`px-1 py-4 text-center text-xs text-muted-foreground`,children:J(`noPlural`,E)}):(0,z.jsx)(Xy,{id:J6(r.value),items:S.map(e=>e.key),strategy:Ky,children:(0,z.jsx)(`ul`,{className:`-mb-2 flex flex-col`,children:S.map(n=>(0,z.jsx)(axe,{model:e,view:t,card:m,row:n,column:r,rows:S,draggable:(u||d)&&ST(n.record,`update`),placeable:d,dragged:f},n.key))})}),s===void 0&&p.more&&(0,z.jsx)(V,{size:`sm`,variant:`ghost`,onClick:p.loadMore,children:J(`showMore`)})]})},axe=({model:e,view:t,card:n,row:r,column:i,rows:a,draggable:o,placeable:s,dragged:c})=>{let{setNodeRef:l,setActivatorNodeRef:u,listeners:d,isDragging:f,isOver:p,active:m,transform:h,transition:_}=ib({id:r.key,data:{row:r,column:i,rows:a},disabled:{draggable:!o,droppable:!s}}),v=p&&m?.data.current?.column?.value!==i.value;return(0,z.jsx)(`li`,{ref:e=>{l(e),u(e?.querySelector(`a`)??e)},...d,onDragStart:e=>e.preventDefault(),onClickCapture:e=>{c()&&(e.preventDefault(),e.stopPropagation())},style:{transform:h?`translate3d(${h.x}px, ${h.y}px, 0)`:void 0,transition:_},className:g(`relative pb-2`,o&&`cursor-grab touch-manipulation`,f&&`opacity-40`,v&&`before:absolute before:inset-x-0 before:-top-1 before:h-0.5 before:rounded-full before:bg-primary`),children:(0,z.jsx)(N6,{model:e,view:t,display:n,row:r,swipe:!1})})},$6=e=>e.kind===`and`?e.args.flatMap($6):[e],e8=e=>e.kind===`string`?String(e.value):void 0,oxe=(e,t)=>{if(e.kind===`compare`&&e.op===`=`&&e.field.path.join(`.`)===t){let t=e8(e.value);return t===void 0?void 0:[t]}if(e.kind===`in`&&e.field.path.join(`.`)===t){let t=e.values.map(e8);return t.every(e=>e!==void 0)?t:void 0}},sxe=(e,t,n)=>{let r=Xt(e);if(!r.ok||!r.ast)return n;let i=$6(r.ast).map(e=>oxe(e,t)).filter(e=>e!==void 0);return n.filter(e=>i.every(t=>e.value!==null&&t.includes(e.value)))},t8=(e,t)=>t!==null&&Object.hasOwn(e,t)?e[t]:void 0,n8=a({en:{done:`Done`,reorder:`Reorder`,couldNotLoad:`Could not load`,nothingYet:`Nothing here yet.`,couldNotChange:`Could not change the order`,orderChanged:`Order changed`,undo:`Undo`,couldNotUndo:`Could not undo`,movedToPlace:e=>`Moved to place ${e}`,notMoved:`Left in its place`,noRule:`No drop rule is registered as {}. Give it in dropRules in protobase.ui.tsx, or load the plugin that provides it.`},nl:{done:`Klaar`,reorder:`Volgorde wijzigen`,couldNotLoad:`Kon niet laden`,nothingYet:`Hier staat nog niets.`,couldNotChange:`Kon de volgorde niet wijzigen`,orderChanged:`Volgorde gewijzigd`,undo:`Ongedaan maken`,couldNotUndo:`Kon niet ongedaan maken`,movedToPlace:e=>`Verplaatst naar plaats ${e}`,notMoved:`Op zijn plaats gelaten`,noRule:`Er is geen sleepregel geregistreerd als {}. Geef die in dropRules in protobase.ui.tsx, of laad de plug-in die haar levert.`}}),r8=(e,t,n)=>t.flatMap(({before:t,record:r,etag:i})=>{let a=n.filter(e=>Object.hasOwn(t,e)&&t[e]!==r[e]);return a.length===0?[]:[{op:`update`,resource:e.name,key:Kx(e,r),data:Object.fromEntries(a.map(e=>[e,t[e]])),etag:i}]}),i8=async(e,t,n)=>{let r=[],i=``;do{let a=await e.search(t,{filter:n,pageSize:100,...i&&{pageToken:i}});r.push(...a.items),i=a.nextPageToken}while(i);return r},a8=(e,t)=>t===void 0?e:`(${e}) AND (${t})`,o8=async(e,t,n,r)=>{let i=t.position?.after;if(!i)return{after:[],before:[]};let a=t.primaryKey[0],o=Kx(t,r),s=e=>sr([e]),c=await i8(e,i.resource,a8(Fn(Hn.or(Hn.eq(i.field,o),Hn.eq(i.key,o))),i.filter)),l=(e,t)=>c.flatMap(n=>s(n[e])===s(o)&&s(n[t])!==s(o)?[n[t]]:[]),u=l(i.field,i.key),d=l(i.key,i.field),[f,p]=await Promise.all([i8(e,t.name,a8(Fn(Hn.in(a,[o,...u])),i.while)),d.length===0?[]:i8(e,t.name,Fn(Hn.in(a,d)))]),m=e=>{let r=sr(Kx(t,e));return{key:r,rank:e[t.position.field],title:Ux(t,n,e,r)}},h=f.some(e=>s(e[a])===s(o));return{after:f.filter(e=>s(e[a])!==s(o)).map(m),before:h?p.map(m):[]}},s8=e=>typeof e==`number`&&Number.isInteger(e),c8=(e,t,n)=>{let r=0;for(;r<t&&s8(e[r])&&(r===0||e[r]>e[r-1]);)r+=1;let i=e.length;for(;i-1>n&&s8(e[i-1])&&(i===e.length||e[i-1]<e[i]);)--i;let a=Math.min(t,r),o=a===0?1:e[a-1]+1,s=Math.max(n,i-1);for(;s+1<e.length&&e[s+1]<=o+(s-a);)s+=1;return{first:a,last:s,start:o}},cxe=(e,t,n)=>{let r=e.findIndex(e=>e.key===t.key);return r===-1?[...e.slice(0,n),t,...e.slice(n)]:zy(e,r,n)},l8=(e,t,n)=>{let r=e.findIndex(e=>e.key===t.key);return{order:cxe(e,t,n),first:r===-1?n:Math.min(r,n),last:r===-1?n:Math.max(r,n)}},u8=e=>typeof e.record.etag==`string`?e.record.etag:`*`,lxe=(e,t,n,r,i,a,o,s,c)=>{let l=(r.record[t]??null)!==i.value,u=c8(a.map(e=>e.record[n]),o,s),d=a.slice(u.first,u.last+1),f=e=>l&&e.key===r.key?`*`:u8(e),p=(t,r)=>({op:`reorder`,resource:e.name,field:n,keys:t.map(t=>Kx(e,t.record)),start:r,etags:Object.fromEntries(t.map(t=>[sr(Kx(e,t.record)),f(t)]))}),m=d.filter(e=>e.key!==r.key),h=c===void 0?[p(d,u.start)]:[p([r],c),...m.length>0?[p(m,u.start)]:[]];return l?[{op:`update`,resource:e.name,key:Kx(e,r.record),data:{[t]:i.value},etag:u8(r)},...h]:h},uxe=(e,t,n)=>{let r=new Map(t.map(t=>[sr(Kx(e,t.record)),t.record])),i=new Map;for(let t of n.results){let n=t.op===`reorder`?t.records:t.op===`update`?[t]:[];for(let{record:t,etag:r}of n)i.set(sr(Kx(e,t)),{record:t,etag:r})}return[...i].flatMap(([e,t])=>{let n=r.get(e);return n?[{before:n,...t}]:[]})},d8=a({en:{dependsOn:(e,t)=>`${e} depends on ${t}.`},nl:{dependsOn:(e,t)=>`${e} hangt af van ${t}.`}}),f8=e=>e!=null&&e!==``,dxe=({model:e,rank:t,rows:n,row:r,index:i,bounds:a,title:o})=>{let s=n.some(e=>e.key===r.key)?n.length-1:n.length,c;for(let l=i;l<=s;l++){let{order:i,first:u,last:d}=l8(n,r,l),f=i.map(e=>e.record[t]),p=c8(f,u,d),m=new Map(i.map((t,n)=>[sr(Kx(e,t.record)),n>=p.first&&n<=p.last?p.start+n-p.first:f[n]])),h=e=>m.has(e.key)?m.get(e.key):e.rank,g=Number(m.get(sr(Kx(e,r.record)))),_=a.after.filter(e=>f8(h(e))&&Number(h(e))>=g),v=a.before.find(e=>f8(h(e))&&Number(h(e))<=g),y=v?d8(`dependsOn`,v.title,o):_[0]&&d8(`dependsOn`,o,_[0].title);if(!y)return{place:{index:l},...c!==void 0&&{reason:c}};if(c??=y,l!==s||v)continue;let b=Math.max(..._.map(e=>Number(h(e))))+1;if(a.before.every(e=>!f8(h(e))||Number(h(e))>b))return{place:{index:l,bump:b},reason:c}}return{reason:c}},fxe=({model:e,view:t,by:n,rank:r,drop:i,labelOf:a,titleOf:o})=>{let s=W(),c=Hb(),l=RT(),[u,d]=(0,L.useState)([]),f=(0,L.useRef)(void 0),p=e=>d(t=>t.filter(t=>t.row.key!==e)),m=r?[n,r]:[n],h=qh({mutationFn:e=>e(),onError:e=>c.show({state:`error`,title:J(`couldNotUndo`),description:dS(e)}),onSettled:()=>l(e.name)}),g=async(t,r)=>{let a=i&&t8(i,r.value);if(!a)throw Error(`The column ${r.label} takes no cards`);let o=Kx(e,t.record),c=typeof t.record.etag==`string`?t.record.etag:`*`,l=await a({resource:e.name,record:t.record,recordKey:o,etag:c,to:r.value,client:s});return{landed:(await s.get(e.name,o)).record[n]??null,...l&&{undo:l}}},_=(t,n)=>({landed:n.value,undo:()=>s.batchWrite(r8(e,t,m))}),v=(e,t,r)=>{let i={...e,record:{...e.record,[n]:t.value}},a=r?.map(e=>e.key);d(n=>[...n.filter(t=>t.row.key!==e.key),{row:i,to:t.value,...a&&{order:a}}])},y=async(n,i,a)=>{if(!e.position?.after)return{index:a.index};let l=await o8(s,e,t,n.record),u=dxe({model:e,rank:r,rows:a.rows,row:n,index:a.index,bounds:l,title:o(n)}),d=!u.place||u.place.bump===void 0&&u.place.index===a.rows.findIndex(e=>e.key===n.key);if(u.reason!==void 0&&c.show({state:`warning`,title:d?n8(`notMoved`):n8(`movedToPlace`,u.place.index+1),description:u.reason}),!d)return u.place.index!==a.index&&v(n,i,l8(a.rows,n,u.place.index).order),u.place},b=async(t,i,a)=>{let o=await y(t,i,a);if(!o)return;let{order:c,first:l,last:u}=l8(a.rows,t,o.index);return _(uxe(e,c,await s.batchWrite(lxe(e,n,r,t,i,c,l,u,o.bump))),i)},x=qh({mutationFn:async({row:t,to:a,place:o})=>{if(o&&!r)throw Error(`A board places a card only by its rank`);let c=t.record[n]??null;if(i&&a.value!==c)return g(t,a);if(o)return b(t,a,o);let l=typeof t.record.etag==`string`?t.record.etag:`*`,u=await s.update(e.name,Kx(e,t.record),{[n]:a.value},l);return _([{before:t.record,record:u.record,etag:u.etag}],a)},onMutate:({row:e,to:t,place:n})=>v(e,t,n&&l8(n.rows,e,n.index).order),onSuccess:(e,{row:t,to:r})=>{if(!e)return;let{landed:i,undo:o}=e;f.current!==void 0&&c.dismiss(f.current),f.current=void 0;let s=t.record[n]??null,l=i===s?s===r.value?J(`orderChanged`):J(`stayedIn`,a(i)):J(`movedTo`,a(i));if(!o){c.show({state:`success`,title:l});return}let u=c.show({state:`success`,title:l,action:{label:J(`undo`),onClick:()=>{c.dismiss(u),f.current=void 0,h.mutate(o)}}});f.current=u},onError:(e,{row:t,to:r})=>{p(t.key);let i=(t.record[n]??null)===r.value?J(`couldNotReorder`):J(`couldNotMoveTo`,r.label);c.show({state:`error`,title:i,description:dS(e)})},onSettled:async(t,n,{row:r})=>{await l(e.name),p(r.key)}});return{moves:u,move:(e,t,n)=>x.mutate({row:e,to:t,...n&&{place:n}})}},p8=(e,t)=>{let n=e.data.current;if(!n?.column||!n.rows)return;if(n.sortable)return{column:n.column,rows:n.rows,index:n.sortable.index};let r=n.rows.some(e=>e.key===t.key);return{column:n.column,rows:n.rows,index:r?n.rows.length-1:n.rows.length}},m8=({model:e,view:t,display:n,fields:r,filter:i,orderBy:a,limit:o})=>{let s=toe(e,t,n),c=sxe(i,n.by,s),l=uS(e,t,n),u=cg(e.name),{boardDrops:d}=hC(),f=t?.list?.drag,p=typeof f?.board==`string`?f.board:void 0,m=p===void 0?void 0:d?.[p],h=t=>xT(u,`update`)&&(f?.board===!0?!e.fields[n.by]?.readOnly:m!==void 0&&t8(m,t)!==void 0),g=c.some(e=>h(e.value)),_=lS(e),v=f?.rank===!0&&_!==void 0&&q6(e,u)!==void 0,y=_?`${_} asc`:a,b=e=>s.find(t=>t.value===e)?.label??String(e),x=e=>String(e.labels[l.title]??e.record[l.title]??e.key),{moves:S,move:C}=fxe({model:e,view:t,by:n.by,rank:_,drop:m,labelOf:b,titleOf:x}),[w,T]=(0,L.useState)(),E=(0,L.useRef)(!1),D=ev($_($v,{activationConstraint:{distance:4}}),$_(ty,{activationConstraint:{delay:250,tolerance:5}}),$_(Gv,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:txe}));if(p!==void 0&&!m)return(0,z.jsx)(Fg,{children:gg(J(`noDrop`),p)});let O=e=>c.find(t=>J6(t.value)===e),k=e=>e.record[n.by]??null,A=(e,t)=>h(k(e))&&h(t.value),j=(e,t)=>{if(!t)return{over:J(`noColumn`)};let n=v?p8(t,e):void 0;if(!n)return{over:O(t.id)?.label??J(`noColumn`)};let r=n.rows.some(t=>t.key===e.key)?n.rows.length:n.rows.length+1;return{over:J(`placeOf`,n.column.label,n.index+1,r),place:J(`place`,n.column.label,n.index+1)}},M=(e,t)=>{let n=(v?p8(t,e)?.column:void 0)??O(t.id);return n!==void 0&&n.value!==k(e)&&!A(e,n)};return(0,z.jsxs)(Cy,{sensors:D,collisionDetection:X6,onDragStart:({active:e})=>{E.current=!0,T(e.data.current.row)},onDragEnd:({active:e,over:t})=>{T(void 0),setTimeout(()=>E.current=!1);let n=e.data.current.row;if(!t)return;let r=v?p8(t,n):void 0;if(!r){let e=O(t.id);e&&e.value!==k(n)&&A(n,e)&&C(n,e);return}let i=r.rows.findIndex(e=>e.key===n.key);if(i!==-1||A(n,r.column)){if(i===-1&&m)return C(n,r.column);i!==r.index&&C(n,r.column,{rows:r.rows,index:r.index})}},onDragCancel:()=>{T(void 0),setTimeout(()=>E.current=!1)},accessibility:{announcements:{onDragStart:({active:e})=>J(`pickedUp`,x(e.data.current.row)),onDragOver:({active:e,over:t})=>J(`isOver`,x(e.data.current.row),j(e.data.current.row,t).over),onDragEnd:({active:e,over:t})=>{let n=e.data.current.row;if(!t||M(n,t))return J(`putBack`,x(n));let r=j(n,t);return J(`wasMovedTo`,x(n),r.place??r.over)},onDragCancel:({active:e})=>J(`cancelled`,x(e.data.current.row))},screenReaderInstructions:{draggable:J(v?g?`boardAnywhere`:`boardWithin`:`boardAcross`)}},children:[(0,z.jsx)(`div`,{className:`relative min-w-0 flex-1 overflow-x-auto`,children:(0,z.jsx)(`div`,{className:`flex snap-x items-start gap-3 pb-2`,children:c.map(a=>(0,z.jsx)(ixe,{model:e,view:t,display:n,column:a,fields:r,filter:i,orderBy:y,limit:o,moves:S,movable:h(a.value),placeable:v,dragged:()=>E.current},J6(a.value)))})}),(0,z.jsx)(Ry,{children:w&&(0,z.jsx)(N6,{model:e,view:t,display:l,row:w,swipe:!1})})]})},h8=864e5,g8=e=>new Date(e).toISOString().slice(0,10),_8=e=>Date.parse(`${e}T00:00:00Z`),v8=(e,t)=>g8(_8(e)+t*h8),y8=e=>v8(e,-((new Date(_8(e)).getUTCDay()+6)%7)),b8=(e,t=0)=>{let n=new Date(_8(e));return g8(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1))},x8=({scale:e,day:t})=>({scale:e,day:e===`month`?b8(t):y8(t)}),S8=(e,t,n=If())=>x8(e??{scale:`month`,day:Hf(t,n)}),C8=(e,t,n=If())=>x8({scale:e,day:Hf(t,n)}),w8=(e,t)=>e.scale===`month`?{scale:`month`,day:b8(e.day,t)}:{scale:`week`,day:v8(y8(e.day),7*t)},T8=e=>{let t=y8(e.scale===`month`?b8(e.day):e.day),n=(_8(e.scale===`month`?v8(y8(v8(b8(e.day,1),-1)),6):v8(t,6))-_8(t))/h8+1;return Array.from({length:n},(e,n)=>v8(t,n))},pxe=e=>{let t=T8(e);return{from:t[0],to:v8(t.at(-1),1)}},E8=(e,t)=>t.fields[e.start]?.type===`timestamp`,mxe=(e,t,n,r=If())=>{let i=E8(e,t),a=e=>new Date(Wf(e,r)).toISOString().replace(`.000Z`,`Z`),o=e=>i?{kind:`timestamp`,value:a(e),span:{start:0,end:0}}:{kind:`string`,value:e,span:{start:0,end:0}},s=Hn.and(Hn.gte(e.start,o(n.from)),Hn.lt(e.start,o(n.to)));if(e.end===void 0)return Fn(s);let c=i?Hn.gt(e.end,o(n.from)):Hn.gte(e.end,o(n.from));return Fn(Hn.or(s,Hn.and(Hn.lt(e.start,o(n.from)),c)))},hxe=(e,t)=>e===``?t:`(${e}) AND (${t})`,D8=e=>{if(typeof e!=`string`)return;let t=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:e);return Number.isNaN(t)?void 0:t},O8=(e,t,n,r=If())=>{let i=D8(e[t.start]);if(i===void 0)return;let a=E8(t,n),o=e=>a?Hf(e,r):g8(e),s=o(i),c=t.end===void 0?void 0:D8(e[t.end]),l=c===void 0?s:o(a?c-1:c);return{first:s,last:l<s?s:l}},gxe=(e,t,n,r,i=If())=>{let a=O8(e,t,n,i);return a?r.filter(e=>e>=a.first&&e<=a.last):[]},k8=(e,t)=>e.toSorted((e,n)=>(D8(e.record[t.start])??0)-(D8(n.record[t.start])??0)),_xe=(e,t,n,r,i=If())=>{let a=new Map(r.map(e=>[e,[]]));for(let o of k8(e,t))for(let e of gxe(o.record,t,n,r,i))a.get(e).push(o);return a},vxe=(e,t,n,r,i,a=If())=>{let o=(_8(i)-_8(r))/h8,s=E8(t,n),c=e=>{let t=D8(e);if(t!==void 0)return s?new Date(Uf(t+Bf(t,a)+o*h8,a)).toISOString():v8(g8(t),o)},l=c(e[t.start]),u=t.end===void 0?void 0:c(e[t.end]);return{...l!==void 0&&{[t.start]:l},...u!==void 0&&{[t.end]:u}}},A8=({heading:e,unit:t,previous:n,today:r,next:i,scales:a,scalesLabel:o,linkTo:s,onView:l})=>{let u=(e,t,n,r,i)=>s?(0,z.jsx)(jS,{to:s(e),className:t,"aria-label":n,"aria-current":i?`page`:void 0,children:r}):(0,z.jsx)(`button`,{type:`button`,className:t,"aria-label":n,"aria-pressed":i,onClick:()=>l?.(e),children:r}),d=gp({variant:`secondary`,size:`sm`});return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium`,children:e}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u(n,d,J(`previousPeriod`,t),(0,z.jsx)(Ti,{className:`size-3.5`})),u(r,d,J(`today`),J(`today`)),u(i,d,J(`nextPeriod`,t),(0,z.jsx)(Di,{className:`size-3.5`}))]}),(0,z.jsx)(`span`,{role:`group`,"aria-label":o,className:c.group(),children:a.map(e=>(0,z.jsx)(L.Fragment,{children:u(e.view,c.option(e.current),e.label,e.label,e.current)},e.label))})]})]})},yxe=e=>{let t=T8(e),n=e=>Date.parse(`${e}T00:00:00Z`);return e.scale===`month`?rp(n(e.day)):cp(n(t[0]),n(t.at(-1)))},bxe=({view:e,now:t,linkTo:n,onView:r})=>{let i=e.scale===`month`&&Hf(t,If()).startsWith(e.day.slice(0,7)),a=n=>n===`week`&&i?C8(`week`,t):S8({scale:n,day:e.day},t),o=(t,n)=>({view:a(t),label:n,current:e.scale===t});return(0,z.jsx)(A8,{heading:yxe(e),unit:e.scale===`month`?`month`:`week`,previous:w8(e,-1),today:C8(e.scale,t),next:w8(e,1),scales:[o(`month`,J(`month`)),o(`week`,J(`week`))],scalesLabel:J(`calendarScale`),linkTo:n,onView:r})},xxe=`day:`,j8=e=>`${xxe}${e}`,Sxe=(e,t)=>`${e}@${t}`,Cxe=(e,{context:{active:t,collisionRect:n,droppableRects:r,over:i}})=>{let a={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[e.code],o=i?String(i.id).slice(4):t?.data.current?.day;if(a===void 0||!n||o===void 0)return;e.preventDefault();let s=r.get(j8(v8(o,a)));if(s)return{x:s.left+(s.width-n.width)/2,y:s.top+4}},wxe=({day:e,count:t,children:n,more:r,inMonth:i,today:a,week:o})=>{let{setNodeRef:s,isOver:c}=Dy({id:j8(e)}),l=Date.parse(`${e}T00:00:00Z`);return(0,z.jsxs)(`section`,{ref:s,"aria-label":`${sp(l)}, ${t}`,className:g(`flex min-w-0 flex-col gap-1 bg-background p-1`,o?`min-h-28 sm:min-h-64`:`min-h-24`,!i&&`bg-surface`,c&&`ring-2 ring-inset ring-primary/30`),children:[(0,z.jsxs)(`header`,{className:g(`flex items-center gap-1 px-0.5 text-xs`,i?`text-foreground`:`text-muted-foreground`),children:[o&&(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:op(l)}),(0,z.jsx)(`span`,{"aria-current":a?`date`:void 0,className:g(`inline-flex size-5 items-center justify-center rounded-full tabular-nums`,a&&`bg-primary font-medium text-primary-foreground`),children:Number(e.slice(8))})]}),n,r]})},M8=(e,t,n,r)=>{let i=n.title??Hx(e,t),a=e.fields[i],o=r.labels[i]??(a?rS(a,r.record[i],t?.fields[i]):``);return o===``?r.key:o},Txe=(e,t,n,r)=>{let i=n.record[t.start];if(e.fields[t.start]?.type!==`timestamp`||typeof i!=`string`)return;let a=Date.parse(i);return Hf(a,If())===r?lp(a):void 0},N8=({model:e,view:t,display:n,row:r,day:i,className:a})=>{let o=h6(e),s=Txe(e,n,r,i);return(0,z.jsxs)(jS,{to:{kind:`record`,resource:e.name,key:r.key},onClick:()=>o(r.record),className:g(`flex min-w-0 items-baseline gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-xs hover:border-border-strong hover:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,a),children:[s&&(0,z.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:s}),(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:M8(e,t,n,r)})]})},P8=({movable:e,dragged:t,...n})=>{let{setNodeRef:r,setActivatorNodeRef:i,listeners:a,isDragging:o}=Ty({id:Sxe(n.row.key,n.day),data:{row:n.row,day:n.day},disabled:!e});return(0,z.jsx)(`div`,{ref:e=>{r(e),i(e?.querySelector(`a`)??e)},...a,onDragStart:e=>e.preventDefault(),onClickCapture:e=>{t()&&(e.preventDefault(),e.stopPropagation())},className:g(`min-w-0`,e&&`cursor-grab touch-manipulation`,o&&`opacity-40`),children:(0,z.jsx)(N8,{...n})})},F8=({model:e,display:t,range:n,fields:r,filter:i})=>{let{resources:a,views:o}=G(),s=S3({resources:a,views:o,model:e,columns:r,filter:hxe(i,mxe(t,e,n)),orderBy:`${t.start} asc`}),c=Q6(e,s.page,s.key,!0),l=c.more&&!c.loading&&c.rows.length<500;(0,L.useEffect)(()=>{l&&c.loadMore()},[l,c.rows.length]);let u=c.rows.length>500||c.rows.length===500&&c.more;return{rows:c.rows.slice(0,500),capped:u,loading:c.loading,error:c.error}},I8=(e,t)=>{let n=new Map(t.map(e=>[e.key,e.patch]));return e.map(e=>n.has(e.key)?{...e,record:{...e.record,...n.get(e.key)}}:e)},L8=(e,t)=>{let n=W(),r=Hb(),i=RT(),[a,o]=(0,L.useState)([]),s=e=>o(t=>t.filter(t=>t.key!==e)),c=qh({mutationFn:({row:t,patch:r})=>{let i=typeof t.record.etag==`string`?t.record.etag:`*`;return n.update(e.name,Kx(e,t.record),r,i)},onMutate:({row:e,patch:t})=>o(n=>[...n.filter(t=>t.key!==e.key),{key:e.key,patch:t}]),onError:(e,{row:t,to:n})=>{s(t.key),r.show({state:`error`,title:J(`couldNotMoveTo`,$f(Date.parse(`${n}T00:00:00Z`))),description:dS(e)})},onSettled:async(t,n,{row:r})=>{await i(e.name),s(r.key)}});return{moves:a,move:(n,r,i)=>c.mutate({row:n,patch:vxe(n.record,t,e,r,i),to:i})}},Exe=3,R8=({model:e,view:t,display:n,fields:r,filter:i,at:a,linkTo:o,now:s=Date.now()})=>{let[c,l]=(0,L.useState)(),u=S8(o?a:c,s),d=T8(u),f=F8({model:e,display:n,range:pxe(u),fields:r,filter:i}),{moves:p,move:m}=L8(e,n),h=_xe(I8(f.rows,p),n,e,d),_=xT(cg(e.name),`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[v,y]=(0,L.useState)(),b=(0,L.useRef)(!1),x=ev($_($v,{activationConstraint:{distance:4}}),$_(ty,{activationConstraint:{delay:250,tolerance:5}}),$_(Gv,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:Cxe})),S=Hf(s,If()),C=u.scale===`week`,w=e=>$f(Date.parse(`${String(e).slice(j8(``).length)}T00:00:00Z`)),T=r=>M8(e,t,n,r.row),E={onDragStart:({active:e})=>J(`pickedUp`,T(e.data.current)),onDragOver:({active:e,over:t})=>J(`isOver`,T(e.data.current),t?w(t.id):J(`noDay`)),onDragEnd:({active:e,over:t})=>t?J(`wasMovedTo`,T(e.data.current),w(t.id)):J(`putBack`,T(e.data.current)),onDragCancel:({active:e})=>J(`cancelled`,T(e.data.current))},D=()=>{y(void 0),setTimeout(()=>b.current=!1)},O=({active:e})=>{b.current=!0,y(e.data.current)},k=({active:e,over:t})=>{D();let{row:n,day:r}=e.data.current,i=t?String(t.id).slice(j8(``).length):void 0;i&&i!==r&&m(n,r,i)},A=(e,t)=>{let n=S8({scale:`week`,day:e},s),r=J(`moreHidden`,t),i=`self-start rounded px-1 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-primary`;return o?(0,z.jsx)(jS,{to:o(n),className:i,children:r}):(0,z.jsx)(`button`,{type:`button`,className:i,onClick:()=>l(n),children:r})};return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,z.jsx)(bxe,{view:u,now:s,linkTo:o,onView:l}),f.error&&(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:f.error}),f.capped&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:J(`capped`,500,u.scale)}),(0,z.jsxs)(Cy,{sensors:x,collisionDetection:X6,onDragStart:O,onDragEnd:k,onDragCancel:D,accessibility:{announcements:E,screenReaderInstructions:{draggable:J(`calendarInstructions`)}},children:[(0,z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[!C&&(0,z.jsx)(`div`,{"aria-hidden":!0,className:`grid grid-cols-7 gap-px border-b border-border bg-border`,children:d.slice(0,7).map(e=>(0,z.jsx)(`span`,{className:`bg-surface px-1.5 py-1 text-xs font-medium text-muted-foreground`,children:op(Date.parse(`${e}T00:00:00Z`))},e))}),(0,z.jsx)(`div`,{className:g(`grid gap-px bg-border`,C?`grid-cols-1 sm:grid-cols-7`:`grid-cols-7`),children:d.map(r=>{let i=h.get(r),a=C?i:i.slice(0,Exe);return(0,z.jsx)(wxe,{day:r,count:i.length,inMonth:C||r.startsWith(u.day.slice(0,7)),today:r===S,week:C,more:a.length<i.length&&A(r,i.length-a.length),children:f.loading?(0,z.jsx)(Yu,{className:`h-4`}):a.map(i=>(0,z.jsx)(P8,{model:e,view:t,display:n,row:i,day:r,movable:_&&ST(i.record,`update`),dragged:()=>b.current},i.key))},r)})})]}),(0,z.jsx)(Ry,{children:v&&(0,z.jsx)(N8,{model:e,view:t,display:n,row:v.row,day:v.day})})]})]})},Dxe=864e5,z8=e=>Date.parse(`${e}T00:00:00Z`),B8=(e,t=0)=>{let n=new Date(z8(e));return new Date(Date.UTC(n.getUTCFullYear(),Math.floor(n.getUTCMonth()/3)*3+3*t,1)).toISOString().slice(0,10)},V8=({scale:e,day:t})=>({scale:e,day:e===`week`?y8(t):e===`month`?b8(t):B8(t)}),H8=(e,t,n=If())=>V8(e??{scale:`month`,day:Hf(t,n)}),U8=(e,t)=>{let{scale:n,day:r}=V8(e);return{scale:n,day:n===`week`?v8(r,7*t):n===`month`?b8(r,t):B8(r,t)}},W8=e=>{let t=V8(e).day,n=(z8(U8(e,1).day)-z8(t))/Dxe;return Array.from({length:n},(e,n)=>v8(t,n))},Oxe=e=>({from:V8(e).day,to:U8(e,1).day}),kxe=(e,t,n,r=If())=>{let i=Hf(n,r),a=W8(e);return V8({scale:t,day:i>=a[0]&&i<=a.at(-1)?i:a[0]})},Axe=e=>{let t=W8(e);return e.scale===`week`?cp(z8(t[0]),z8(t.at(-1))):e.scale===`month`?rp(z8(t[0])):ap(z8(t[0]),z8(b8(t.at(-1))))},jxe=e=>{let t=W8(e);if(e.scale===`week`)return t.map((e,t)=>({index:t,span:1,label:`${op(z8(e))} ${Number(e.slice(8))}`}));if(e.scale===`month`)return t.map((e,t)=>({index:t,span:1,label:String(Number(e.slice(8))),...t%7!=0&&{minor:!0}}));let n=t.flatMap((e,t)=>e.endsWith(`-01`)?[t]:[]);return n.map((e,r)=>({index:e,span:(n[r+1]??t.length)-e,label:ip(z8(t[e]))}))},Mxe=(e,t,n,r,i=If())=>{let a=O8(e,t,n,i),o=r[0],s=r.at(-1);if(!(!a||o===void 0||s===void 0||a.last<o||a.first>s))return{first:a.first<o?0:r.indexOf(a.first),last:a.last>s?r.length-1:r.indexOf(a.last),before:a.first<o,after:a.last>s,start:a.first}},Nxe=`none`,Pxe=(e,t,n,r)=>{let i=r.group,a=i===void 0?void 0:t.fields[i];if(i===void 0||!a)return[{key:``,rows:e}];let o=n?.fields[i],s=new Map;for(let t of e){let e=t.record[i],n=e==null||e===``,r=n?Nxe:`value:${String(e)}`,c=n?J(`noValue`,o?.label??q(i)):t.labels[i]??rS(a,e,o),l=s.get(r)??{value:n?void 0:e,lane:{key:r,label:c,rows:[]}};l.lane.rows.push(t),s.set(r,l)}let c=a.enumValues??[],l=(e,t)=>e.value===void 0||t.value===void 0?Number(e.value===void 0)-Number(t.value===void 0):a.type===`enum`?c.indexOf(String(e.value))-c.indexOf(String(t.value)):a.type===`relation`?e.lane.label.localeCompare(t.lane.label):typeof e.value==`number`&&typeof t.value==`number`?e.value-t.value:String(e.value).localeCompare(String(t.value),void 0,{numeric:!0});return[...s.values()].toSorted(l).map(({lane:e})=>e)},G8=`grid grid-cols-1 sm:grid-cols-[12rem_minmax(0,1fr)]`,K8=(e,t)=>`${e/t*100}%`,Fxe=({ticks:e,days:t,today:n,label:r,trackRef:i})=>(0,z.jsxs)(`div`,{className:g(G8,`border-b border-border bg-surface`),children:[(0,z.jsx)(`span`,{className:`hidden truncate px-2 py-1 text-xs font-medium text-muted-foreground sm:block`,children:r}),(0,z.jsx)(`div`,{ref:i,"aria-hidden":!0,className:`relative h-6`,children:e.map(e=>(0,z.jsx)(`span`,{className:g(`absolute inset-y-0 items-center truncate px-1 text-xs tabular-nums text-muted-foreground`,e.index>0?`border-l border-border`:`border-border sm:border-l`,e.minor?`hidden sm:flex`:`flex`,e.span===1&&t[e.index]===n&&`font-medium text-primary`),style:{left:K8(e.index,t.length),width:K8(e.span,t.length)},children:e.label},e.index))})]}),Ixe=({ticks:e,days:t,today:n})=>{let r=t.indexOf(n);return(0,z.jsxs)(`div`,{"aria-hidden":!0,className:g(G8,`pointer-events-none absolute inset-0`),children:[(0,z.jsx)(`span`,{className:`hidden sm:block`}),(0,z.jsxs)(`div`,{className:`relative`,children:[r>=0&&(0,z.jsx)(`span`,{className:`absolute inset-y-0 bg-primary/10`,style:{left:K8(r,t.length),width:K8(1,t.length)}}),e.map(e=>(0,z.jsx)(`span`,{className:g(`absolute inset-y-0 w-px bg-border`,(e.minor||e.index===0)&&`hidden sm:block`),style:{left:K8(e.index,t.length)}},e.index))]})]})},Lxe=({model:e,view:t,display:n,row:r,days:i,movable:a,dragged:o})=>{let s=Mxe(r.record,n,e,i);return(0,z.jsxs)(`div`,{className:g(G8,`relative border-b border-border last:border-b-0`),children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`truncate px-2 pt-1 text-body sm:py-1.5`,children:M8(e,t,n,r)}),(0,z.jsx)(`div`,{className:`relative h-7`,children:s&&(0,z.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2`,style:{left:K8(s.first,i.length),width:K8(s.last-s.first+1,i.length)},children:(0,z.jsx)(P8,{model:e,view:t,display:n,row:r,day:s.start,movable:a,dragged:o,className:g(s.before&&`rounded-l-none border-l-0`,s.after&&`rounded-r-none border-r-0`)})})})]})},Rxe=()=>[{scale:`week`,label:J(`week`)},{scale:`month`,label:J(`month`)},{scale:`quarter`,label:J(`quarter`)}],q8=({model:e,view:t,display:n,fields:r,filter:i,at:a,linkTo:o,now:s=Date.now()})=>{let[c,l]=(0,L.useState)(),u=H8(o?a:c,s),d=W8(u),f=jxe(u),p=F8({model:e,display:n,range:Oxe(u),fields:r,filter:i}),{moves:m,move:h}=L8(e,n),g=Pxe(k8(I8(p.rows,m),n),e,t,n),_=xT(cg(e.name),`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[v,y]=(0,L.useState)(),b=(0,L.useRef)(!1),x=(0,L.useRef)(0),S=(0,L.useRef)(null),C=()=>(S.current?.getBoundingClientRect().width??0)/d.length,w=e=>{let t=C();return t>0?Math.round(e/t):0},T=({transform:e})=>({...e,x:w(e.x)*C(),y:0}),E=ev($_($v,{activationConstraint:{distance:4}}),$_(ty,{activationConstraint:{delay:250,tolerance:5}}),$_(Gv,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:(e,{currentCoordinates:t})=>{let n=e.code===`ArrowLeft`?-1:+(e.code===`ArrowRight`);if(n!==0)return e.preventDefault(),{x:t.x+n*C(),y:t.y}}})),D=Hf(s,If()),O=r=>M8(e,t,n,r.row),k=e=>$f(Date.parse(`${v8(e.day,x.current)}T00:00:00Z`)),A={onDragStart:({active:e})=>J(`pickedUp`,O(e.data.current)),onDragMove:({active:e})=>J(`startsOn`,O(e.data.current),k(e.data.current)),onDragOver:()=>void 0,onDragEnd:({active:e})=>x.current===0?J(`putBack`,O(e.data.current)):J(`wasMovedTo`,O(e.data.current),k(e.data.current)),onDragCancel:({active:e})=>J(`cancelled`,O(e.data.current))},j=()=>{y(void 0),setTimeout(()=>b.current=!1)},M=({active:e})=>{b.current=!0,x.current=0,y(e.data.current)},N=({delta:e})=>x.current=w(e.x),P=({active:t,delta:r})=>{j(),x.current=w(r.x);let{row:i}=t.data.current,a=O8(i.record,n,e);a&&x.current!==0&&h(i,a.first,v8(a.first,x.current))},ee=n.group===void 0?t?.names?.plural??q(e.name):t?.fields[n.group]?.label??q(n.group),te=!p.loading&&!p.error&&p.rows.length===0;return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,z.jsx)(A8,{heading:Axe(u),unit:u.scale,previous:U8(u,-1),today:H8({scale:u.scale,day:D},s),next:U8(u,1),scales:Rxe().map(({scale:e,label:t})=>({view:kxe(u,e,s),label:t,current:u.scale===e})),scalesLabel:J(`timelineScale`),linkTo:o,onView:l}),p.error&&(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:p.error}),p.capped&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:J(`capped`,500,u.scale)}),(0,z.jsxs)(Cy,{sensors:E,modifiers:[T],onDragStart:M,onDragMove:N,onDragEnd:P,onDragCancel:j,accessibility:{announcements:A,screenReaderInstructions:{draggable:J(`timelineInstructions`)}},children:[(0,z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[(0,z.jsx)(Fxe,{ticks:f,days:d,today:D,label:ee,trackRef:S}),(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(Ixe,{ticks:f,days:d,today:D}),p.loading&&(0,z.jsxs)(`div`,{className:`relative flex flex-col gap-2 p-2`,children:[(0,z.jsx)(Yu,{className:`h-4`}),(0,z.jsx)(Yu,{className:`h-4`})]}),te&&(0,z.jsx)(`p`,{className:`relative px-2 py-3 text-xs text-muted-foreground`,children:J(`nothingIn`,u.scale)}),!p.loading&&g.map(r=>(0,z.jsxs)(`section`,{"aria-label":r.label,className:`relative border-b border-border last:border-b-0`,children:[r.label!==void 0&&(0,z.jsxs)(`h3`,{className:`flex items-center gap-1.5 border-b border-border bg-surface px-2 py-1 text-xs font-medium`,children:[r.label,(0,z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:r.rows.length})]}),r.rows.map(r=>(0,z.jsx)(Lxe,{model:e,view:t,display:n,row:r,days:d,movable:_&&ST(r.record,`update`),dragged:()=>b.current},r.key))]},r.key))]})]}),(0,z.jsx)(Ry,{children:v&&(0,z.jsx)(N8,{model:e,view:t,display:n,row:v.row,day:v.day})})]})]})},zxe=({list:e,empty:t,loading:n,children:r})=>(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.loading?n:e.error?(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:e.error}):e.rows.length===0?(0,z.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:t}):r}),Bxe=({list:e})=>(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[e.rows.length.toLocaleString(l()),` of `,e.total.toLocaleString(l())]}),e.more&&(0,z.jsx)(V,{size:`sm`,onClick:e.loadMore,children:J(`showMore`)})]}),J8=`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,Vxe=`relative flex snap-x snap-mandatory gap-3 overflow-x-auto pb-1`,Hxe=({model:e,view:t,display:n,list:r,row:i=!1,footer:a=!0})=>{let o=(t?.names?.plural??q(e.name)).toLowerCase();return(0,z.jsxs)(zxe,{list:r,empty:J(`noneMatch`,o),loading:(0,z.jsx)(`div`,{className:J8,children:Array.from({length:6},(e,t)=>(0,z.jsx)(Yu,{className:`h-24`},t))}),children:[(0,z.jsx)(`ul`,{className:i?Vxe:J8,"aria-label":t?.names?.plural??q(e.name),children:r.rows.map(r=>(0,z.jsx)(`li`,{className:g(i&&`w-64 shrink-0 snap-start`),children:(0,z.jsx)(N6,{model:e,view:t,display:n,row:r,swipe:!i})},r.key))}),a&&(0,z.jsx)(Bxe,{list:r})]})},Y8=(0,L.createContext)(void 0),Uxe=({value:e,children:t})=>(0,z.jsx)(Y8.Provider,{value:e,children:t}),Wxe=()=>{let e=(0,L.useContext)(Y8);if(!e)throw Error(`useListDisplay is used inside a list display, which the list page draws`);return e},Gxe=()=>(0,L.useContext)(Y8),X8=({display:e,list:t})=>{let{components:n}=hC(),r=n?.[e.component];return r?(0,z.jsx)(Uxe,{value:t,children:(0,z.jsx)(`div`,{className:`relative min-w-0 flex-1 overflow-x-auto`,children:(0,z.jsx)(Lg,{name:e.component,children:(0,z.jsx)(r,{...Jn(e.props??{})})})})}):(0,z.jsx)(Fg,{children:gg(J(`noComponent`),e.component)})},Z8=Vn(),Kxe={bounds:{south:-90,west:-180,north:90,east:180},zoom:0},qxe=22,Q8=e=>Math.floor(e*1e6)/1e6,$8=e=>Math.ceil(e*1e6)/1e6,e5=e=>((e+180)%360+360)%360-180,Jxe=(e,t)=>{let n=[Z8.gte(e.latitude,Q8(Math.max(t.south,-90))),Z8.lte(e.latitude,$8(Math.min(t.north,90)))];if(t.east-t.west>=360)return Z8.and(...n);let r=Z8.gte(e.longitude,Q8(e5(t.west))),i=Z8.lte(e.longitude,$8(e5(t.east)));return e5(t.west)<=e5(t.east)?Z8.and(...n,r,i):Z8.and(...n,Z8.or(r,i))},Yxe=(e,t,n)=>{let r=Fn(Jxe(t,n));return e.trim()===``?r:`(${e}) AND ${r}`},Xxe=e=>Math.min(Math.max(Math.floor(e),0),qxe),Zxe=(e,t)=>{let n=[...e.map(e=>({south:e.latitude,west:e.longitude,north:e.latitude,east:e.longitude})),...t.map(e=>e.bounds)];if(n.length!==0)return{south:Math.min(...n.map(e=>e.south)),west:Math.min(...n.map(e=>e.west)),north:Math.max(...n.map(e=>e.north)),east:Math.max(...n.map(e=>e.east))}},t5=e=>{if(typeof e==`number`)return e;if(typeof e==`string`&&e.trim()!==``)return Number(e)},n5=(e,t)=>{let n=t5(e[t.latitude]),r=t5(e[t.longitude]);if(n!==void 0&&r!==void 0&&Math.abs(n)<=90&&Math.abs(r)<=180)return{latitude:n,longitude:r}},Qxe=6371008.8,r5=64,i5=(e,t)=>t.approximate===void 0?t.exact!==void 0&&e[t.exact]===!1:e[t.approximate]===!0,a5=(e,t)=>{let n=t/Qxe,r=e.latitude*Math.PI/180,i=e.longitude*Math.PI/180;return{type:`Polygon`,coordinates:[Array.from({length:65},(e,t)=>{let a=t%r5/r5*2*Math.PI,o=Math.asin(Math.sin(r)*Math.cos(n)+Math.cos(r)*Math.sin(n)*Math.cos(a));return[(i+Math.atan2(Math.sin(a)*Math.sin(n)*Math.cos(r),Math.cos(n)-Math.sin(r)*Math.sin(o)))*180/Math.PI,o*180/Math.PI]})]}},$xe=e=>Array.isArray(e)&&e.length>=2&&typeof e[0]==`number`&&typeof e[1]==`number`&&Math.abs(e[0])<=180&&Math.abs(e[1])<=90,o5=(e,t)=>Array.isArray(e)&&e.length>=t&&e.every($xe),s5=e=>Array.isArray(e)&&e.length>0&&e.every(e=>o5(e,4)),eSe=e=>Array.isArray(e)&&e.length>0&&e.every(e=>o5(e,2)),tSe=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch(e){if(e instanceof SyntaxError)return;throw e}},nSe=e=>{let t=tSe(e);if(typeof t!=`object`||!t)return;let n=t.type===`Feature`?t.geometry:t;if(typeof n!=`object`||!n)return;let{type:r,coordinates:i}=n;if(r===`Polygon`&&s5(i)||r===`MultiPolygon`&&Array.isArray(i)&&i.length>0&&i.every(s5)||r===`LineString`&&o5(i,2)||r===`MultiLineString`&&eSe(i))return{type:r,coordinates:i}},rSe=(e,t,n)=>{if(!i5(e,t))return;let r=t.area===void 0?void 0:nSe(e[t.area]);if(r)return r;let i=t.radius===void 0?void 0:t5(e[t.radius]);return i!==void 0&&Number.isFinite(i)&&i>0?a5(n,i):t.defaultRadius===void 0?void 0:a5(n,t.defaultRadius)},c5=(e,t)=>e.flatMap(e=>{let n=n5(e.record,t);if(!n)return[];if(!i5(e.record,t))return[{key:e.key,...n}];let r=rSe(e.record,t,n);return[{key:e.key,...n,approximate:!0,...r&&{area:r}}]}),iSe=(e,t)=>{let n=[];for(let r of e){let e=n.find(e=>Math.hypot(e.at.x-r.x,e.at.y-r.y)<=t);e?e.keys.push(r.key):n.push({at:r,keys:[r.key]})}return n.map(e=>({keys:e.keys,at:e.at.key}))},aSe=(e,t)=>{if(!e)return;let n=new Set(t.map(e=>e.key)),r=e.keys.filter(e=>n.has(e));if(r.length===0)return;let i=r.indexOf(e.keys[e.index]);return{keys:r,index:Math.max(i,0)}},l5=(e,t)=>({keys:e.keys,index:((e.index+t)%e.keys.length+e.keys.length)%e.keys.length}),oSe=({model:e,view:t,display:n,fields:r,filter:i,orderBy:a,area:o})=>{let s=W(),{resources:c,views:l}=G(),u={latitude:n.latitude,longitude:n.longitude},d=o?Yxe(i,u,o.bounds):``,f=o?Xxe(o.zoom):0;return Kh({queryKey:U.map(e.name,`${u.latitude},${u.longitude}`,f,d,a),enabled:o!==void 0,placeholderData:lh,queryFn:async()=>{let n=await s.map(e.name,{...u,zoom:f,filter:d,orderBy:a,labels:Y0(c,l,e,r),photos:oS(t)});return{rows:X0(c,e,r,sS(e,n.items,n.photos),n.labels).map(t=>CS(e,t)),buckets:n.buckets,total:n.totalSize}}})},sSe=(0,L.lazy)(()=>m(()=>import(`./records-map-85gFdOGo.js`).then(e=>({default:e.RecordsMap})),__vite__mapDeps([5,1,2,6,7,8,3,4,9]))),cSe=250,u5=`flex size-8 items-center justify-center rounded-full border border-border bg-background hover:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,d5=({model:e,view:t,display:n,filter:r,orderBy:i,fields:a,at:o,onMove:s,footer:c=!0,flush:u=!1})=>{let d=G().maps,f=d?.style,[p,m]=(0,L.useState)(),[h,_]=(0,L.useState)(),v=V3(h,cSe),[y,b]=(0,L.useState)(o===void 0),x=oSe({model:e,view:t,display:n,fields:a,filter:r,orderBy:i,area:y?Kxe:v}),S=x.isPlaceholderData?void 0:x.data,C=x.data?.rows??[],w=x.data?.buckets??[],T=c5(C,n),E=y&&S?Zxe(c5(S.rows,n),S.buckets):void 0,D=bS(t,n),O=(t?.names?.plural??q(e.name)).toLowerCase(),k=(t?.names?.singular??q(e.name)).toLowerCase(),A=aSe(p,C),j=A&&C.find(e=>e.key===A.keys[A.index]),M=new Set(T.filter(e=>e.approximate).map(e=>e.key)),N=e=>{let t=e.filter(e=>M.has(e)).length;return e.length===1?J(t===1?`showOneApproximate`:`showOne`,k):t===0?J(`showMany`,e.length,O):t===e.length?J(`showManyApproximate`,e.length,O):J(`showManySomeApproximate`,e.length,O,t)},P=e=>J(`zoomIn`,e.toLocaleString(l()),e===1?k:O),ee=(0,L.useRef)(null),[te,ne]=(0,L.useState)(0);if((0,L.useLayoutEffect)(()=>ne(ee.current?.offsetHeight??0),[j?.key]),!f)return(0,z.jsx)(Fg,{children:J(`needsStyle`)});let re=S?.total===0;return(0,z.jsxs)(`div`,{className:g(`flex h-full min-h-[36rem] flex-1 flex-col sm:min-h-[28rem]`,u&&`max-md:-mx-5 max-md:-mb-4 max-md:min-h-0`),children:[(0,z.jsxs)(`div`,{className:g(`relative min-h-0 flex-1 overflow-hidden rounded-lg border border-border bg-muted`,u&&`max-md:rounded-none max-md:border-0`),children:[(0,z.jsx)(L.Suspense,{fallback:null,children:(0,z.jsx)(sSe,{style:f,layers:d?.layers,initial:o,points:T,buckets:w,fit:E,onFitted:()=>b(!1),onMove:(e,t)=>{_(e),s?.(t)},selected:A?.keys,covered:A?te:0,onSelect:e=>m({keys:e,index:0}),onClear:()=>m(void 0),markerLabel:N,bucketLabel:P})}),x.error&&(0,z.jsx)(`div`,{className:`absolute inset-x-3 top-3 z-10`,children:(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:x.error})}),re&&(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-10 flex justify-center`,children:(0,z.jsxs)(`p`,{className:`pointer-events-auto flex items-center gap-3 rounded-full border border-border bg-background px-4 py-1.5 text-muted-foreground shadow`,role:`status`,children:[J(y?`noneMatch`:`noneHere`,O),!y&&(0,z.jsx)(V,{size:`sm`,onClick:()=>b(!0),children:J(`showAll`)})]})}),A&&j&&(0,z.jsx)(`div`,{ref:ee,className:`pointer-events-none absolute inset-x-3 bottom-3 z-10 flex justify-center`,children:(0,z.jsxs)(`div`,{className:`pointer-events-auto flex w-full max-w-[16rem] flex-col gap-2 sm:max-w-xs`,role:`group`,"aria-label":J(`chosen`,k),children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[M.has(j.key)&&(0,z.jsxs)(`span`,{className:`mr-auto flex items-center gap-1 rounded-full border border-border bg-background px-2 py-1 text-xs`,children:[(0,z.jsx)(Uee,{className:`size-3.5`,"aria-hidden":!0}),J(`approximatePosition`)]}),A.keys.length>1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":J(`previous`),className:u5,onClick:()=>m(l5(A,-1)),children:(0,z.jsx)(Ti,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{className:`rounded-full border border-border bg-background px-2 py-1 text-xs tabular-nums`,"aria-live":`polite`,children:[A.index+1,` / `,A.keys.length]}),(0,z.jsx)(`button`,{type:`button`,"aria-label":J(`next`),className:u5,onClick:()=>m(l5(A,1)),children:(0,z.jsx)(Di,{className:`size-4`,"aria-hidden":!0})})]}),(0,z.jsx)(`button`,{type:`button`,"aria-label":J(`close`),className:u5,onClick:()=>m(void 0),children:(0,z.jsx)(ss,{className:`size-4`,"aria-hidden":!0})})]}),(0,z.jsx)(`div`,{className:`shadow-lg`,children:(0,z.jsx)(N6,{model:e,view:t,display:D,row:j})})]})})]}),c&&(0,z.jsx)(`p`,{className:`hidden py-3 text-xs text-muted-foreground md:block`,children:lSe(x.data,O)})]})},lSe=(e,t)=>{if(!e)return`\xA0`;let n=e.total.toLocaleString(l());return e.buckets.length===0&&e.rows.length<e.total?`${e.rows.length.toLocaleString(l())} of ${n} ${t} in view`:`${n} ${t} in view`},f5=({value:e,options:t,onChange:n,label:r})=>{let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null),s=(0,L.useRef)(null),c=(0,L.useRef)([]),l=t.findIndex(t=>t.value===e),u=t[l];(0,L.useEffect)(()=>{if(!i)return;c.current[Math.max(l,0)]?.focus();let e=e=>{e.target instanceof Node&&!o.current?.contains(e.target)&&a(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[i]);let d=()=>{a(!1),s.current?.focus()};return(0,z.jsxs)(`div`,{ref:o,className:`relative shrink-0`,children:[(0,z.jsxs)(`button`,{ref:s,type:`button`,"aria-label":u?`${r}: ${u.label}`:r,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>a(!i),className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border-strong bg-background px-2.5 text-body font-medium shadow-sm transition-colors hover:bg-muted pointer-coarse:h-11`,children:[u?.icon&&(0,z.jsx)(u.icon,{className:`size-3.5`}),u?.label??r,(0,z.jsx)(Ci,{className:`size-3.5 text-muted-foreground`})]}),i&&(0,z.jsx)(`ul`,{role:`menu`,"aria-label":r,onKeyDown:e=>{if(e.key===`Escape`)return d();if(e.key===`Tab`)return a(!1);let n=B3(e.key,c.current.indexOf(document.activeElement),t.length);n!==void 0&&(e.preventDefault(),c.current[n]?.focus())},className:`absolute right-0 top-full z-30 mt-1 min-w-40 rounded-md border bg-background py-1 text-body shadow-pop`,children:t.map((t,r)=>(0,z.jsx)(`li`,{role:`none`,children:(0,z.jsxs)(`button`,{ref:e=>{c.current[r]=e},type:`button`,role:`menuitemradio`,"aria-checked":t.value===e,onClick:()=>{d(),t.value!==e&&n(t.value)},className:g(`flex min-h-9 w-full items-center gap-2 whitespace-nowrap px-3 py-1.5 text-left hover:bg-muted focus:bg-muted focus:outline-none pointer-coarse:min-h-11`,t.value===e&&`font-medium`),children:[t.icon?(0,z.jsx)(t.icon,{className:`size-3.5`}):(0,z.jsx)(`span`,{className:`size-3.5`}),(0,z.jsx)(`span`,{className:`flex-1`,children:t.label}),t.value===e&&(0,z.jsx)(xi,{className:`size-3.5 text-primary-text`})]})},t.value))})]})},uSe={table:Bo,cards:_a,kanban:Fo,board:Kee,list:ate,calendar:gi,timeline:Bee,map:Pa},p5=({view:e,value:t,onChange:n,menu:r=!1,choices:i=_S(e)})=>{if(i.length<2)return null;let a=i.map(e=>({value:e.name,label:e.label,icon:e.icon===void 0?void 0:uSe[e.icon]}));return r?(0,z.jsx)(f5,{label:J(`display`),value:t,onChange:n,options:a}):(0,z.jsx)(f,{label:J(`display`),size:`md`,value:t,onChange:n,options:a})},dSe=[[`asc`,`ascending`],[`desc`,`descending`]],m5=({model:e,view:t,display:n,orderBy:r,onChange:i,className:a})=>{let o=TS(r),s=uoe(e,t,n),c=s.includes(o.columnId)?s:[o.columnId,...s],l=e=>t?.fields[e]?.label??q(e);return(0,z.jsx)(`select`,{"aria-label":J(`sort`),value:`${o.columnId} ${o.direction}`,onChange:e=>i(e.target.value),className:g(`h-8 rounded-md border border-border-strong bg-background px-2.5 shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20`,a),children:c.flatMap(e=>dSe.map(([t,n])=>(0,z.jsxs)(`option`,{value:`${e} ${t}`,children:[l(e),`, `,J(n)]},`${e} ${t}`)))})},h5=(e,t,n,r)=>e.map(e=>{let i=t.fields[e.id],a=i&&gC(r,i,n?.fields[e.id]);return a?{...e,render:t=>(0,z.jsx)(vC,{shown:a,part:`cell`,field:i,value:t[e.id],fallback:W4(e,e.value?e.value(t):t[e.id])})}:e}),g5=e=>e.includes(`.`),fSe=({model:e,row:t,column:n})=>{let r=r2(NT(e,CS(e,t).record),n);return r.state===`loading`?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`…`}):r.state===`missing`?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,z.jsx)($0,{model:r.model,field:r.field,value:r.value})},pSe=(e,t,{resources:n,views:r})=>{let i=Sc(n,e.name,t),a=i.ok?i.steps.at(-1):void 0,o=a?.field.name??t;return{id:t,header:r[a?.model.name??e.name]?.fields[o]?.label??q(o),kind:`text`,width:200,render:n=>(0,z.jsx)(fSe,{model:e,row:n,column:t})}},_5=(e,t,n,r)=>{let i=new Map(h5(tS(e,t,[],n.filter(e=>!g5(e))),e,t,r.fieldTypes).map(e=>[e.id,e]));return n.flatMap(t=>g5(t)?[pSe(e,t,r)]:i.get(t)??[])},v5=(e,t,n)=>{let r=Object.hasOwn(e.fields,t)?e.fields[t]:void 0;return r?.type===`relation`&&r.relation!==void 0&&n[r.relation.resource]?.primaryKey.length===1},mSe=(e,t,n)=>{if(e.open!==void 0)return e.open!==e.field&&v5(t,e.open,n)?e.open:void 0;let r=t.primaryKey.filter(r=>r!==e.field&&r!==t.tenant&&v5(t,r,n));return r.length===1?r[0]:void 0},y5=(e,t)=>{let n=e[t],r=typeof n==`object`&&n&&`id`in n?n.id:n;return typeof r==`string`||typeof r==`number`?r:void 0},b5=(e,t)=>(t?.names?.singular??q(e.name)).toLowerCase(),hSe=({model:e,view:t,opens:n,resources:r,views:i,canUpdate:a})=>{let o=t=>({kind:`record`,resource:e.name,key:Kx(e,t)}),s=n&&e.fields[n]?.relation?.resource,c=s?r[s]:void 0,l=e=>{let t=n&&c?y5(e,n):void 0;return c&&t!==void 0?{kind:`record`,resource:c.name,key:t}:void 0},u=e=>l(e)??o(e),d=b5(e,t);return{address:u,actions:t=>{let n={label:s2(`open`,d),link:e=>t(o(e))};if(!c)return[n];let r=e=>a&&ST(e,`update`);return[{label:s2(`open`,b5(c,i[c.name])),available:e=>l(e)!==void 0,link:e=>t(l(e))},{label:s2(`edit`,d),available:r,link:n=>t({kind:`record`,resource:e.name,key:Kx(e,n),edit:!0})},{...n,available:e=>!r(e)}]}}},gSe=({model:e,filter:t,orderBy:n,limit:r,fields:i})=>{let a=W(),{resources:o,views:s}=G();return Kh({queryKey:[...U.list(e.name,t,n,r,`embedded`),i.join(`,`)],placeholderData:lh,queryFn:async()=>{let c=Y0(o,s,e,i),l=oS(s[e.name]),u=await a.search(e.name,{filter:t||void 0,orderBy:n||void 0,pageSize:r,count:`exact`,labels:c,photos:l}),d=X0(o,e,i,sS(e,u.items,u.photos),u.labels).map((t,n)=>({...t,id:Gx(e,u.items[n])}));return u.nextPageToken===``?{rows:d,total:d.length,estimated:!1}:{rows:d,total:u.totalSize??u.totalSizeEstimate,estimated:u.totalSize===void 0}}})},x5=({view:e,value:t,onChange:n})=>(0,z.jsx)(p5,{view:e,value:t,onChange:n,menu:!Mu()}),_Se=()=>(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-4 w-full`},t))}),S5=({model:e,view:t,filter:n,sort:r,columns:i,limit:a,display:o,empty:s,row:c=!1,viewAll:l,link:u=!0,opens:d})=>{let{resources:f,views:p}=G(),m=xT(cg(e.name),`update`),{fields:h}=hC(),{go:g,href:_}=AS(),v=Nu(),[y,b]=(0,L.useState)(r||wS(e,t)),x=i??eS(e,t),S=(0,L.useMemo)(()=>_5(e,t,x,{resources:f,views:p,fieldTypes:h}),[e,t,x.join(`,`),f,p,h]),C=(0,L.useMemo)(()=>SS(e,t,S.map(e=>e.id)),[e,t,S]),w=gSe({model:e,filter:n,orderBy:y,limit:a,fields:C}),T=w.data?.rows,E=(0,L.useMemo)(()=>T&&{total:T.length,rowAt:e=>T[e]},[T]),D=gS(t,o),O=t?.names?.plural??q(e.name),k=u&&(0,z.jsxs)(jS,{to:u2(e,t,v,l?{filter:l.filter,orderBy:wS(e,t),display:o,savedSearch:l.savedSearch}:{filter:n,orderBy:y,display:o}),onClick:l?.onOpen,className:`flex items-center gap-1 self-end font-medium text-primary-text hover:underline`,children:[l?l.label:(0,z.jsxs)(z.Fragment,{children:[s2(`viewAll`),` `,(0,z.jsx)(`span`,{className:`sr-only`,children:O.toLowerCase()})]}),(0,z.jsx)(Vr,{className:`size-3.5`,"aria-hidden":!0})]});if(w.isPending)return(0,z.jsx)(_Se,{});if(w.error)return(0,z.jsx)(rC,{title:s2(`couldNotLoad`),error:w.error});if(!E||E.total===0){let e=(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:s??s2(`nothingYet`)});return l&&u?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,k]}):e}let A={resource:e.name,rows:w.data.rows.map(t=>CS(e,t)),total:w.data.total,loading:!1,error:null,more:!1,loadMore:()=>void 0},j=hSe({model:e,view:t,opens:d,resources:f,views:p,canUpdate:m}),M=e=>({href:_(e),onFollow:()=>g(e)}),N=c2(E.total,w.data.total,w.data.estimated);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[D?D.kind===`cards`?(0,z.jsx)(Hxe,{model:e,view:t,display:D,list:A,row:c||v,footer:!1}):D.kind===`map`?(0,z.jsx)(d5,{model:e,view:t,display:D,filter:n,orderBy:y,fields:C,footer:!1}):D.kind===`board`?(0,z.jsx)(m8,{model:e,view:t,display:D,fields:C,filter:n,orderBy:y,limit:a}):D.kind===`calendar`?(0,z.jsx)(R8,{model:e,view:t,display:D,fields:C,filter:n}):D.kind===`timeline`?(0,z.jsx)(q8,{model:e,view:t,display:D,fields:C,filter:n}):(0,z.jsx)(X8,{display:D,list:A}):(0,z.jsx)(_3,{fit:!0,columns:S,source:E,latencyMs:0,sort:TS(y),onSortChange:e=>b(ES(e)),onOpenRow:e=>g(j.address(e)),rowLink:e=>M(j.address(e)),rowActions:j.actions(M),rowNumbers:!1,selectable:!1}),N&&u?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:N}),k]}):k]})},C5=(e,t,n)=>{let r=Nu(),i=pge(t),[a,o]=(0,L.useState)(()=>mge(localStorage,i)),s=(0,L.useCallback)(e=>{o(e),hge(localStorage,i,e)},[i]);return[l2(e,r,{picked:a,preferred:n}),s]},vSe=({model:e,view:t,filter:n=``,sort:r=``,columns:i,limit:a=10,display:o,title:s,description:c,empty:l,actions:u})=>{let[d,f]=C5(t,`page:${e.name}:${s??``}:${n}`,o);return(0,z.jsx)(GT,{title:s,description:c,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(x5,{view:t,value:d,onChange:f}),u]}),className:`h-full`,children:(0,z.jsx)(S5,{model:e,view:t,filter:n,sort:r,columns:i,limit:a,display:d,empty:l})})},ySe=({node:e,slots:t})=>{let n=HT(e),{resources:r,views:i}=G(),a=r[n.resource];return a?(0,z.jsx)(vSe,{...n,model:a,view:i[a.name],actions:t.actions}):null},w5=a({en:{email:`Email`,invite:`Invite`,expired:`Expired`,until:e=>`Until ${e}`,sendAgain:`Send again`,revoke:`Revoke`,passLinkOn:`This app cannot send email, so pass this link on yourself. It works once, until the invitation expires: {}`},nl:{email:`E-mailadres`,invite:`Uitnodigen`,expired:`Verlopen`,until:e=>`Tot ${e}`,sendAgain:`Opnieuw sturen`,revoke:`Intrekken`,passLinkOn:`Deze app kan geen e-mail sturen, dus geef deze link zelf door. Die werkt één keer, tot de uitnodiging verloopt: {}`}}),T5=({link:e})=>e?(0,z.jsx)(`p`,{className:`mt-3 break-all rounded-md border bg-muted px-3 py-2 text-xs`,children:gg(w5(`passLinkOn`),(0,z.jsx)(`span`,{className:`font-mono`,children:e}))}):null,E5=({title:e,description:t,onInvite:n,beside:r,children:i,incomplete:a=!1})=>{let[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(),{busy:u,error:d,run:f}=Ag(),p=()=>f(async()=>{l((await n(o.trim())).link),s(``)});return(0,z.jsxs)(vp,{title:e,description:t,children:[(0,z.jsx)(yp,{message:d}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,z.jsx)(Wd,{"aria-label":w5(`email`),type:`email`,placeholder:`name@example.com`,value:o,onChange:e=>s(e.target.value),wrapperClassName:`flex-1`}),r,(0,z.jsx)(V,{type:`submit`,variant:`primary`,loading:u,disabled:!o.trim()||a,children:w5(`invite`)})]}),i]}),(0,z.jsx)(T5,{link:c})]})},D5=({email:e,gives:t,expiresAt:n,onResend:r,onRevoke:i})=>{let[a,o]=(0,L.useState)(),{busy:s,error:c,run:u}=Ag(),d=new Date(n).getTime()<Date.now();return(0,z.jsxs)(`li`,{className:`px-3 py-2.5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate font-medium`,children:e}),(0,z.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t,` · `,d?w5(`expired`):w5(`until`,new Date(n).toLocaleDateString(l()))]})]}),(0,z.jsx)(V,{size:`sm`,loading:s,onClick:()=>void u(async()=>o((await r()).link)),children:w5(`sendAgain`)}),(0,z.jsx)(V,{size:`sm`,variant:`danger`,loading:s,onClick:()=>void u(i),children:w5(`revoke`)})]}),(0,z.jsx)(yp,{message:c}),(0,z.jsx)(T5,{link:a})]})},O5=({roles:e,selected:t,grantable:n,disabled:r,onChange:i})=>(0,z.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,children:e.map(e=>{let a=t.includes(e.name),o=r||!n.has(e.name);return(0,z.jsxs)(`label`,{title:o&&!r?K(`cannotChangeRole`):void 0,className:g(`inline-flex items-center gap-1.5`,o&&`text-muted-foreground`),children:[(0,z.jsx)(xg,{checked:a,label:e.label,onChange:o?void 0:n=>i(n?[...t,e.name]:t.filter(t=>t!==e.name)),className:g(o&&`cursor-default opacity-60`)}),e.label]},e.name)})}),bSe=(e,t)=>t.map(t=>Dg(e,t)).join(`, `),k5=a({en:{inviteSomeone:`Invite someone`,inviteDescription:`They get an email with a link to make their account, with the roles you tick.`,notAcceptedYet:`Not accepted yet`,sendingAgain:`Sending again gives a new link, which replaces the earlier one.`,nobodyWaiting:`Nobody is waiting.`,addAnAccount:`Add an account`,addDescription:`Makes the account at once, with the address counted as verified. Without a password, the person signs in another way this app allows, such as an emailed code.`,email:`Email`,name:`Name`,password:`Password`,passwordOptional:e=>`Password (optional, ${e}+ characters)`,addAccount:`Add account`,couldNotReadRoles:`Could not read the roles`,people:`People`,peopleDescription:`Everyone with an account. Roles decide what each sees and does; someone blocked cannot sign in, and is signed out at once.`,findSomeone:`Find someone`,emailAddress:`Email address`,keepOneRole:`Keep at least one role.`,blocked:`Blocked`,unblock:`Unblock`,block:`Block`},nl:{inviteSomeone:`Iemand uitnodigen`,inviteDescription:`Die krijgt een e-mail met een link om een account te maken, met de rollen die je aanvinkt.`,notAcceptedYet:`Nog niet geaccepteerd`,sendingAgain:`Opnieuw sturen geeft een nieuwe link, die de vorige vervangt.`,nobodyWaiting:`Er wacht niemand.`,addAnAccount:`Een account toevoegen`,addDescription:`Maakt het account meteen, met het adres als gecontroleerd. Zonder wachtwoord logt de persoon in op een andere manier die deze app toestaat, zoals een gemailde code.`,email:`E-mailadres`,name:`Naam`,password:`Wachtwoord`,passwordOptional:e=>`Wachtwoord (optioneel, ${e}+ tekens)`,addAccount:`Account toevoegen`,couldNotReadRoles:`Kon de rollen niet lezen`,people:`Mensen`,peopleDescription:`Iedereen met een account. Rollen bepalen wat ieder ziet en doet; wie geblokkeerd is, kan niet inloggen en wordt meteen uitgelogd.`,findSomeone:`Iemand zoeken`,emailAddress:`E-mailadres`,keepOneRole:`Houd minstens één rol.`,blocked:`Geblokkeerd`,unblock:`Deblokkeren`,block:`Blokkeren`}}),xSe=({roles:e})=>{let{session:t}=xf(),[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)([]),o=(0,L.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,L.useEffect)(o,[o]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(E5,{title:k5(`inviteSomeone`),description:k5(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,z.jsx)(O5,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,z.jsx)(vp,{title:k5(`notAcceptedYet`),description:i.length>0?k5(`sendingAgain`):k5(`nobodyWaiting`),children:i.length>0&&(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,z.jsx)(D5,{email:n.email,gives:bSe(e,n.roles),expiresAt:n.expiresAt,onResend:async()=>{let e=await t.users.invite({email:n.email,roles:n.roles});return o(),e},onRevoke:async()=>{await t.users.revoke(n.id),o()}},n.id))})})]})},SSe=({roles:e,onCreated:t})=>{let{session:n}=xf(),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)([]),{busy:d,error:f,run:p}=Ag(),m=()=>p(async()=>{await n.users.create({email:r.trim(),name:a.trim(),roles:l,...s&&{password:s}}),i(``),o(``),c(``),u([]),t()}),h=!r.trim()||!a.trim()||l.length===0||s!==``&&s.length<12;return(0,z.jsxs)(vp,{title:k5(`addAnAccount`),description:k5(`addDescription`),children:[(0,z.jsx)(yp,{message:f}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,z.jsx)(Wd,{"aria-label":k5(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,z.jsx)(Wd,{"aria-label":k5(`name`),placeholder:k5(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,z.jsx)(Wd,{"aria-label":k5(`password`),type:`password`,autoComplete:`new-password`,placeholder:k5(`passwordOptional`,12),value:s,onChange:e=>c(e.target.value)}),(0,z.jsx)(O5,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,z.jsx)(`div`,{children:(0,z.jsx)(V,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:k5(`addAccount`)})})]})]})},CSe=a({en:{showMore:`Show more`},nl:{showMore:`Meer tonen`}}),A5=({title:e,description:t,searchLabel:n,placeholder:r,query:i,onQuery:a,list:o,error:s,renderRow:c})=>(0,z.jsxs)(vp,{title:e,description:t,children:[(0,z.jsx)(yp,{message:s}),(0,z.jsx)(Wd,{"aria-label":n,placeholder:r,value:i,onChange:e=>a(e.target.value),leading:(0,z.jsx)(_o,{className:`size-3.5`}),wrapperClassName:`mb-2`}),(0,z.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[o.found.length,` of `,o.total]}),o.found.length>0&&(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:o.found.map(c)}),o.found.length<o.total&&(0,z.jsx)(V,{className:`mt-3`,loading:o.loading,onClick:()=>void o.more(),children:CSe(`showMore`)})]}),j5=(e,t)=>{let[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)(0),[o,s]=(0,L.useState)(!1),c=(0,L.useRef)(t);return c.current=t,(0,L.useEffect)(()=>{let n=setTimeout(()=>{s(!0),e(t,0).then(e=>{c.current===t&&(r(e.items),a(e.total),s(!1))},()=>{c.current===t&&(r([]),a(0),s(!1))})},200);return()=>clearTimeout(n)},[e,t]),{found:n,total:i,more:async()=>{let i=t;s(!0);let o=await e(i,n.length).catch(()=>void 0);c.current===i&&(o&&(r(e=>[...e,...o.items]),a(o.total)),s(!1))},loading:o}},M5=({name:e,email:t,self:n,actions:r,children:i,error:a})=>(0,z.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`span`,{className:`block truncate font-medium`,children:[e,n&&` (you)`]}),(0,z.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t})]}),r]}),i,(0,z.jsx)(yp,{message:a})]}),wSe=({user:e,roles:t,self:n})=>{let{session:r}=xf(),[i,a]=(0,L.useState)(e),{busy:o,error:s,run:c,setError:l}=Ag(),u=e=>{if(e.length===0)return l(k5(`keepOneRole`));c(async()=>{await r.users.setRoles(i.id,e),a({...i,roles:e})})},d=e=>void c(async()=>{await(e?r.users.block(i.id):r.users.unblock(i.id)),a({...i,blocked:e})});return(0,z.jsx)(M5,{name:i.name,email:i.email,self:n,error:s,actions:(0,z.jsxs)(z.Fragment,{children:[i.blocked&&(0,z.jsx)(_d,{tone:`red`,children:k5(`blocked`)}),!n&&(i.blocked?(0,z.jsx)(V,{size:`sm`,loading:o,onClick:()=>d(!1),children:k5(`unblock`)}):(0,z.jsx)(V,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:k5(`block`)}))]}),children:(0,z.jsx)(O5,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},TSe=({roles:e,version:t})=>{let{session:n,state:r}=xf(),[i,a]=(0,L.useState)(``),o=j5((0,L.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),i),s=r.kind===`signed-in`?r.user.id:void 0;return(0,z.jsx)(A5,{title:k5(`people`),description:k5(`peopleDescription`),searchLabel:k5(`findSomeone`),placeholder:k5(`emailAddress`),query:i,onQuery:a,list:o,renderRow:n=>(0,z.jsx)(wSe,{user:n,roles:e,self:n.id===s},`${t}/${n.id}`)})},ESe=()=>{let{session:e}=xf(),[t,n]=(0,L.useState)([]),[r,i]=(0,L.useState)();return(0,L.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof Oc?sf(e):k5(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},DSe={Page:cge,Grid:tge,Card:qT,Stat:Zbe,RecordCard:dge,Field:Xhe,Table:ySe,CardRow:YT,RecordRow:qbe,RecordCards:bge,Chart:Ghe,Progress:lge,ModalForm:sge,Action:WT,Show:Jbe,Link:nge,Users:()=>{let{roles:e,error:t}=ESe(),[n,r]=(0,L.useState)(0);return(0,z.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,z.jsx)(yp,{message:t}),(0,z.jsx)(TSe,{roles:e,version:n}),(0,z.jsx)(xSe,{roles:e}),(0,z.jsx)(SSe,{roles:e,onCreated:()=>r(e=>e+1)})]})}},N5=e=>typeof e==`string`||!e.custom&&e.type===`Link`,P5=e=>{let t=[];for(let n of e){let e=t.at(-1);N5(n)&&e&&N5(e[0])?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return N5(n)?(0,z.jsx)(`p`,{className:`leading-6`,children:e.map((e,t)=>typeof e==`string`?(0,z.jsx)(L.Fragment,{children:e},t):(0,z.jsx)(F5,{node:e},t))},t):(0,z.jsx)(F5,{node:n},t)})},OSe=e=>hc(e)||Array.isArray(e)&&e.length>0&&e.every(hc),kSe=e=>Object.fromEntries(Object.entries(e.props).flatMap(([e,t])=>OSe(t)?[[e,(0,z.jsx)(z.Fragment,{children:P5(Array.isArray(t)?t:[t])})]]:[])),F5=({node:e})=>{let{components:t}=hC();if(e.custom){let n=t?.[e.type];return n?(0,z.jsx)(Lg,{name:e.type,children:(0,z.jsx)(n,{...Jn(e.props),children:e.children.length>0?P5(e.children):void 0})}):(0,z.jsx)(Fg,{children:gg(Ig(`noComponent`),e.type)})}let n=DSe[e.type];return n?(0,z.jsx)(n,{node:e,slots:kSe(e),children:P5(e.children)}):(0,z.jsx)(Fg,{children:gg(Ig(`unknownBlock`),e.type)})},I5=({name:e})=>{let t=G().pages[e];return t?(0,z.jsx)(F5,{node:t.tree}):(0,z.jsx)(sg,{title:Ig(`notFound`),children:gg(Ig(`noPage`),e)})},L5=a({en:{details:`Details`,history:`History`,comments:`Comments`,summary:`Summary`,loading:`Loading`,fetching:`Fetching the record.`,noRecord:`This record does not exist, or you cannot see it.`,couldNotLoad:`Could not load the record`,someoneElse:`Someone else`,justNow:`just now`,saved:`Saved`,save:`Save`,cancel:`Cancel`,unsavedChanges:`Unsaved changes`,notSaved:`Not saved`,linesChanged:`The lines were changed by someone else`,linesReloaded:`The lines were reloaded. Your new order is kept: Save again to apply it.`,unsavedKept:`You have unsaved changes to this record.`,continueEditing:`Continue editing`,discard:`Discard`,unsavedRestored:`Your unsaved changes were restored.`,keep:`Keep`,savingSubject:e=>`Saving ${e}...`,subjectSaved:e=>`${e} saved`,changedBySomeoneElse:`Changed by someone else`,couldNotSave:`Could not save`,recordActions:`Record actions`,edit:`Edit`,delete:`Delete`,nothingYet:`Nothing here yet.`,couldNotLoadRelated:`Could not load`,relatedRecords:`Related records`,lines:`Lines`,linesHelp:`What the document bills for. Drag the handle, or use the menu, to change the order; Save applies it.`},nl:{details:`Details`,history:`Geschiedenis`,comments:`Opmerkingen`,summary:`Overzicht`,loading:`Laden`,fetching:`Het record wordt opgehaald.`,noRecord:`Dit record bestaat niet, of je mag het niet zien.`,couldNotLoad:`Kon het record niet laden`,someoneElse:`Iemand anders`,justNow:`zojuist`,saved:`Bewaard`,save:`Bewaren`,cancel:`Annuleren`,unsavedChanges:`Niet bewaarde wijzigingen`,notSaved:`Niet bewaard`,linesChanged:`De regels zijn door iemand anders gewijzigd`,linesReloaded:`De regels zijn opnieuw geladen. Je nieuwe volgorde is behouden: bewaar opnieuw om hem toe te passen.`,unsavedKept:`Je hebt niet bewaarde wijzigingen in dit record.`,continueEditing:`Verder bewerken`,discard:`Weggooien`,unsavedRestored:`Je niet bewaarde wijzigingen zijn teruggezet.`,keep:`Houden`,savingSubject:e=>`${e} bewaren...`,subjectSaved:e=>`${e} bewaard`,changedBySomeoneElse:`Gewijzigd door iemand anders`,couldNotSave:`Kon niet bewaren`,recordActions:`Recordacties`,edit:`Bewerken`,delete:`Verwijderen`,nothingYet:`Hier staat nog niets.`,couldNotLoadRelated:`Kon niet laden`,relatedRecords:`Gerelateerde records`,lines:`Regels`,linesHelp:`Waar het document voor factureert. Sleep de greep, of gebruik het menu, om de volgorde te wijzigen; Bewaren past hem toe.`}}),ASe=2e3,R5=(e,t)=>{let n=Hb(),[r,i]=(0,L.useState)(`idle`),[a,o]=(0,L.useState)(),s=(0,L.useRef)(void 0);return(0,L.useEffect)(()=>()=>clearTimeout(s.current),[]),{phase:r,message:a,run:async r=>{let a=e===`toast`?n.show({state:`loading`,title:L5(`savingSubject`,t)}):void 0;o(void 0),e===`button`&&i(`saving`);try{return await r(),a!==void 0&&n.update(a,{state:`success`,title:L5(`subjectSaved`,t)}),e===`button`&&(i(`saved`),s.current=setTimeout(()=>i(`idle`),ASe)),!0}catch(t){if(!Xs(t))throw t;let r=t.status===412?L5(`changedBySomeoneElse`):L5(`couldNotSave`),s=jC(t);return a!==void 0&&n.update(a,{state:`error`,title:r,description:s}),e===`button`&&(i(`idle`),o(`${r}: ${s}`)),!1}}}},z5=({title:e,eyebrow:t,submit:n,saving:r,disabled:i,error:a,errorTitle:o=YS(`notSaved`),onSubmit:s,onCancel:c,children:l,ref:u})=>{let d=(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c&&(0,z.jsx)(V,{className:`max-sm:min-h-11`,onClick:c,children:YS(`cancel`)}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,className:`max-sm:min-h-11 max-sm:flex-1`,loading:r,disabled:i,children:n})]}),f=a!==void 0&&(0,z.jsx)(`div`,{className:`mt-4`,children:(0,z.jsx)(rC,{title:o,error:a})}),p=(0,z.jsx)(`div`,{className:`divide-y divide-border`,children:l}),m=e=>{e.preventDefault(),s()};return e===void 0?(0,z.jsxs)(`form`,{ref:u,className:`max-w-[760px]`,onSubmit:m,children:[f,p,(0,z.jsx)(`footer`,{className:`border-t pt-6 sm:flex sm:justify-end`,children:d})]}):(0,z.jsx)(`form`,{ref:u,className:`flex-1`,onSubmit:m,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-[760px] px-4 py-6 md:px-10 md:py-8`,children:[(0,z.jsxs)(`header`,{className:`flex flex-col gap-4 border-b pb-6 sm:flex-row sm:items-end sm:justify-between sm:gap-6`,children:[(0,z.jsxs)(`div`,{children:[t&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),(0,z.jsx)(`h1`,{className:`mt-1 text-2xl font-semibold tracking-tight`,children:e})]}),d]}),f,p]})})},jSe=({noun:e,collection:t,sections:n,saving:r,message:i,onSubmit:a,onCancel:o,ref:s})=>(0,z.jsx)(z5,{ref:s,title:YS(`title`,e),eyebrow:t,submit:YS(`submit`,e),saving:r,error:i?Error(i):void 0,errorTitle:YS(`notCreated`),onSubmit:a,onCancel:o,children:n.map(e=>(0,z.jsx)(qb,{title:e.title,help:e.help,children:(0,z.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:e.fields.map(e=>(0,z.jsx)(Gb,{name:e.name,label:e.label,required:e.required,help:e.help,error:e.error,wide:e.wide,children:e.editor},e.name))})},e.title))}),MSe=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),NSe=({resource:e,values:t})=>{let n=G(),r=n.resources[e],i=cg(e);return r?xT(i,`create`)?(0,z.jsx)(PSe,{resource:e,values:t}):(0,z.jsx)(sg,{title:YS(`notAllowed`),children:YS(`cannotCreate`,n.views[e]?.names?.plural.toLowerCase()??e)}):(0,z.jsx)(sg,{title:H(`notFound`),children:H(`noResource`,e)})},PSe=({resource:e,values:t})=>{let n=G(),r=n.resources[e],i=n.views[e],a=W(),o=Km(),{go:s}=AS(),c=i?.names?.singular??q(e),l=R5(i?.saveFeedback??`toast`,YS(`subject`,c)),u=woe(r,i),[d,f]=(0,L.useState)(()=>eC(r,u,t)),[p,m]=(0,L.useState)({}),[h,g]=(0,L.useState)(0),_=MC(h);(0,L.useEffect)(()=>{for(let[e,i]of Object.entries(t??{})){let t=n.resources[r.fields[e]?.relation?.resource??``];t&&q0(o,a,t,[i],n.views[t.name]).then(t=>{let n=t.get(i);n&&f(t=>XS(t[e])&&t[e].key===i?{...t,[e]:{key:i,label:n}}:t)})}},[t,n,r,a,o]);let v=(e,t)=>{m(t=>MSe(t,e)),f(n=>({...n,[e]:t}))},y=()=>l.run(async()=>{let t;try{t=await a.create(e,QS(r,n.resources,d))}catch(e){let t=AC(e);throw m(t),Object.keys(t).length>0&&g(e=>e+1),e}for(let t of[`page`,`list`,`first-page`,`map`,`facets`,`series`])o.invalidateQueries({queryKey:[t,e]});s({kind:`record`,resource:e,key:Kx(r,t.record)},{replace:!0})}),b=u.map(e=>({title:e.title,help:e.help,fields:e.fields.map(e=>{let t=r.fields[e],a=d[e],o=t.relation?n.resources[t.relation.resource]:void 0,s=i?.fields[e]?.label??q(e),c=p[e];return{name:e,label:s,help:i?.fields[e]?.help,required:$S(t),error:c&&kC(t,s,c),wide:!!(i?.fields[e]?.multiline||i?.fields[e]?.markdown),editor:(0,z.jsx)(SC,{field:t,hints:i?.fields[e],value:XS(a)?a.key:a??(t.type!==`boolean`&&``),stored:void 0,relationLabel:XS(a)?a.label:void 0,placeholder:tC(t)?YS(`setByDatabase`):void 0,relationPicker:o?{target:o,view:n.views[o.name]}:void 0,invalid:!!p[e],resource:r.name,onChange:t=>v(e,t)})}})}));return(0,z.jsx)(jSe,{ref:_,noun:c,collection:i?.names?.plural??q(e),sections:b,saving:l.phase===`saving`,message:l.message,onSubmit:()=>void y(),onCancel:()=>s({kind:`list`,resource:e})})},FSe=({resource:e,values:t})=>{let n=G(),r=n.views[e];return r?.create?n.pages[r.create.page]?(0,z.jsx)(I5,{name:r.create.page}):(0,z.jsx)(sg,{title:YS(`notAllowed`),children:YS(`cannotCreate`,r.names?.plural.toLowerCase()??q(e))}):(0,z.jsx)(NSe,{resource:e,values:t},new URLSearchParams(t).toString())},ISe=(e,t)=>{let n=new Map(t.map(e=>[e.value,e.count]));return e.map(([e,t])=>({value:e,label:t,...n.get(e)!==void 0&&{count:n.get(e)}}))},LSe=(e,t)=>[...new Set(t.filter(t=>!e.includes(t)))],RSe=Vn(),zSe=(e,t)=>{let n=W(),[r,i]=(0,L.useState)({}),a=e=>!!e?.search?.length&&e.primaryKey.length===1,o=Wh({queries:e.map(({id:e,target:i})=>{let o=(r[e]??``).trim();return{queryKey:[`reference-search`,e,i?.name??``,o],enabled:a(i)&&o!==``,placeholderData:lh,queryFn:async()=>{let e=i.primaryKey[0],r=Vx(i,t[i.name]);return(await n.list(i.name,{filter:Fn(RSe.search(o)),fields:[e,r],pageSize:20})).items.map(t=>[String(t[e]),String(t[r])])}}})});return e.map(({id:e,target:t},n)=>{if(!a(t))return{};let s=t=>i(n=>({...n,[e]:t}));return(r[e]??``).trim()===``?{onSearch:s}:{onSearch:s,matches:o[n]?.data??[]}})},BSe=24,VSe=({model:e,resources:t,views:n,view:r,state:i,extras:a})=>{let o=W(),s=Km(),c=l6(r,e),l=e=>r?.fields[e]?.label??q(e),u=n=>{let r=e.fields[n];return r?.type===`relation`&&r.relation?t[r.relation.resource]:void 0},d=c.facets.flatMap(e=>(e.flags?e.options.map(e=>e.value):[e.id]).map(t=>({group:e.id,field:t}))),f=Wh({queries:d.map(({group:t,field:r})=>{let s=t6(c,{...i,facets:{...i.facets,[t]:[]}},a),l=u(r),d=l?.primaryKey.length===1?Vx(l,n[l.name]):void 0;return{queryKey:U.facets(e.name,r,s),queryFn:()=>o.facets(e.name,r,{filter:s,limit:50,...d&&{label:d}})}})}),p=(e,t)=>f[d.findIndex(n=>n.group===e&&n.field===t)]?.data,m=Wh({queries:c.facets.map(t=>{let r=u(t.id),a=LSe((p(t.id,t.id)??[]).flatMap(e=>e.value===null?[]:[String(e.value)]),i.facets[t.id]??[]);return{queryKey:U.labels(`facet:${e.name}.${t.id}`,a.join(`,`)),enabled:!!r&&a.length>0,queryFn:async()=>[...await q0(s,o,r,a,n[r.name])]}})}),h=zSe(c.facets.map(e=>({id:e.id,target:e.combobox?u(e.id):void 0})),n),g=c.ranges??[],_=Wh({queries:g.map(t=>{let n=t6(c,N3(i,t.id,void 0),a),s=u6(r,t.id)?BSe:1;return{queryKey:U.histogram(e.name,t.id,s,n),queryFn:()=>o.histogram(e.name,t.id,{filter:n,buckets:s})}})});return{facets:c.facets.map((t,n)=>{if(t.flags){let e=t.options.map(({value:e})=>({value:e,label:l(e),count:p(t.id,e)?.find(e=>String(e.value)===`true`)?.count??0}));return{...t,options:e}}let i=e.fields[t.id],a=(p(t.id,t.id)??[]).flatMap(e=>e.label===void 0?[]:[[String(e.value),e.label]]),o=new Map([...a,...m[n]?.data??[]]),s=(p(t.id,t.id)??[]).flatMap(e=>e.value===null?[]:[{value:String(e.value),label:i?.type===`enum`?ps(String(e.value),r?.fields[t.id]?.valueLabels):o.get(String(e.value))??String(e.value),count:e.count}]),c=h[n];return{...t,label:l(t.id),options:c.matches?ISe(c.matches,s):s,...o.size>0&&{labels:Object.fromEntries(o)},...c.onSearch&&{onSearch:c.onSearch}}}),ranges:g.flatMap((e,t)=>{let n=_[t]?.data;return!n||n.min===null||n.max===null?[]:[{...e,label:l(e.id),min:Math.floor(n.min),max:Math.ceil(n.max),step:Math.max(1,Math.round((n.max-n.min)/100)),histogram:u6(r,e.id)?n.buckets.map(e=>e.count):[],format:d6(r,e.id)}]}),...c.dateField&&{datePresets:c.datePresets??!0,dateField:c.dateField,dateKind:c.dateKind,...c.dateSecondary&&{dateSecondary:!0}},toggles:c.toggles?.map(e=>({...e,label:l(e.id)}))}},B5=a({en:{confirmTitle:e=>`Delete ${e}?`,confirmDescription:(e,t)=>`This ${e.toLowerCase()} will be removed. This cannot be undone.`,cancel:`Cancel`,delete:`Delete`,changedTitle:e=>`${e} was changed since you opened it`,changedDescription:`Someone saved this record in the meantime. Review what changed before you delete it.`,reviewChanges:`Review changes`,deleteAnyway:`Delete anyway`,noVisibleChanges:`No visible fields differ; the record was saved again with the same values.`,bulkConfirmTitle:(e,t)=>`Delete ${e} ${e===1?t.replace(/s$/,``):t.toLowerCase()}?`,bulkConfirmDescription:`This cannot be undone. Each record is deleted only if it has not changed since the list loaded; anything that changed is reported and kept.`,deleteCount:e=>`Delete ${e}`,deleting:`Deleting`,progress:(e,t)=>`${e} of ${t} done`,working:`Working`,deleted:e=>`Deleted ${e}`,deletedOf:(e,t)=>`Deleted ${e} of ${t}`,kept:e=>`${e} could not be deleted and were kept.`,done:`Done`,deletedToast:e=>`${e} deleted`,undo:`Undo`,restored:e=>`${e} restored`,alreadyBack:e=>`${e} is already back`,couldNotRestore:e=>`Could not restore ${e}`,couldNotDelete:e=>`Could not delete ${e}`,changedSinceLoaded:`Changed since the list loaded, so it was kept.`,stillPointAt:(e,t)=>`${e} still point at this ${t.toLowerCase()}.`,show:e=>`Show ${e.toLowerCase()}`},nl:{confirmTitle:e=>`${e} verwijderen?`,confirmDescription:(e,t)=>`${t} wordt verwijderd. Dit kan niet ongedaan worden gemaakt.`,cancel:`Annuleren`,delete:`Verwijderen`,changedTitle:e=>`${e} is gewijzigd sinds je het opende`,changedDescription:`Iemand heeft dit record intussen bewaard. Bekijk wat er veranderde voordat je het verwijdert.`,reviewChanges:`Wijzigingen bekijken`,deleteAnyway:`Toch verwijderen`,noVisibleChanges:`Geen zichtbaar veld verschilt; het record is opnieuw bewaard met dezelfde waarden.`,bulkConfirmTitle:(e,t)=>e===1?`Eén record verwijderen?`:`${e} ${t.toLowerCase()} verwijderen?`,bulkConfirmDescription:`Dit kan niet ongedaan worden gemaakt. Elk record wordt alleen verwijderd als het niet is gewijzigd sinds de lijst laadde; wat wel is gewijzigd, wordt gemeld en behouden.`,deleteCount:e=>`${e} verwijderen`,deleting:`Verwijderen`,progress:(e,t)=>`${e} van ${t} klaar`,working:`Bezig`,deleted:e=>`${e} verwijderd`,deletedOf:(e,t)=>`${e} van ${t} verwijderd`,kept:e=>`${e} kon${e===1?``:`den`} niet worden verwijderd en ${e===1?`is`:`zijn`} behouden.`,done:`Klaar`,deletedToast:e=>`${e} verwijderd`,undo:`Ongedaan maken`,restored:e=>`${e} teruggezet`,alreadyBack:e=>`${e} is al terug`,couldNotRestore:e=>`Kon ${e} niet terugzetten`,couldNotDelete:e=>`Kon ${e} niet verwijderen`,changedSinceLoaded:`Gewijzigd sinds de lijst laadde, dus behouden.`,stillPointAt:(e,t)=>`${e} verwijzen hier nog naar.`,show:e=>`${e} tonen`}}),HSe=Vn(),USe=({blockingPlural:e,noun:t})=>B5(`stillPointAt`,e,t),WSe=({blockedBy:e,resources:t,views:n,noun:r,key:i})=>{let{resource:a,field:o}=e;if(!t[a])return;let s=n[a]?.names?.plural??q(a),c=USe({blockingPlural:s,noun:r});if(!o||i===void 0)return{text:c};let l={kind:`list`,resource:a,filter:Fn(HSe.eq(o,i))};return{text:c,link:{label:B5(`show`,s),to:l}}},GSe=({title:e,noun:t,busy:n,onConfirm:r,onCancel:i})=>(0,z.jsx)(_p,{title:B5(`confirmTitle`,e),description:B5(`confirmDescription`,t,e),onClose:i,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:i,children:B5(`cancel`)}),(0,z.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:r,children:B5(`delete`)})]})}),KSe=({title:e,changes:t,busy:n,onReview:r,onDeleteAnyway:i,onCancel:a})=>(0,z.jsx)(_p,{title:B5(`changedTitle`,e),description:B5(`changedDescription`),onClose:a,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:r,children:B5(`reviewChanges`)}),(0,z.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:i,children:B5(`deleteAnyway`)})]}),children:t.length===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B5(`noVisibleChanges`)}):(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:t.map(e=>(0,z.jsxs)(`li`,{className:`grid grid-cols-[96px_1fr] gap-3 px-3 py-2`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,z.jsx)(`span`,{className:`font-medium`,children:e.after})]})]},e.field))})}),V5=e=>{if(e.stage===`confirm`)return(0,z.jsx)(_p,{title:B5(`bulkConfirmTitle`,e.count,e.plural),description:B5(`bulkConfirmDescription`),onClose:e.onCancel,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:e.onCancel,children:B5(`cancel`)}),(0,z.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,onClick:e.onConfirm,children:B5(`deleteCount`,e.count)})]})});if(e.stage===`running`)return(0,z.jsx)(_p,{title:B5(`deleting`),description:B5(`progress`,e.done,e.total),onClose:()=>void 0,actions:(0,z.jsx)(V,{loading:!0,disabled:!0,children:B5(`working`)})});let t=e.total-e.failures.length;return(0,z.jsx)(_p,{title:e.failures.length===0?B5(`deleted`,t):B5(`deletedOf`,t,e.total),description:e.failures.length===0?void 0:B5(`kept`,e.failures.length),onClose:e.onClose,actions:(0,z.jsx)(V,{variant:`primary`,onClick:e.onClose,children:B5(`done`)}),children:e.failures.length>0&&(0,z.jsx)(`ul`,{className:`max-h-48 divide-y overflow-y-auto rounded-md border`,children:e.failures.map(e=>(0,z.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,z.jsx)(`span`,{className:`block text-xs text-danger-text`,children:e.message})]},e.title))})})},qSe=new Set([`updated_at`,`updatedAt`]),JSe=(e,t,n,r)=>Object.values(e.fields).flatMap(e=>{if(qSe.has(e.name)||JSON.stringify(n[e.name]??null)===JSON.stringify(r[e.name]??null))return[];let i=t?.fields[e.name];return[{field:e.name,label:i?.label??q(e.name),before:rS(e,n[e.name],i),after:rS(e,r[e.name],i)}]}),YSe=4,H5=({model:e,view:t,onDeleted:n,onReview:r,restore:i})=>{let a=W(),o=Km(),s=Hb(),[c,l]=(0,L.useState)(),[u,d]=(0,L.useState)(!1),f=t?.names?.singular??q(e.name),p=t?.names?.plural??q(e.name),{resources:m,views:h}=G(),{href:g,open:_}=AS(),v=(t,n)=>t.blockedBy&&WSe({blockedBy:t.blockedBy,resources:m,views:h,noun:f,...e.primaryKey.length===1&&{key:n.key}}),y=()=>{for(let t of[`page`,`list`,`first-page`,`map`])o.invalidateQueries({queryKey:[t,e.name]});for(let t of[`facets`,`series`,`histogram`])o.invalidateQueries({queryKey:[t,e.name]})},b=async(t,n)=>{let r=n??(await a.get(e.name,t.key)).etag;try{await a.remove(e.name,t.key,{etag:r})}catch(e){if(!(e instanceof Ys))throw e;return e}},x=t=>{y(),l(void 0),n?.(t),s.show({state:`success`,title:B5(`deletedToast`,t.title),...e.softDelete&&i&&{action:{label:B5(`undo`),onClick:()=>{i(t).then(()=>{y(),s.show({state:`success`,title:B5(`restored`,t.title)})},e=>{if(!Xs(e))throw e;y(),s.show({state:e.status===409?`success`:`error`,title:e.status===409?B5(`alreadyBack`,t.title):B5(`couldNotRestore`,t.title),description:e.status===409?void 0:e.message})})}}}})},S=async(n,r)=>{d(!0);try{if(!await b(n,r))return x(n);let i=(await a.get(e.name,n.key)).record;l({kind:`conflict`,target:n,fresh:i,changes:JSe(e,t,n.snapshot,i)})}catch(e){if(!Xs(e))throw e;l(void 0);let t=v(e,n);s.show({state:`error`,title:B5(`couldNotDelete`,n.title),description:t?.text??e.message,...t?.link&&{action:{label:t.link.label,href:g(t.link.to),onNavigate:_}}})}finally{d(!1)}},C=async e=>{try{return await b(e,e.etag)?{title:e.title,message:B5(`changedSinceLoaded`)}:void 0}catch(t){if(!Xs(t))throw t;return{title:e.title,message:v(t,e)?.text??t.message}}},w=async e=>{let t=[],n=0;l({kind:`bulk-running`,done:n,total:e.length});let r=[...e];await Promise.all(Array.from({length:Math.min(YSe,e.length)},async()=>{for(let i=r.shift();i;i=r.shift()){let r=await C(i);r&&t.push(r),n+=1,l({kind:`bulk-running`,done:n,total:e.length})}})),y(),l({kind:`bulk-done`,total:e.length,failures:t})},T=()=>l(void 0);return{dialogs:c&&(0,z.jsxs)(z.Fragment,{children:[c.kind===`confirm`&&(0,z.jsx)(GSe,{title:c.target.title,noun:f,busy:u,onCancel:T,onConfirm:()=>void S(c.target,c.target.etag)}),c.kind===`conflict`&&(0,z.jsx)(KSe,{title:c.target.title,changes:c.changes,busy:u,onCancel:T,onReview:()=>{T(),r?.(c.target,c.fresh)},onDeleteAnyway:()=>void S(c.target,`*`)}),c.kind===`bulk-confirm`&&(0,z.jsx)(V5,{stage:`confirm`,count:c.targets.length,plural:p,onCancel:T,onConfirm:()=>void w(c.targets)}),c.kind===`bulk-running`&&(0,z.jsx)(V5,{stage:`running`,done:c.done,total:c.total}),c.kind===`bulk-done`&&(0,z.jsx)(V5,{stage:`done`,total:c.total,failures:c.failures,onClose:T})]}),start:t=>e.softDelete?S(t,t.etag):l({kind:`confirm`,target:t}),startBulk:e=>l({kind:`bulk-confirm`,targets:e})}},U5=e=>{let t=W();return e.softDelete?async n=>void await t.undelete(e.name,n.key):void 0},W5=(e,t,n)=>e?.create?Object.hasOwn(t,e.create.page):xT(n,`create`),$=a({en:{import:`Import`,importPlural:e=>`Import ${e.toLowerCase()}`,couldNotReadFile:`Could not read the file`,couldNotCheck:`Could not check the rows`,cancel:`Cancel`,next:`Next`,checkRows:`Check rows`,back:`Back`,checking:`Checking`,importRows:(e,t)=>`Import ${e} ${t===1?`row`:`rows`}`,cancelImport:`Cancel import`,done:`Done`,file:`File`,fileHint:`An Excel workbook (.xlsx) or a CSV file saved as UTF-8. Its first row names the columns.`,reading:e=>`Reading ${e}…`,theFile:`the file`,sheet:`Sheet`,create:`Create`,update:`Update`,upsert:`Create or update`,createHint:`Each row creates a record.`,updateHint:`Each row updates the record its value finds; a row that finds none is not imported.`,upsertHint:`Each row updates the record its value finds, or creates one when it finds none.`,doNotImport:`Do not import`,rows:`Rows`,whatEachRowDoes:`What each row does`,findBy:`Find records by`,chooseField:`Choose a field`,findByHint:`A field no two records share, such as the key or an email.`,foundInColumn:`Found in column`,chooseColumn:`Choose a column`,numbers:`Numbers`,dates:`Dates`,dayFirst:`Day first (31/12/2026)`,monthFirst:`Month first (12/31/2026)`,datesHint:`Dates written as 2026-12-31 read the same either way. Times without a zone are your own time.`,requiredMarked:`New records need the fields marked *.`,columns:`Columns`,emptyInFirstRows:`Empty in the first rows`,field:`Field`,fieldFor:e=>`Field for ${e}`,foundBy:`Found by`,pluralFoundBy:e=>`${e} found by`,noColumnFills:e=>`No column fills ${e}, which new records need.`,rowsNotImported:`Rows not imported`,rowProblems:e=>`Row ${e}:`,andMore:e=>`And ${e} more rows, all in the file.`,checkingRows:e=>`Checking rows… ${e} read`,check:`Check`,toCreate:`To create`,toUpdate:`To update`,withProblems:`With problems`,firstRows:`First rows`,row:`Row`,problemRows:`Rows with problems, which are skipped`,download:`Download`,batches:e=>`Rows are saved in batches of ${e}. Cancelling, or an error, keeps the batches already saved; a row the server refuses is listed and the others are saved.`,stopping:`Stopping after this batch…`,saving:`Saving rows…`,rowsSaved:`Rows saved`,stopped:`The import stopped. The rows counted below were saved.`,cancelled:`Cancelled. The rows counted below were saved.`,summary:`Import summary`,created:`Created`,updated:`Updated`,skipped:`Skipped`,failed:`Failed`,notWrittenHint:`Skipped rows had problems in the file; the server refused the failed ones. The file holds each with the reason, to fix and import again.`,notImportedFile:e=>`${e} - not imported.csv`,line:`Line`,problems:`Problems`,notNumber:e=>`${e} is not a number`,notWholeNumber:e=>`${e} is not a whole number`,tooLarge:e=>`${e} is too large`,notBoolean:e=>`${e} is not true or false (true, false, yes, no, 1 or 0)`,notDate:(e,t)=>`${e} is not a date (2026-04-03 or ${t?`day/month/year`:`month/day/year`})`,hasTime:e=>`${e} has a time of day; the field holds a date`,severalValues:(e,t)=>`${e} matches more than one value: ${t}`,notOneOf:(e,t)=>`${e} is not one of ${t}`,notText:e=>`${e} is true or false, not text`,emptyRequired:`is empty, and it is required`,noneHas:(e,t)=>`no ${e.toLowerCase()} has ${t}`,severalHave:(e,t,n)=>`${e} ${t.toLowerCase()} have ${n}`,notOneRecord:e=>`Not one record: ${e}`,nothingToUpdate:e=>`Nothing to update: ${e}`,fileNotUtf8:`The file is not UTF-8 text. Save it as "CSV UTF-8" and choose it again.`,noSheets:`The workbook has no sheets`,missingSheetPart:`The workbook names a sheet it does not hold`,notZip:`The file is not an Excel workbook (.xlsx): it is no ZIP archive`,zip64:`The workbook is too large to read: it is a ZIP64 archive`,compression:(e,t)=>`The workbook's part ${e} is compressed in a way that cannot be read (method ${t})`,notWorkbook:e=>`The file is not an Excel workbook (.xlsx): it has no ${e}`,noSheetCalled:e=>`The workbook has no sheet called ${e}`,unreadable:`The file could not be read`,column:e=>`Column ${e}`},nl:{import:`Importeren`,importPlural:e=>`${e} importeren`,couldNotReadFile:`Kon het bestand niet lezen`,couldNotCheck:`Kon de rijen niet controleren`,cancel:`Annuleren`,next:`Volgende`,checkRows:`Rijen controleren`,back:`Terug`,checking:`Controleren`,importRows:(e,t)=>`${e} ${t===1?`rij`:`rijen`} importeren`,cancelImport:`Import annuleren`,done:`Klaar`,file:`Bestand`,fileHint:`Een Excel-werkmap (.xlsx) of een CSV-bestand bewaard als UTF-8. De eerste rij noemt de kolommen.`,reading:e=>`${e} lezen…`,theFile:`het bestand`,sheet:`Werkblad`,create:`Maken`,update:`Bijwerken`,upsert:`Maken of bijwerken`,createHint:`Elke rij maakt een record.`,updateHint:`Elke rij werkt het record bij dat haar waarde vindt; een rij die er geen vindt, wordt niet geïmporteerd.`,upsertHint:`Elke rij werkt het record bij dat haar waarde vindt, of maakt er een als ze er geen vindt.`,doNotImport:`Niet importeren`,rows:`Rijen`,whatEachRowDoes:`Wat elke rij doet`,findBy:`Records vinden op`,chooseField:`Kies een veld`,findByHint:`Een veld dat geen twee records delen, zoals de sleutel of een e-mailadres.`,foundInColumn:`Gevonden in kolom`,chooseColumn:`Kies een kolom`,numbers:`Getallen`,dates:`Datums`,dayFirst:`Dag eerst (31/12/2026)`,monthFirst:`Maand eerst (12/31/2026)`,datesHint:`Datums geschreven als 2026-12-31 lezen hoe dan ook hetzelfde. Tijden zonder zone zijn in je eigen tijd.`,requiredMarked:`Nieuwe records hebben de velden met * nodig.`,columns:`Kolommen`,emptyInFirstRows:`Leeg in de eerste rijen`,field:`Veld`,fieldFor:e=>`Veld voor ${e}`,foundBy:`Gevonden op`,pluralFoundBy:e=>`${e} gevonden op`,noColumnFills:e=>`Geen kolom vult ${e}, wat nieuwe records nodig hebben.`,rowsNotImported:`Niet geïmporteerde rijen`,rowProblems:e=>`Rij ${e}:`,andMore:e=>`En nog ${e} rijen, allemaal in het bestand.`,checkingRows:e=>`Rijen controleren… ${e} gelezen`,check:`Controle`,toCreate:`Te maken`,toUpdate:`Bij te werken`,withProblems:`Met problemen`,firstRows:`Eerste rijen`,row:`Rij`,problemRows:`Rijen met problemen, die worden overgeslagen`,download:`Downloaden`,batches:e=>`Rijen worden bewaard in groepen van ${e}. Annuleren, of een fout, houdt de groepen die al bewaard zijn; een rij die de server weigert, wordt vermeld en de andere worden bewaard.`,stopping:`Stoppen na deze groep…`,saving:`Rijen bewaren…`,rowsSaved:`Bewaarde rijen`,stopped:`De import is gestopt. De rijen die hieronder zijn geteld, zijn bewaard.`,cancelled:`Geannuleerd. De rijen die hieronder zijn geteld, zijn bewaard.`,summary:`Samenvatting van de import`,created:`Gemaakt`,updated:`Bijgewerkt`,skipped:`Overgeslagen`,failed:`Mislukt`,notWrittenHint:`Overgeslagen rijen hadden problemen in het bestand; de mislukte weigerde de server. Het bestand bevat elke rij met de reden, om te verbeteren en opnieuw te importeren.`,notImportedFile:e=>`${e} - niet geïmporteerd.csv`,line:`Regel`,problems:`Problemen`,notNumber:e=>`${e} is geen getal`,notWholeNumber:e=>`${e} is geen geheel getal`,tooLarge:e=>`${e} is te groot`,notBoolean:e=>`${e} is niet waar of onwaar (true, false, yes, no, 1 of 0)`,notDate:(e,t)=>`${e} is geen datum (2026-04-03 of ${t?`dag/maand/jaar`:`maand/dag/jaar`})`,hasTime:e=>`${e} heeft een tijd van de dag; het veld bevat een datum`,severalValues:(e,t)=>`${e} past bij meer dan één waarde: ${t}`,notOneOf:(e,t)=>`${e} is niet een van ${t}`,notText:e=>`${e} is waar of onwaar, geen tekst`,emptyRequired:`is leeg, en is verplicht`,noneHas:(e,t)=>`geen ${e.toLowerCase()} heeft ${t}`,severalHave:(e,t,n)=>`${e} ${t.toLowerCase()} hebben ${n}`,notOneRecord:e=>`Niet één record: ${e}`,nothingToUpdate:e=>`Niets om bij te werken: ${e}`,fileNotUtf8:`Het bestand is geen UTF-8-tekst. Bewaar het als "CSV UTF-8" en kies het opnieuw.`,noSheets:`De werkmap heeft geen werkbladen`,missingSheetPart:`De werkmap noemt een werkblad dat er niet in zit`,notZip:`Het bestand is geen Excel-werkmap (.xlsx): het is geen ZIP-archief`,zip64:`De werkmap is te groot om te lezen: het is een ZIP64-archief`,compression:(e,t)=>`Het deel ${e} van de werkmap is gecomprimeerd op een manier die niet kan worden gelezen (methode ${t})`,notWorkbook:e=>`Het bestand is geen Excel-werkmap (.xlsx): het heeft geen ${e}`,noSheetCalled:e=>`De werkmap heeft geen werkblad met de naam ${e}`,unreadable:`Het bestand kon niet worden gelezen`,column:e=>`Kolom ${e}`}}),G5=e=>typeof e==`object`&&!!e,K5=e=>e===null||typeof e==`string`&&e.trim()===``,q5=e=>e===null?``:G5(e)?e.date.replace(`T`,` `):typeof e==`boolean`?e?`TRUE`:`FALSE`:String(e),J5=e=>e<26?String.fromCharCode(65+e):J5(Math.floor(e/26)-1)+J5(e%26),Y5=(e,t)=>e[t]?.trim()?e[t]:$(`column`,J5(t)),XSe=e=>/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,ZSe=(e,t)=>{let n=[...t].sort((e,t)=>e.line-t.line).map(t=>[...e.map((e,n)=>q5(t.cells[n]??null)),String(t.line),t.problems.join(`; `)]);return`${[[...e,$(`line`),$(`problems`)],...n].map(e=>e.map(XSe).join(`,`)).join(`\r
|
|
67
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qme(e,t){if(e){if(typeof e==`string`)return T0(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T0(e,t):void 0}}function T0(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function $me(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function ehe(e){if(Array.isArray(e))return e}var the=()=>(Bq(),null);function E0(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var nhe=(0,L.forwardRef)((e,t)=>{var n=(0,L.useRef)(null),r=w0((0,L.useState)({containerWidth:E0(e.style?.width),containerHeight:E0(e.style?.height)}),2),i=r[0],a=r[1],o=(0,L.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,L.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,L.useEffect)(()=>()=>{n.current?.disconnect()},[o]),L.createElement(L.Fragment,null,L.createElement($M,{width:i.containerWidth,height:i.containerHeight}),L.createElement(`div`,C0({ref:s},e)))}),rhe=(0,L.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=w0((0,L.useState)({containerWidth:E0(n),containerHeight:E0(r)}),2),a=i[0],o=i[1],s=(0,L.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,L.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return L.createElement(L.Fragment,null,L.createElement($M,{width:a.containerWidth,height:a.containerHeight}),L.createElement(`div`,C0({ref:c},e)))}),ihe=(0,L.forwardRef)((e,t)=>{var n=e.width,r=e.height;return L.createElement(L.Fragment,null,L.createElement($M,{width:n,height:r}),L.createElement(`div`,C0({ref:t},e)))}),ahe=(0,L.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?L.createElement(rhe,C0({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?L.createElement(ihe,C0({},e,{width:n,height:r,ref:t})):L.createElement(L.Fragment,null,L.createElement($M,{width:n,height:r}),L.createElement(`div`,C0({ref:t},e)))});function ohe(e){return e?nhe:ahe}var she=(0,L.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,v=e.responsive,y=e.dispatchTouchEvents,b=y===void 0||y,x=(0,L.useRef)(null),S=Vk(),C=w0((0,L.useState)(null),2),w=C[0],T=C[1],E=w0((0,L.useState)(null),2),D=E[0],O=E[1],k=Kme(),A=UM(),j=A?.width>0?A.width:_,M=A?.height>0?A.height:i,N=(0,L.useCallback)(e=>{k(e),typeof t==`function`&&t(e),T(e),O(e),e!=null&&(x.current=e)},[k,t,T,O]),P=(0,L.useCallback)(e=>{S(I1(e)),S(e0({handler:a,reactEvent:e}))},[S,a]),ee=(0,L.useCallback)(e=>{S(R1(e)),S(e0({handler:l,reactEvent:e}))},[S,l]),te=(0,L.useCallback)(e=>{S(YW()),S(e0({handler:u,reactEvent:e}))},[S,u]),ne=(0,L.useCallback)(e=>{S(R1(e)),S(e0({handler:d,reactEvent:e}))},[S,d]),re=(0,L.useCallback)(()=>{S(q1())},[S]),ie=(0,L.useCallback)(()=>{S(J1())},[S]),ae=(0,L.useCallback)(e=>{S(K1(e.key))},[S]),oe=(0,L.useCallback)(e=>{S(e0({handler:o,reactEvent:e}))},[S,o]),se=(0,L.useCallback)(e=>{S(e0({handler:s,reactEvent:e}))},[S,s]),ce=(0,L.useCallback)(e=>{S(e0({handler:c,reactEvent:e}))},[S,c]),le=(0,L.useCallback)(e=>{S(e0({handler:f,reactEvent:e}))},[S,f]),ue=(0,L.useCallback)(e=>{S(e0({handler:h,reactEvent:e}))},[S,h]),F=(0,L.useCallback)(e=>{b&&S(a0(e)),S(e0({handler:m,reactEvent:e}))},[S,b,m]),de=(0,L.useCallback)(e=>{S(e0({handler:p,reactEvent:e}))},[S,p]),fe=ohe(v);return L.createElement(mq.Provider,{value:w},L.createElement(gD.Provider,{value:D},L.createElement(fe,{width:j??g?.width,height:M??g?.height,className:mE(`recharts-wrapper`,r),style:qme({position:`relative`,cursor:`default`,width:j,height:M},g),onClick:P,onContextMenu:oe,onDoubleClick:se,onFocus:re,onBlur:ie,onKeyDown:ae,onMouseDown:ce,onMouseEnter:ee,onMouseLeave:te,onMouseMove:ne,onMouseUp:le,onTouchEnd:de,onTouchMove:F,onTouchStart:ue,ref:N},L.createElement(the,null),n)))}),che=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function lhe(e,t){if(e==null)return{};var n,r,i=uhe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function uhe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var D0=(0,L.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=bE(lhe(e,che));return c?L.createElement(L.Fragment,null,L.createElement($M,{width:n,height:r}),L.createElement(b0,{otherAttributes:d,title:l,desc:u},a)):L.createElement(she,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},L.createElement(b0,{otherAttributes:d,title:l,desc:u,ref:t},L.createElement(yde,null,a)))});function O0(){return O0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},O0.apply(null,arguments)}function k0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function dhe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?k0(Object(n),!0).forEach(function(t){fhe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function fhe(e,t,n){return(t=phe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function phe(e){var t=mhe(e,`string`);return typeof t==`symbol`?t:t+``}function mhe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var hhe=dhe({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},d0),A0=(0,L.forwardRef)(function(e,t){var n=TO(e.categoricalChartProps,hhe),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return L.createElement(p0,{preloadedState:{options:c},reduxStoreName:s.id??r},L.createElement(d$,{chartData:s.data}),L.createElement(m0,{layout:n.layout,margin:n.margin}),L.createElement(g0,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),L.createElement(h0,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),L.createElement(D0,O0({},n,{ref:t})))}),ghe=[`axis`],_he=(0,L.forwardRef)((e,t)=>L.createElement(A0,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:ghe,tooltipPayloadSearcher:bq,categoricalChartProps:e,ref:t})),vhe=[`axis`,`item`],j0=(0,L.forwardRef)((e,t)=>L.createElement(A0,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:vhe,tooltipPayloadSearcher:bq,categoricalChartProps:e,ref:t}));function yhe(e){var t=Vk();return(0,L.useEffect)(()=>{t(Dme(e))},[t,e]),null}var bhe=[`layout`];function M0(){return M0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},M0.apply(null,arguments)}function xhe(e,t){if(e==null)return{};var n,r,i=She(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function She(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function N0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Che(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?N0(Object(n),!0).forEach(function(t){whe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):N0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function whe(e,t,n){return(t=The(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function The(e){var t=Ehe(e,`string`);return typeof t==`symbol`?t:t+``}function Ehe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var P0=Che({accessibilityLayer:!0,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`,layout:`radial`,responsive:!1,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`},d0),Dhe=(0,L.forwardRef)(function(e,t){var n=TO(e.categoricalChartProps,P0),r=n.layout,i=xhe(n,bhe),a=e.chartName,o={chartName:a,defaultTooltipEventType:e.defaultTooltipEventType,validateTooltipEventTypes:e.validateTooltipEventTypes,tooltipPayloadSearcher:e.tooltipPayloadSearcher,eventEmitter:void 0};return L.createElement(p0,{preloadedState:{options:o},reduxStoreName:n.id??a},L.createElement(d$,{chartData:n.data}),L.createElement(m0,{layout:r,margin:n.margin}),L.createElement(g0,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),L.createElement(h0,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),L.createElement(yhe,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),L.createElement(D0,M0({},i,{ref:t})))});function F0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function I0(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?F0(Object(n),!0).forEach(function(t){Ohe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):F0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ohe(e,t,n){return(t=khe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function khe(e){var t=Ahe(e,`string`);return typeof t==`symbol`?t:t+``}function Ahe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var jhe=[`item`],Mhe=I0(I0({},P0),{},{layout:`centric`,startAngle:0,endAngle:360}),Nhe=(0,L.forwardRef)((e,t)=>{var n=TO(e,Mhe);return L.createElement(Dhe,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:jhe,tooltipPayloadSearcher:bq,categoricalChartProps:n,ref:t})}),L0=`flex items-center gap-2 rounded-md px-1 py-0.5`,R0=({resource:e,view:t,filter:n,color:r,label:i,children:a})=>{let o=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`size-2.5 shrink-0 rounded-full`,style:{background:r},"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate group-hover:text-primary-text`,children:i}),a]});return(0,z.jsx)(`li`,{children:n===void 0?(0,z.jsx)(`div`,{className:L0,children:o}):(0,z.jsx)(jS,{to:dE(t,e,n),className:`group ${L0} hover:bg-muted`,children:o})})},Phe=(e,t)=>t>0?`${Math.round(e/t*100)}%`:``,Fhe=({active:e,payload:t,measure:n})=>{let r=t?.[0]?.payload;return!e||!r?null:(0,z.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:r.label}),(0,z.jsx)(`div`,{className:`font-semibold tabular-nums`,children:uE(r.value,n)})]})},Ihe=({resource:e,view:t,slices:n,measure:r})=>{let i=n.filter(e=>e.value!==null&&e.value>0),a=i.reduce((e,t)=>e+t.value,0);return(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-4 sm:flex-row sm:items-center`,children:[(0,z.jsx)(`div`,{className:`size-36 shrink-0`,children:(0,z.jsx)(WM,{width:`100%`,height:`100%`,children:(0,z.jsxs)(Nhe,{children:[(0,z.jsx)(xQ,{data:i,dataKey:`value`,nameKey:`label`,innerRadius:`62%`,outerRadius:`100%`,paddingAngle:+(i.length>1),stroke:`var(--background)`,strokeWidth:2,isAnimationActive:!1,children:i.map(e=>(0,z.jsx)(iJ,{fill:e.color},e.key))}),(0,z.jsx)(rJ,{content:(0,z.jsx)(Fhe,{measure:r}),isAnimationActive:!1})]})})}),(0,z.jsx)(`ul`,{className:`flex w-full min-w-0 flex-col gap-0.5`,children:n.map(n=>(0,z.jsxs)(R0,{resource:e,view:t,filter:n.filter,color:n.color,label:n.label,children:[(0,z.jsx)(`span`,{className:`font-medium tabular-nums`,children:uE(n.value,r)}),(0,z.jsx)(`span`,{className:`w-9 text-right text-xs text-muted-foreground tabular-nums`,children:Phe(n.value??0,a)})]},n.key))})]})},z0={hour:`2-digit`,minute:`2-digit`,hour12:!1},B0={day:`numeric`,month:`short`,...z0},Lhe={minute:z0,"5_minutes":z0,"15_minutes":z0,hour:z0,day:{day:`numeric`,month:`short`},week:{day:`numeric`,month:`short`},month:{month:`short`,year:`2-digit`},year:{year:`numeric`}},V0={minute:B0,"5_minutes":B0,"15_minutes":B0,hour:B0,day:{day:`numeric`,month:`short`,year:`numeric`},week:{day:`numeric`,month:`short`,year:`numeric`},month:{month:`long`,year:`numeric`},year:{year:`numeric`}},H0=e=>{let t=new Intl.DateTimeFormat(l(),{...e,timeZone:`UTC`});return e=>t.format(e)},U0={fontSize:11,fill:`var(--muted-foreground)`},Rhe=864e5,zhe=new Set([`minute`,`5_minutes`,`15_minutes`,`hour`]),Bhe=(e,t)=>{let n=t.length>1?t.at(-1).at-t[0].at:0;return zhe.has(e)&&n>=Rhe?B0:Lhe[e]},Vhe=({active:e,payload:t,measure:n,bucket:r,series:i})=>{let a=t?.[0]?.payload;return!e||!a?null:(0,z.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:r===`week`?tE(`weekOf`,H0(V0[r])(a.at)):H0(V0[r])(a.at)}),i?.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{background:e.color},"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`flex-1`,children:e.label}),(0,z.jsx)(`span`,{className:`font-semibold tabular-nums`,children:uE(a[e.key]??null,e.measure??n)})]},e.key)),i&&(n.kind===`count`||n.kind===`sum`)&&(0,z.jsx)(`div`,{className:`mt-0.5 border-t pt-0.5 font-semibold tabular-nums`,children:uE(a.value,n)}),!i&&(0,z.jsx)(`div`,{className:`font-semibold tabular-nums`,children:uE(a.value,n)})]})},W0=({points:e,measure:t,bucket:n,type:r,series:i,resource:a,view:o})=>{let s=ju(`(min-width: 640px)`),c=H0(Bhe(n,e)),u=(0,z.jsx)(B$,{vertical:!1,stroke:`var(--border)`}),d=(0,z.jsx)(O1,{dataKey:`at`,tickFormatter:c,tick:U0,axisLine:!1,tickLine:!1,minTickGap:s?24:40,height:18}),f=(0,z.jsx)(N1,{width:s?48:36,tick:U0,axisLine:!1,tickLine:!1,tickCount:3,tickFormatter:e=>e.toLocaleString(l(),{notation:`compact`})}),p=(0,z.jsx)(rJ,{cursor:r===`bar`?{fill:`var(--muted)`}:{stroke:`var(--border-strong)`},content:(0,z.jsx)(Vhe,{measure:t,bucket:n,...i&&{series:i}}),isAnimationActive:!1}),m=i??[{key:`value`,label:``,color:`var(--chart-1)`}],h=(0,z.jsx)(`div`,{className:`h-40`,children:(0,z.jsx)(WM,{width:`100%`,height:`100%`,children:r===`line`?(0,z.jsxs)(_he,{data:e,margin:{top:6,right:6,bottom:0,left:0},children:[u,d,f,p,m.map(t=>(0,z.jsx)(r1,{dataKey:t.key,stroke:t.color,strokeWidth:2,dot:e.length<=31&&{r:3,fill:t.color,strokeWidth:0},activeDot:{r:4,stroke:`var(--background)`,strokeWidth:2},isAnimationActive:!1},t.key))]}):(0,z.jsxs)(j0,{data:e,margin:{top:6,right:0,bottom:0,left:0},barCategoryGap:`22%`,children:[u,d,f,p,m.map((e,t)=>(0,z.jsx)(b1,{dataKey:e.key,fill:e.color,...i&&{stackId:`split`},radius:t===m.length-1?[4,4,0,0]:0,isAnimationActive:!1},e.key))]})})});return!i||a===void 0?h:(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h,(0,z.jsx)(`ul`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-sm`,children:i.map(e=>(0,z.jsx)(R0,{resource:a,view:o,color:e.color,label:e.label,...e.filter!==void 0&&{filter:e.filter}},e.key))})]})},Hhe=1e-6,Uhe=(e,t,n,r,i,a=``)=>{let o=t.map((e,t)=>({key:`s${t}`,label:aE(n,r,e),color:iE(n,r,e.value,t),filter:oE(n,e.value,a)})),s=i.kind===`count`?0:null,c=(e,t)=>{let n=e.splits?.find(e=>e.value===t);return n?i.kind===`count`?n.count:n[i.kind]??null:s},l=lE(e,i).map((n,r)=>{let a=e[r],o=t.map(e=>c(a,e.value)),s=Object.fromEntries(o.map((e,t)=>[`s${t}`,e]));if(i.kind===`average`)return{...n,...s};let l=n.value===null?null:n.value-o.reduce((e,t)=>e+(t??0),0);return{...n,...s,other:l===null?null:l<Hhe?0:l}});return i.kind!==`average`&&l.some(e=>(e.other??0)>0)?{series:[...o,{key:`other`,label:tE(`other`),color:`var(--border-strong)`}],points:l}:{series:o,points:l.map(({other:e,...t})=>t)}},Whe=(e,t,n,r)=>{let i=n??r,a=i===void 0?void 0:e.fields[i];return!a||i===void 0?{kind:`count`}:{kind:n===void 0?`average`:`sum`,field:a,hints:t?.fields[i]}},G0=(e,t,n)=>{let r=e?.type===`relation`&&e.relation?t[e.relation.resource]:void 0;return r&&r.primaryKey.length===1?Vx(r,n[r.name]):void 0},K0=({model:e,view:t,groupBy:n,splitBy:r,type:i=`bar`,sum:a,average:o,filter:s=``,granularity:c=`day`,range:l=`30d`,limit:u=10,empty:d=tE(`nothingYet`)})=>{let{resources:f,views:p}=G(),m=e.fields[n],h=m?.type===`date`||m?.type===`timestamp`,g=G0(m,f,p),_=h&&r!==void 0?e.fields[r]:void 0,v=G0(_,f,p),y=_?{splitBy:_.name,splitLimit:8,...v&&{splitLabel:v}}:{},b=h?{granularity:c,range:l,timeZone:If(),...y}:{limit:u,...g&&{label:g}},x=$T(e.name,{groupBy:n,filter:s,...a&&{sum:a},...o&&{average:o},...b},!!m),S=Whe(e,t,a,o);if(!m)return null;if(x.isPending)return(0,z.jsx)(Yu,{className:`h-36 w-full`});if(x.error)return(0,z.jsx)(`p`,{className:`text-danger-text`,children:tE(`couldNotLoad`)});let{groups:C}=x.data;if(C.every(e=>e.count===0))return(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:d});let w=i===`line`?`line`:`bar`;if(h&&_&&x.data.splits){let{series:n,points:r}=Uhe(C,x.data.splits,_,t?.fields[_.name],S,s);return(0,z.jsx)(W0,{points:r,measure:S,bucket:c,type:w,series:n,resource:e.name,view:t})}if(h)return(0,z.jsx)(W0,{points:lE(C,S),measure:S,bucket:c,type:w});let T=cE(C,m,t?.fields[n],S,s);return i===`donut`?(0,z.jsx)(Ihe,{resource:e.name,view:t,slices:T,measure:S}):(0,z.jsx)(fE,{resource:e.name,view:t,slices:T,measure:S})},Ghe=({node:e,slots:t})=>{let{resource:n,title:r,description:i,actions:a,span:o,...s}=HT(e),{resources:c,views:l}=G(),u=c[n];return u?(0,z.jsx)(GT,{title:r,description:i,actions:t.actions,className:`h-full`,children:(0,z.jsx)(K0,{model:u,view:l[n],...s})}):null},Khe=Vn(),q0=async(e,t,n,r,i)=>{let a=n.primaryKey[0],o=[...new Set(r)].sort();if(o.length===0||n.primaryKey.length!==1)return new Map;let s=Vx(n,i),c=await e.fetchQuery({queryKey:U.labels(n.name,o.join(`,`)),staleTime:3e5,queryFn:async()=>(await t.list(n.name,{filter:Fn(Khe.in(a,o)),fields:[a,s],pageSize:o.length})).items.map(e=>[String(e[a]),String(e[s])])});return new Map(c)},J0=(e,t,n)=>n.flatMap(n=>{let r=t.fields[n],i=r?.type===`relation`&&r.relation?e[r.relation.resource]:void 0;return i?[{name:n,target:i}]:[]}),Y0=(e,t,n,r)=>Object.fromEntries(J0(e,n,r).filter(({target:e})=>e.primaryKey.length===1).map(({name:e,target:n})=>[e,Vx(n,t[n.name])])),X0=(e,t,n,r,i={})=>{let a=J0(e,t,n);return r.map(e=>{let t={...e};for(let{name:n}of a)e[n]!=null&&(t[n]={id:e[n],name:i[n]?.[String(e[n])]??String(e[n])});return t})},Z0=(e,t)=>{let n=String(t);return e&&Object.hasOwn(e,n)?e[n]:void 0},Q0=({value:e,hints:t,children:n})=>(0,z.jsx)(_d,{tone:Qx(String(e)),color:Z0(t?.valueColors,e),shape:t?.badgeShape,children:n}),qhe=({field:e,value:t,known:n})=>{let{resources:r,views:i}=G(),a=W(),o=Km(),s=e.relation?r[e.relation.resource]:void 0,c=String(t),l=Kh({queryKey:U.relatedLabel(s?.name??``,c),enabled:!!s&&n===void 0,queryFn:async()=>(await q0(o,a,s,[c],i[s.name])).get(c)??c});return s?(0,z.jsx)(jS,{to:{kind:`record`,resource:s.name,key:c},className:`font-medium text-primary-text hover:underline`,children:n??l.data??c}):(0,z.jsx)(`span`,{children:c})},Jhe=({model:e,field:t,value:n,format:r,relationLabel:i})=>{let{views:a}=G(),o={...a[e.name]?.fields[t.name],...r&&{format:r}};if(n==null||n===``)return(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});if(t.type===`relation`)return(0,z.jsx)(qhe,{field:t,value:n,known:i});let s=t.type===`file`?rx(n):void 0;if(s&&`url`in s&&s.url){let e=dx(n,{width:40,height:40});return(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[e&&(0,z.jsx)(fC,{image:e,className:`size-10 shrink-0 rounded border border-border object-cover`}),(0,z.jsx)(`a`,{href:s.url,target:`_blank`,rel:`noreferrer`,className:`truncate font-medium text-primary-text hover:underline`,children:s.name})]})}if(zx(t,o))return(0,z.jsx)(yC,{source:String(n)});let c=rS(t,n,o),l=t.type===`text`?Jx(o):void 0;return l?(0,z.jsx)(xC,{format:l,value:c}):t.type===`enum`||o.format===`badge`?(0,z.jsx)(Q0,{value:n,hints:o,children:c}):(0,z.jsx)(`span`,{title:iS(t,n,void 0,o),className:g(o.format===`code`&&`font-mono text-xs`,(t.type===`decimal`||t.type===`integer`)&&`tabular-nums`,o.multiline&&`whitespace-pre-line break-words`),children:c})},$0=e=>{let{views:t}=G(),n=_C(e.field,t[e.model.name]?.fields[e.field.name]),r=(0,z.jsx)(Jhe,{...e});return n?(0,z.jsx)(vC,{shown:n,part:`display`,field:e.field,value:e.value,fallback:r}):r},e2=(e,t,n)=>{if(!t)return[];let r=Sc(e,t.model.name,n);return r.ok?r.steps:[]},t2=(e,t,n,r,i)=>({queryKey:U.pathValue(n?.model.name??``,n?.key??``,r),enabled:i.length>1,queryFn:async()=>{let r=n.record;for(let n of i.slice(0,-1)){let i=r[n.field.name];if(i==null)return null;let a=n.field.relation.resource;r=(await t.fetchQuery({queryKey:U.record(a,String(i)),queryFn:()=>e.get(a,String(i))})).record}return r[i.at(-1).field.name]??null}}),n2=(e,t,n)=>{let r=t.at(-1);return!e||!r?{state:`missing`}:t.length===1?{state:`ready`,value:e.record[r.field.name],field:r.field,model:r.model}:n.isPending?{state:`loading`}:{state:`ready`,value:n.data??null,field:r.field,model:r.model}},r2=(e,t)=>{let{resources:n}=G(),r=e2(n,e,t);return n2(e,r,Kh(t2(W(),Km(),e,t,r)))},Yhe=(e,t)=>{let{resources:n}=G(),r=W(),i=Km(),a=t.map(t=>e2(n,e,t)),o=Wh({queries:t.map((t,n)=>t2(r,i,e,t,a[n]))});return t.map((t,n)=>n2(e,a[n],o[n]))},i2=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>q(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},Xhe=({node:e})=>{let{name:t,label:n,format:r}=HT(e),{views:i}=G(),a=r2(bT(),t);if(a.state===`missing`)return null;let o=a.state===`loading`?(0,z.jsx)(Yu,{className:`h-4 w-24`}):(0,z.jsx)($0,{model:a.model,field:a.field,value:a.value,format:r});if(n===!1)return(0,z.jsx)(`div`,{children:o});let s=n??i2(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-body text-muted-foreground`,children:s}),(0,z.jsx)(`div`,{className:`mt-0.5 truncate`,children:o})]})},Zhe={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},Qhe={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},$he={1:``,2:`md:col-span-2`,3:`md:col-span-2 xl:col-span-3`,4:`sm:col-span-2 md:col-span-2 xl:col-span-4`},ege=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,tge=({node:e,children:t})=>{let{columns:n=2}=HT(e),r=e.children,i=r.length>0&&r.every(ege);return(0,z.jsx)(`div`,{className:g(`grid grid-cols-1 gap-4`,i?Qhe[n]:Zhe[n]),children:t.map((e,t)=>{let n=r[t],i=typeof n==`object`?n.props.span:void 0;return(0,z.jsx)(`div`,{className:g(`min-w-0`,i&&$he[i]),children:e},t)})})},a2=`font-medium text-primary-text hover:underline`,nge=({node:e})=>{let t=HT(e),n=bT()?.record,r=e.children.filter(e=>typeof e==`string`).join(``);if(t.to){let e=Kn(t.to,n);return(0,z.jsx)(jS,{to:e,className:a2,children:r||Cs(e)})}let i=t.href??``;return(0,z.jsx)(`a`,{href:i,className:a2,...i.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:r||i})},rge=(e,t,n)=>Object.fromEntries(t.map(t=>{let r=e.fields[t];if(r.type===`file`)return[t,n?.record[t]??null];if(n)return[t,r.type===`boolean`?!!n.record[t]:zS(n.record[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:zS(i)]})),ige=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return XS(r)?r.key===zS(n.record[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:GS(i,r,n.record[t])?[[t,HS(i,r)]]:[]})),age=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=G(),u=W(),d=Hb(),f=RT(),p=l[e.name],[m,h]=(0,L.useState)(()=>rge(e,a,t)),[g,_]=(0,L.useState)({}),[v,y]=(0,L.useState)(0),b=MC(v),[x,S]=(0,L.useState)(),[C,w]=(0,L.useState)(!1),T=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...QS(e,c,m),...o}):u.update(e.name,t.key,ige(e,m,t),t.etag??`*`)).then(async()=>{await f(e.name),d.show({state:`success`,title:Ig(`saved`,i??r)}),s()},e=>{let t=AC(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,z.jsx)(_p,{title:i??r,onClose:s,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:s,children:Ig(`cancel`)}),(0,z.jsx)(V,{variant:`primary`,loading:C,onClick:()=>void T(),children:Ig(n===`create`?`create`:`save`)})]}),children:(0,z.jsxs)(`form`,{ref:b,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),T()},children:[x!==void 0&&Object.keys(g).length===0&&(0,z.jsx)(rC,{title:Ig(`notSaved`),error:x}),a.map(n=>{let r=e.fields[n],i=m[n],a=r.relation?c[r.relation.resource]:void 0,o=p?.fields[n]?.label??q(n),s=g[n];return(0,z.jsx)(Gb,{name:n,label:o,help:p?.fields[n]?.help,error:s&&kC(r,o,s),children:(0,z.jsx)(SC,{field:r,hints:p?.fields[n],value:XS(i)?i.key:i,stored:t?.record[n],relationLabel:XS(i)?i.label:void 0,relationPicker:a?{target:a,view:l[a.name]}:void 0,invalid:!!g[n],resource:e.name,onChange:e=>{_(({[n]:e,...t})=>t),h(t=>({...t,[n]:e}))}})},n)})]})})},oge=({model:e,recordKey:t,children:n})=>{let r=IT(e,{key:t});return(0,z.jsx)(z.Fragment,{children:n(r.data??void 0)})},sge=({node:e})=>{let t=HT(e),n=bT(),{resources:r}=G(),i=r[t.resource??n?.model.name??``],a=cg(i?.name??``),[o,s]=(0,L.useState)(!1);if(!i||!(t.mode===`create`?xT(a,`create`):xT(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,z.jsx)(age,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,z.jsx)(oge,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},cge=({node:e,children:t,slots:n})=>{let{title:r,description:i}=HT(e);return(0,z.jsx)(`div`,{className:`flex-1`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-[1200px] flex-col gap-6 px-4 pb-16 pt-6 md:px-10 md:py-8`,children:[(0,z.jsx)(ef,{title:r,subtitle:i,actions:n.actions}),t]})})},o2=(e,t)=>{let n=bT(),r=r2(typeof e==`string`?n:void 0,typeof e==`string`?e:``);return typeof e==`number`?e:e===void 0?t:r.state===`ready`?Number(r.value):r.state===`loading`?void 0:NaN},lge=({node:e})=>{let{value:t,max:n,label:r}=HT(e),i=o2(t,0),a=o2(n,100);if(i===void 0||a===void 0)return(0,z.jsx)(Yu,{className:`h-6 w-full`});if(!Number.isFinite(i)||!Number.isFinite(a))return null;let o=a>0?Math.min(1,Math.max(0,i/a)):0;return(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:r}),(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[i.toLocaleString(l()),` / `,a.toLocaleString(l())]})]}),(0,z.jsx)(`div`,{role:`progressbar`,"aria-label":r,"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":a,className:`mt-1.5 h-2 overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{className:o>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${o*100}%`}})})]})},uge=({model:e,filter:t,sort:n,recordKey:r,title:i,description:a,empty:o,actions:s,children:c})=>{let l=IT(e,{filter:t,sort:n,key:r}),u=e=>l.data?(0,z.jsx)(yT,{value:l.data,children:e}):void 0,d=l.isPending?(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(Yu,{className:`h-4 w-1/2`}),(0,z.jsx)(Yu,{className:`h-4 w-1/3`})]}):l.error?(0,z.jsx)(rC,{title:Ig(`couldNotLoad`),error:l.error}):l.data?u((0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:c})):(0,z.jsx)(KT,{children:o??Ig(`nothingYet`)});return(0,z.jsx)(GT,{title:i,description:a,actions:s?u(s):void 0,className:`h-full`,children:d})},dge=({node:e,children:t,slots:n})=>{let{resource:r,filter:i,sort:a,recordKey:o,title:s,description:c,empty:l}=HT(e),u=G().resources[r];return u?(0,z.jsx)(uge,{model:u,filter:i,sort:a,recordKey:o,title:s,description:c,empty:l,actions:n.actions,children:t}):null},s2=a({en:{firstOf:(e,t)=>`The first ${e} of ${t}.`,firstOfAbout:(e,t)=>`The first ${e} of about ${t}.`,open:e=>`Open ${e}`,edit:e=>`Edit ${e}`,viewAll:`View all`,couldNotLoad:`Could not load`,nothingYet:`Nothing here yet.`},nl:{firstOf:(e,t)=>`De eerste ${e} van ${t}.`,firstOfAbout:(e,t)=>`De eerste ${e} van ongeveer ${t}.`,open:e=>`${e} openen`,edit:e=>`${e} bewerken`,viewAll:`Alles bekijken`,couldNotLoad:`Kon niet laden`,nothingYet:`Hier staat nog niets.`}}),c2=(e,t,n)=>{if(!(e>=t))return s2(n?`firstOfAbout`:`firstOf`,e,t.toLocaleString(l()))},fge=`protobase:embedded-display:`,pge=e=>`${fge}${e}`,mge=(e,t)=>u(()=>e.getItem(t)??void 0,void 0),hge=(e,t,n)=>u(()=>e.setItem(t,n),void 0),l2=(e,t,{picked:n,preferred:r})=>{let i=_S(e).map(e=>e.name);return n!==void 0&&i.includes(n)?n:pS(e,t,r!==void 0&&i.includes(r)?r:void 0)},u2=(e,t,n,{resource:r=e.name,...i})=>kS({kind:`list`,resource:r},i,{...OS(e,t,n),display:pS(t,n)}),d2=a({en:{showMore:`Show more`,showLess:`Show less`,couldNotLoad:`Could not load`,nothingYet:`Nothing here yet.`},nl:{showMore:`Meer tonen`,showLess:`Minder tonen`,couldNotLoad:`Kon niet laden`,nothingYet:`Hier staat nog niets.`}}),gge=({children:e})=>{let t=(0,L.useRef)(null),[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(!1);return(0,L.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=()=>a(e.scrollHeight>e.parentElement.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[n]),(0,z.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,z.jsx)(`div`,{className:g(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,z.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,z.jsx)(V,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:d2(n?`showLess`:`showMore`)})]})},_ge=e=>e==null||e===``,vge=({scope:e,path:t})=>{let{views:n}=G(),r=r2(e,t);if(r.state===`missing`||r.state===`ready`&&_ge(r.value))return null;let i=i2(t,r.state===`ready`?n[r.model.name]?.fields[r.field.name]?.label:void 0);return(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:i}),(0,z.jsx)(`dd`,{className:`mt-0.5`,children:r.state===`loading`?(0,z.jsx)(Yu,{className:`h-4 w-24`}):(0,z.jsx)(gge,{children:(0,z.jsx)($0,{model:r.model,field:r.field,value:r.value})})})]})},yge=({scope:e,view:t,fields:n,actions:r})=>(0,z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[(0,z.jsx)(jS,{to:{kind:`record`,resource:e.model.name,key:Kx(e.model,e.record)},className:`self-start font-medium text-primary-text hover:underline`,children:Ux(e.model,t,e.record,e.key)}),n.length>0&&(0,z.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,z.jsx)(vge,{scope:e,path:t},t))}),r.length>0&&(0,z.jsx)(yT,{value:e,children:(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:r.map(e=>(0,z.jsx)(UT,{name:e},e))})})]}),f2=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,limit:o,display:s,empty:c})=>{let l=Nu(),u=r||wS(e,t),d=LT(e,{filter:n,sort:u,pageSize:o}),f=FT(e,n);if(d.isPending)return(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:2},(e,t)=>(0,z.jsx)(Yu,{className:`h-24 w-full`},t))});if(d.error)return(0,z.jsx)(rC,{title:d2(`couldNotLoad`),error:d.error});let p=d.data.items;if(p.length===0)return(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:c??d2(`nothingYet`)});let m=f.data===void 0?void 0:c2(p.length,f.data,!1);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,z.jsx)(`ul`,{className:`flex flex-col gap-3`,children:p.map(n=>{let r=NT(e,n);return(0,z.jsx)(yge,{scope:r,view:t,fields:i,actions:a},r.key)})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m}),(0,z.jsxs)(jS,{to:u2(e,t,l,{filter:n,orderBy:u,display:l2(t,l,{preferred:s})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[s2(`viewAll`),` `,(0,z.jsx)(`span`,{className:`sr-only`,children:(t?.names?.plural??q(e.name)).toLowerCase()}),(0,z.jsx)(Vr,{className:`size-3.5`,"aria-hidden":!0})]})]})]})},bge=({node:e,slots:t})=>{let{resource:n,filter:r=``,sort:i=``,fields:a,cardActions:o=[],limit:s=10,display:c,title:l,description:u,empty:d}=HT(e),{resources:f,views:p}=G(),m=f[n];if(!m)return null;let h=p[m.name];return(0,z.jsx)(`section`,{className:`min-w-0`,"aria-label":l,children:(0,z.jsx)(Kb,{title:l,help:u,actions:t.actions,children:(0,z.jsx)(f2,{model:m,view:h,filter:r,sort:i,fields:a??eS(m,h),actions:o,limit:s,display:c,empty:d})})})};function xge(e){return Sge(e)||typeof e==`function`||Cge(e)}function Sge(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Cge(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function p2(e,t){return e==null?null:xge(e)?L.createElement(e,t):e}function wge(e){if(`cell`in e&&e.cell){let t=e.cell,n=t.column.columnDef,r=t,i=n;return r.getIsAggregated?.()?p2(i.aggregatedCell??n.cell,t.getContext()):r.getIsPlaceholder?.()?null:p2(n.cell,t.getContext())}return`header`in e&&e.header?p2(e.header.column.columnDef.header,e.header.getContext()):`footer`in e&&e.footer?p2(e.footer.column.columnDef.footer,e.footer.getContext()):null}function Tge({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(1)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(1)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function Ege(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var m2=[],h2=0,{link:g2,unlink:Dge,propagate:Oge,checkDirty:_2,shallowPropagate:v2}=Tge({update(e){return e._update()},notify(e){m2[b2++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,C2(e))}}),y2=0,b2=0,x2,S2=0;function kge(e){try{++S2,e()}finally{--S2||w2()}}function C2(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Dge(n,e)}function w2(){if(!(S2>0)){for(;y2<b2;){let e=m2[y2];m2[y2++]=void 0,e.notify()}y2=0,b2=0}}function Age(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return x2!==void 0&&g2(i,x2,h2),i._snapshot},subscribe(e){let t=Ege(e),n={current:!1},r=jge(()=>{i.get(),n.current?(x2=void 0,t.next?.(i._snapshot)):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=x2,o=t?.compare??Object.is;if(n)x2=i,++h2,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{x2=a,n&&(i.flags&=-5),C2(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&_2(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&v2(e)}}else e&32&&(i.flags=e&-33);return x2!==void 0&&g2(i,x2,h2),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Oge(e),v2(e),w2())}},i}function jge(e){let t=()=>{let t=x2;x2=n,++h2,n.depsTail=void 0,n.flags=6;try{return e()}finally{x2=t,n.flags&=-5,C2(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&_2(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,C2(this)}};return t(),n}function T2(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=E2(e);if(n.length!==E2(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}function E2(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function Mge(e,t){return e===t}function D2(e,t=e=>e,n){let r=n?.compare??Mge,i=(0,L.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,L.useCallback)(()=>e.get(),[e]);return(0,zk.useSyncExternalStoreWithSelector)(i,a,a,t,r)}function Nge(e){let t=D2(e.source,e.selector,{compare:T2});return typeof e.children==`function`?e.children(t):e.children}function Pge(e){let t=e;return Object.defineProperty(e,"state",{get(){return e.get()}}),`set`in e&&(t.setState=e.set.bind(e)),t}function Fge(e){let{createAtom:t,batch:n}=e,r=t(0);return{createOptionsStore:!1,wrapExternalAtoms:!1,addSubscription:()=>{throw Error(`Feature not supported in current reactivity implementation`)},unmount:()=>{throw Error(`Feature not supported in current reactivity implementation`)},schedule:e.schedule??(e=>queueMicrotask(e)),batch:n,untrack:e=>e(),createReadonlyAtom:(e,n)=>{let i=n?.compare??Object.is,a=!1,o,s=()=>{let t=e();return(!a||!i(o,t))&&(o=t,a=!0),o},c=t(()=>(r.get(),s()),{compare:i});return{get:s,subscribe:c.subscribe.bind(c)}},createWritableAtom:(e,n)=>t(e,{compare:n?.compare}),commit:()=>{r.set(e=>e+1)}}}function Ige(e,t=Object.is){let n=!1,r;return{get:e.get,markCommitted:e=>{r=e,n=!0},subscribe:i=>e.subscribe(e=>{(!n||!t(r,e))&&i(e)})}}function Lge(){return Fge({createAtom:Age,batch:kge})}function O2(e,t){return typeof e==`function`?e(t):e}function k2(e){if(Array.isArray(e))return e.map(k2);if(e&&typeof e==`object`){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=t===null?A2():{},r=Object.keys(e);for(let t=0;t<r.length;t++){let i=r[t];Object.defineProperty(n,i,{configurable:!0,enumerable:!0,value:k2(e[i]),writable:!0})}return n}return e}function Rge(e,t){let n=Object.keys(t),r=e;for(let e=0;e<n.length;e++){let i=n[e];!i.startsWith(`_memo_`)&&i!==`_cellsCache`&&(r[i]=t[i])}return e}function A2(){return Object.create(null)}function j2(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function M2(e,t){return n=>{(t.options.atoms?.[e]??t.baseAtoms[e]).set(e=>O2(n,e))}}function N2(e){if(typeof e!=`object`||!e)return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function P2(e){return Reflect.ownKeys(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}var zge=3;function Bge(e,t){return F2(e,t,zge)}function F2(e,t,n){if(Object.is(e,t))return!0;if(n<=0||!N2(e)||!N2(t)||(Array.isArray(e)||Array.isArray(t))&&(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length))return!1;let r=P2(e),i=P2(t);if(r.length!==i.length)return!1;let a=e,o=t;for(let e=0;e<r.length;e++){let i=r[e];if(!Object.prototype.propertyIsEnumerable.call(t,i)||!F2(a[i],o[i],n-1))return!1}return!0}function I2(e,t,n,r=Bge){let i=`on${t.charAt(0).toUpperCase()}${t.slice(1)}Change`,a=e.options[i];a&&a(e=>{let t=O2(n,e);return r(e,t)?e:t})}function Vge(e){return e instanceof Function}function Hge(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i.length&&r(i)})};return r(e),n}var Uge=({fn:e,memoDeps:t,onAfterCompare:n,onAfterUpdate:r,onBeforeCompare:i,onBeforeUpdate:a})=>{let o=[],s;return c=>{i?.();let l=t?.(c),u=!l||l.length!==o?.length;if(!u&&l){for(let e=0;e<l.length;e++)if(l[e]!==o[e]){u=!0;break}}return n?.(u),u?(o=l,a?.(),s=e(...l??[]),r?.(s),s):s}};function Wge(e){let t=!1;return()=>{if(!t){t=!0;return}e()}}function L2({feature:e,fnName:t,objectId:n,onAfterUpdate:r,table:i,...a}){let o=()=>{if(!r)return;let{schedule:e,untrack:t}=i._reactivity;e(()=>t(()=>r()))},s={onAfterUpdate:()=>{o()}};return Uge({...a,...s})}function R2(e,t=`_`){let[n,r]=e.split(t);return{fnKey:r,fnName:`${n}.${r}`,parentName:n}}function z2(e,t,n){for(let[r,{fn:i,memoDeps:a}]of Object.entries(n)){let{fnKey:n,fnName:o}=R2(r);t[n]=a?L2({memoDeps:a,fn:i,fnName:o,table:t,feature:e}):i}}function B2(e,t,n,r){for(let[i,{fn:a,memoDeps:o}]of Object.entries(r)){let{fnKey:r,fnName:s}=R2(i);if(o){let i=`_memo_${r}`;t[r]=function(...t){if(!this[i]){let t=this;this[i]=L2({memoDeps:e=>o(t,e),fn:(...e)=>a(t,...e),fnName:s,objectId:t.id,table:n,feature:e})}return this[i](...t)}}else t[r]=function(...e){return a(this,...e)}}}function V2(e,t,n,...r){return e[t]?.(...r)??n(e,...r)}function Gge(e){return e.row.getValue(e.column.id)}function Kge(e){return e.getValue()??e.table.options.renderFallbackValue}function qge(e){return{table:e.table,column:e.column,row:e.row,cell:e,getValue:()=>e.getValue(),renderValue:()=>e.renderValue()}}var Jge={assignCellPrototype:(e,t)=>{B2(`coreCellsFeature`,e,t,{cell_getValue:{fn:e=>Gge(e)},cell_renderValue:{fn:e=>Kge(e)},cell_getContext:{fn:e=>qge(e),memoDeps:e=>[e]}})}};function Yge(e){if(!e._headerPrototype){e._headerPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignHeaderPrototype?.(e._headerPrototype,e)}return e._headerPrototype}function H2(e,t,n){let r=Yge(e),i=Object.create(r);i.colSpan=0,i.column=t,i.depth=n.depth,i.headerGroup=null,i.id=n.id??t.id,i.index=n.index,i.isPlaceholder=!!n.isPlaceholder,i.placeholderId=n.placeholderId,i.rowSpan=0,i.subHeaders=[];let a=e._headerInstanceInitFns;for(let e=0;e<a.length;e++)a[e](i);return i}function Xge(){return{start:[],end:[]}}function U2(e){let t=e.table.atoms.columnVisibility?.get();if(!t)return!0;let n=e.columns;return n.length?n.some(e=>V2(e,`getIsVisible`,U2)):(j2(t,e.id)?t[e.id]:void 0)??!0}function Zge(e){return e.getAllLeafColumns().filter(e=>V2(e,`getIsVisible`,U2))}function W2(e,t=1){let n=t;for(let r=0;r<e.length;r++){let i=e[r];V2(i,`getIsVisible`,U2)&&i.columns.length&&(n=Math.max(n,W2(i.columns,t+1)))}return n}function Qge(e,t){return e?`${e}_${t}`:String(t)}function $ge(e,t,n,r){let i=e??``;return t&&(i=i?`${i}_${t}`:String(t)),n&&(i=i?`${i}_${n}`:n),r&&(i=i?`${i}_${r}`:r),i}function e_e(e,t){let n=0;for(let r=0;r<e.length;r++)e[r].column===t&&n++;return n}function G2(e,t,n,r,i,a){let o={depth:t,id:Qge(r,t),headers:[]},s=[];for(let i=0;i<e.length;i++){if(!(i in e))continue;let a=e[i],c=s[s.length-1],l=a.column.depth===o.depth,u,d=!1;if(l&&a.column.parent?u=a.column.parent:(u=a.column,d=!0),c&&c.column===u)c.subHeaders.push(a);else{let e=H2(n,u,{id:$ge(r,t,u.id,a.id),isPlaceholder:d,placeholderId:d?String(e_e(s,u)):void 0,depth:t,index:s.length});e.subHeaders.push(a),s.push(e)}o.headers.push(a),a.headerGroup=o}for(let e=0;e<a.length;e++)a[e](o);i.push(o),t>0&&G2(s,t-1,n,r,i,a)}function K2(e){for(let t=0;t<e.length;t++){let n=e[t];if(!V2(n.column,`getIsVisible`,U2))continue;let r=0;if(n.subHeaders.length){K2(n.subHeaders);for(let e=0;e<n.subHeaders.length;e++){let t=n.subHeaders[e];V2(t.column,`getIsVisible`,U2)&&(r+=t.colSpan)}}else r=1;if(n.colSpan=r,n.isPlaceholder&&n.subHeaders.length===1&&n.subHeaders[0].column===n.column){let e=1,t=n.subHeaders[0];for(;t;)t.rowSpan=0,e++,t=t.subHeaders.length===1&&t.subHeaders[0].column===n.column?t.subHeaders[0]:void 0;n.rowSpan=e}else n.rowSpan=1}}function q2(e,t,n,r){let i=W2(e),a=[],o=n._headerGroupInstanceInitFns,s=Array(t.length);for(let e=0;e<t.length;e++)e in t&&(s[e]=H2(n,t[e],{depth:i,index:e}));return G2(s,i-1,n,r,a,o),a.reverse(),K2(a[0]?.headers??[]),a}function t_e(e){if(!e._columnPrototype){e._columnPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignColumnPrototype?.(e._columnPrototype,e)}return e._columnPrototype}function n_e(e,t,n,r){let i={...e.getDefaultColumnDef(),...t},a=i.accessorKey,o=a===void 0?void 0:String(a),s=i.id??o?.replaceAll(`.`,`_`)??(typeof i.header==`string`?i.header:void 0),c;if(i.accessorFn)c=i.accessorFn;else if(a!==void 0){if(typeof a==`string`&&a.includes(`.`)){let e=a.split(`.`);c=t=>{let n=t;for(let t=0;t<e.length;t++){let r=e[t];n=n?.[r]}return n}}else c=e=>e[i.accessorKey]}if(!s)throw Error();let l=t_e(e),u=Object.create(l);u.accessorFn=c,u.columnDef=i,u.columns=[],u.depth=n,u.id=`${String(s)}`,u.parent=r;let d=e._columnInstanceInitFns;for(let e=0;e<d.length;e++)d[e](u);return u}function J2(e){let t=e.atoms.columnOrder?.get();return n=>{let r=[];if(!t?.length)r=n;else{let e=new Map;for(let t=0;t<n.length;t++){let r=n[t];e.set(r.id,r)}for(let n=0;n<t.length;n++){let i=t[n],a=e.get(i);a&&(r.push(a),e.delete(i))}for(let t=0;t<n.length;t++){let i=n[t];e.has(i.id)&&r.push(i)}}return r_e(e,r)}}function r_e(e,t){let n=e.atoms.grouping?.get()??[],{groupedColumnMode:r}=e.options;if(!n.length||!r)return t;let i=t.filter(e=>!n.includes(e.id));if(r===`remove`)return i;let a=new Map;for(let e=0;e<t.length;e++){let n=t[e];a.set(n.id,n)}let o=[];for(let e=0;e<n.length;e++){let t=a.get(n[e]);t&&o.push(t)}return[...o,...i]}function i_e(e){return[e,...e.columns.flatMap(e=>e.getFlatColumns())]}function a_e(e){if(e.columns.length){let t=e.columns.flatMap(e=>e.getLeafColumns());return V2(e.table,`getOrderColumns`,J2)(t)}return[e]}function o_e(e){return{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>e.renderValue()?.toString?.()??null,...Object.values(e._features).reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef?.()),{}),...e.options.defaultColumn}}function Y2(e,t,n,r=0){let i=Array(t.length);for(let a=0;a<t.length;a++){if(!(a in t))continue;let o=t[a],s=n_e(e,o,r,n),c=o;s.columns=c.columns?Y2(e,c.columns,s,r+1):[],i[a]=s}return i}function s_e(e){return Y2(e,e.options.columns)}function c_e(e){return e.getAllColumns().flatMap(e=>e.getFlatColumns())}function l_e(e){let t=A2(),n=e.getAllFlatColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function u_e(e){let t=e.getAllColumns().flatMap(e=>e.getLeafColumns());return V2(e,`getOrderColumns`,J2)(t)}function d_e(e){let t=A2(),n=e.getAllLeafColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function f_e(e,t){return e.getAllFlatColumnsById()[t]}var p_e={assignColumnPrototype:(e,t)=>{B2(`coreColumnsFeature`,e,t,{column_getFlatColumns:{fn:e=>i_e(e),memoDeps:e=>[e.table.options.columns]},column_getLeafColumns:{fn:e=>a_e(e),memoDeps:e=>[e.table.atoms.columnOrder?.get(),e.table.atoms.grouping?.get(),e.table.options.columns,e.table.options.groupedColumnMode]}})},constructTableAPIs:e=>{z2(`coreColumnsFeature`,e,{table_getDefaultColumnDef:{fn:()=>o_e(e),memoDeps:()=>[e.options.defaultColumn]},table_getAllColumns:{fn:()=>s_e(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumns:{fn:()=>c_e(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumnsById:{fn:()=>l_e(e),memoDeps:()=>[e.options.columns]},table_getAllLeafColumns:{fn:()=>u_e(e),memoDeps:()=>[e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.columns,e.options.groupedColumnMode]},table_getAllLeafColumnsById:{fn:()=>d_e(e),memoDeps:()=>[e.getAllLeafColumns()]},table_getColumn:{fn:t=>f_e(e,t)}})}};function X2(e,t){for(let n=0;n<e.subHeaders.length;n++)X2(e.subHeaders[n],t);t.push(e)}function m_e(e){let t=[];return X2(e,t),t}function h_e(e){return{column:e.column,header:e,table:e.column.table}}function g_e(e){let{start:t,end:n}=e.atoms.columnPinning?.get()??Xge(),r=e.getAllColumns(),i=V2(e,`getVisibleLeafColumns`,Zge);if(!t.length&&!n.length)return q2(r,i,e);let a=e.getAllLeafColumnsById(),o=[];for(let e=0;e<t.length;e++){let n=a[t[e]];n&&V2(n,`getIsVisible`,U2)&&o.push(n)}let s=[];for(let e=0;e<n.length;e++){let t=a[n[e]];t&&V2(t,`getIsVisible`,U2)&&s.push(t)}let c=i.filter(e=>!t.includes(e.id)&&!n.includes(e.id));return q2(r,[...o,...c,...s],e)}function __e(e){return[...e.getHeaderGroups()].reverse()}function v_e(e){let t=e.getHeaderGroups(),n=[];for(let e=0;e<t.length;e++){let r=t[e].headers;for(let e=0;e<r.length;e++)n.push(r[e])}return n}function y_e(e){let t=e.getHeaderGroups()[0]?.headers??[],n=[];for(let e=0;e<t.length;e++){let r=t[e].getLeafHeaders();for(let e=0;e<r.length;e++)n.push(r[e])}return n}var b_e={assignHeaderPrototype:(e,t)=>{B2(`coreHeadersFeature`,e,t,{header_getLeafHeaders:{fn:e=>m_e(e),memoDeps:e=>[e.column.table.options.columns]},header_getContext:{fn:e=>h_e(e),memoDeps:e=>[e.column.table.options.columns]}})},constructTableAPIs:e=>{z2(`coreHeadersFeature`,e,{table_getHeaderGroups:{fn:()=>g_e(e),memoDeps:()=>[e.options.columns,e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.options.groupedColumnMode]},table_getFooterGroups:{fn:()=>__e(e),memoDeps:()=>[e.getHeaderGroups()]},table_getFlatHeaders:{fn:()=>v_e(e),memoDeps:()=>[e.getHeaderGroups()]},table_getLeafHeaders:{fn:()=>y_e(e),memoDeps:()=>[e.getHeaderGroups()]}})}};function x_e(e){if(!e._rowPrototype){e._rowPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignRowPrototype?.(e._rowPrototype,e)}return e._rowPrototype}var S_e=(e,t,n,r,i,a,o)=>{let s=x_e(e),c=Object.create(s);c._displayIndexCache=-1,c._uniqueValuesCache=A2(),c._valuesCache=A2(),c.depth=i,c.id=t,c.index=r,c.original=n,c.parentId=o,c.subRows=a??[];let l=e._rowInstanceInitFns;for(let e=0;e<l.length;e++)l[e](c);return c},C_e=/([0-9]+)/gm;function Z2(e){let t=Object.assign((e,n,r)=>{let i=e.getValue(r),a=n.getValue(r),o=t.resolveDataValue;return o&&(i=o(i),a=o(a)),t.sort(i,a,e,n,r)},e);return t}Z2({resolveDataValue:e=>e4(e).toLowerCase(),sort:(e,t)=>t4(e,t)}),Z2({resolveDataValue:e=>e4(e),sort:(e,t)=>t4(e,t)}),Z2({resolveDataValue:e=>e4(e).toLowerCase(),sort:(e,t)=>$2(e,t)}),Z2({resolveDataValue:e=>e4(e),sort:(e,t)=>$2(e,t)}),Z2({resolveDataValue:e=>w_e(e),sort:(e,t)=>e>t?1:e<t?-1:0});var Q2=Z2({sort:(e,t)=>$2(e,t)});function $2(e,t){return e===t?0:e>t?1:-1}function w_e(e){return e instanceof Date?e.getTime():e}function e4(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function t4(e,t){let n=0,r=0,i=e.length,a=t.length;for(;n<i&&r<a;){let i=n4(e.charCodeAt(n)),a=n4(t.charCodeAt(r)),o=r4(e,n,i),s=r4(t,r,a);if(!i&&!a){let i=T_e(e,n,o,t,r,s);if(i)return i;n=o,r=s;continue}if(i!==a)return i?1:-1;let c=E_e(e,n,o,t,r,s);if(c)return c;n=o,r=s}return a4(e,n)-a4(t,r)}function n4(e){return e>=48&&e<=57}function r4(e,t,n){let r=t+1;for(;r<e.length&&n4(e.charCodeAt(r))===n;)r++;return r}function T_e(e,t,n,r,i,a){let o=n-t,s=a-i,c=o<s?o:s;for(let n=0;n<c;n++){let a=e.charCodeAt(t+n),o=r.charCodeAt(i+n);if(a>o)return 1;if(o>a)return-1}return o>s?1:s>o?-1:0}function E_e(e,t,n,r,i,a){let o=t;for(;o<n&&e.charCodeAt(o)===48;)o++;let s=i;for(;s<a&&r.charCodeAt(s)===48;)s++;let c=n-o,l=a-s;if(c===0&&l===0)return 0;if(c<=15&&l<=15){let t=i4(e,o,n),i=i4(r,s,a);return t>i?1:i>t?-1:0}let u=parseInt(e.slice(t,n),10),d=parseInt(r.slice(i,a),10);return u>d?1:d>u?-1:0}function i4(e,t,n){let r=0;for(let i=t;i<n;i++)r=r*10+e.charCodeAt(i)-48;return r}function a4(e,t){let n=0,r=t;for(;r<e.length;)n++,r=r4(e,r,n4(e.charCodeAt(r)));return n}function o4(){return[]}function D_e(e,t){I2(e,`cellSelection`,t?o4():k2(e.initialState.cellSelection)??o4())}function O_e(e){e.atoms.cellSelection&&(e.options.autoResetAll??e.options.autoResetCellSelection??!0)&&e._reactivity.schedule(()=>D_e(e))}function k_e(e){e.atoms.expanded&&(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding)&&e._reactivity.schedule(()=>A_e(e))}function A_e(e,t){let n=e.initialState.expanded;I2(e,`expanded`,t?A2():n===!0||Object.assign(A2(),k2(n??{})))}var s4=0;function j_e(e){if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if((e.atoms.pagination?.get()?.pageIndex??s4)===s4)return;P_e(e,!0)}}function M_e(e,t){I2(e,`pagination`,t)}function N_e(e,t){M_e(e,n=>{let r=O2(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})}function P_e(e,t){N_e(e,t?s4:e.initialState.pagination?.pageIndex??s4)}function F_e(){return[]}function c4(e,t){I2(e,`sorting`,t)}function l4(e,t){c4(e,t?[]:k2(e.initialState.sorting??[]))}function I_e(e){e.atoms.sorting&&(e.options.autoResetAll??e.options.autoResetSorting??!1)&&l4(e)}function u4(e){let t=e.table._rowModelFns.sortFns,n=e.table.getFilteredRowModel().flatRows.slice(0,10),r,i=!1;for(let t=0;t<n.length;t++){let a=n[t].getValue(e.id);if(Object.prototype.toString.call(a)===`[object Date]`){r=`datetime`;break}if(typeof a==`string`&&(i=!0,a.split(C_e).length>1)){r=`alphanumeric`;break}}if(!r&&i&&(r=`text`),r){let e=t?.[r];if(e||r===`alphanumeric`&&(e=t?.text),e)return e}return Q2}function d4(e){let t=e.table.getFilteredRowModel().flatRows.slice(0,10);for(let n=0;n<t.length;n++){let r=t[n].getValue(e.id);if(r!=null)return typeof r==`string`?`asc`:`desc`}return`desc`}function L_e(e){let t=e.table._rowModelFns.sortFns;return Vge(e.columnDef.sortFn)?e.columnDef.sortFn:e.columnDef.sortFn===`auto`?u4(e):t?.[e.columnDef.sortFn]??Q2}function f4(e,t,n){let r=m4(e,n&&g4(e)),i=t!==void 0;c4(e.table,a=>{let o=a.findIndex(t=>t.id===e.id),s=o===-1?void 0:a[o],c=[],l,u=i?t:r===`desc`,d=!!(a.length&&g4(e)&&n);return l=d?s?`toggle`:`add`:s?`toggle`:`replace`,l===`toggle`&&(i||r||(l=`remove`)),l===`add`?(c=[...a,{id:e.id,desc:u}],c.splice(0,c.length-(e.table.options.maxMultiSortColCount??2**53-1))):c=l===`toggle`?d?a.map(t=>t.id===e.id?{...t,desc:u}:t):[{id:e.id,desc:u}]:l===`remove`?d?a.filter(t=>t.id!==e.id):[]:[{id:e.id,desc:u}],c})}function p4(e){return e.columnDef.sortDescFirst??e.table.options.sortDescFirst??d4(e)===`desc`?`desc`:`asc`}function m4(e,t){let n=p4(e),r=_4(e);return r?r!==n&&(e.table.options.enableSortingRemoval??!0)&&(!t||(e.table.options.enableMultiRemove??!0))?!1:r===`desc`?`asc`:`desc`:n}function h4(e){return(e.columnDef.enableSorting??!0)&&(e.table.options.enableSorting??!0)&&!!e.accessorFn}function g4(e){return e.columnDef.enableMultiSort??e.table.options.enableMultiSort??!!e.accessorFn}function _4(e){let t=e.table.atoms.sorting?.get()?.find(t=>t.id===e.id);return t?t.desc?`desc`:`asc`:!1}function R_e(e){return e.table.atoms.sorting?.get()?.findIndex(t=>t.id===e.id)??-1}function z_e(e){c4(e.table,t=>t.length?t.filter(t=>t.id!==e.id):[])}function B_e(e){let t=h4(e);return n=>{t&&f4(e,void 0,g4(e)?e.table.options.isMultiSortEvent?.(n):!1)}}function V_e(){return e=>L2({feature:`coreRowModelsFeature`,table:e,fnName:`table.getCoreRowModel`,memoDeps:()=>[e.options.data],fn:()=>H_e(e,e.options.data),onAfterUpdate:Wge(()=>{k_e(e),j_e(e),I_e(e),O_e(e)})})}function v4(e,t,n,r=0,i){let a=[];for(let o=0;o<n.length;o++){let s=n[o],c=S_e(e,e.getRowId(s,o,i),s,o,r,void 0,i?.id);t.flatRows.push(c),t.rowsById[c.id]=c,a.push(c),e.options.getSubRows&&(c.originalSubRows=e.options.getSubRows(s,o),c.originalSubRows?.length&&(c.subRows=v4(e,t,c.originalSubRows,r+1,c)))}return a}function H_e(e,t){let n={rows:[],flatRows:[],rowsById:A2()};return n.rows=v4(e,n,t),n}function U_e(e){return e._rowModels.coreRowModel||(e._rowModels.coreRowModel=e.options.features.coreRowModel?.(e)??V_e()(e)),e._rowModels.coreRowModel()}function W_e(e){return e.getCoreRowModel()}function G_e(e){return e._rowModels.filteredRowModel||(e._rowModels.filteredRowModel=e.options.features.filteredRowModel?.(e)),e.options.manualFiltering||!e._rowModels.filteredRowModel?e.getPreFilteredRowModel():e._rowModels.filteredRowModel()}function K_e(e){return e.getFilteredRowModel()}function q_e(e){return e._rowModels.groupedRowModel||(e._rowModels.groupedRowModel=e.options.features.groupedRowModel?.(e)),e.options.manualGrouping||!e._rowModels.groupedRowModel?e.getPreGroupedRowModel():e._rowModels.groupedRowModel()}function J_e(e){return e.getGroupedRowModel()}function Y_e(e){return e._rowModels.sortedRowModel||(e._rowModels.sortedRowModel=e.options.features.sortedRowModel?.(e)),e.options.manualSorting||!e._rowModels.sortedRowModel?e.getPreSortedRowModel():e._rowModels.sortedRowModel()}function X_e(e){return e.getSortedRowModel()}function Z_e(e){return e._rowModels.expandedRowModel||(e._rowModels.expandedRowModel=e.options.features.expandedRowModel?.(e)),e.options.manualExpanding||!e._rowModels.expandedRowModel?e.getPreExpandedRowModel():e._rowModels.expandedRowModel()}function Q_e(e){return e.getExpandedRowModel()}function $_e(e){return e._rowModels.paginatedRowModel||(e._rowModels.paginatedRowModel=e.options.features.paginatedRowModel?.(e)),e.options.manualPagination||!e._rowModels.paginatedRowModel?e.getPrePaginatedRowModel():e._rowModels.paginatedRowModel()}function eve(e){return e.getPaginatedRowModel()}var tve={constructTableAPIs:e=>{z2(`coreRowModelsFeature`,e,{table_getCoreRowModel:{fn:()=>U_e(e)},table_getPreFilteredRowModel:{fn:()=>W_e(e)},table_getFilteredRowModel:{fn:()=>G_e(e)},table_getPreGroupedRowModel:{fn:()=>K_e(e)},table_getGroupedRowModel:{fn:()=>q_e(e)},table_getPreSortedRowModel:{fn:()=>J_e(e)},table_getSortedRowModel:{fn:()=>Y_e(e)},table_getPreExpandedRowModel:{fn:()=>X_e(e)},table_getExpandedRowModel:{fn:()=>Z_e(e)},table_getPrePaginatedRowModel:{fn:()=>Q_e(e)},table_getPaginatedRowModel:{fn:()=>$_e(e)},table_getRowModel:{fn:()=>eve(e)}})}};function nve(e){if(!e._cellPrototype){e._cellPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignCellPrototype?.(e._cellPrototype,e)}return e._cellPrototype}function rve(e,t,n){let r=nve(n),i=Object.create(r);i.column=e,i.id=`${t.id}_${e.id}`,i.row=t;let a=n._cellInstanceInitFns;for(let e=0;e<a.length;e++)a[e](i);return i}function ive(e){let t=e.table.getRowsInDisplayOrder(),n=e._displayIndexCache;return t[n]===e?n:-1}function ave(e){let t=e.getPrePaginatedRowModel().rows;if(e.options.paginateExpandedRows===!1){let e=[],n=t=>{t._displayIndexCache=e.length,e.push(t),t.subRows.length&&t.getIsExpanded?.()&&t.subRows.forEach(n)};return t.forEach(n),e}for(let e=0;e<t.length;e++)t[e]._displayIndexCache=e;return t}function ove(e,t){if(j2(e._valuesCache,t))return e._valuesCache[t];let n=e.table.getColumn(t);if(n?.accessorFn)return e._valuesCache[t]=n.accessorFn(e.original,e.index),e._valuesCache[t]}function sve(e,t){if(j2(e._uniqueValuesCache,t))return e._uniqueValuesCache[t];let n=e.table.getColumn(t);if(n?.accessorFn)return n.columnDef.getUniqueValues?(e._uniqueValuesCache[t]=n.columnDef.getUniqueValues(e.original,e.index),e._uniqueValuesCache[t]):(e._uniqueValuesCache[t]=[e.getValue(t)],e._uniqueValuesCache[t])}function cve(e,t){return e.getValue(t)??e.table.options.renderFallbackValue}function lve(e){return Hge(e.subRows,e=>e.subRows)}function uve(e){let t=e.getCoreRowModel().flatRows,n=0;for(let e=0;e<t.length;e++)n=Math.max(n,t[e].depth);return n}function dve(e){if(e.parentId)return e.table.getCoreRowModel().rowsById[e.parentId]??e.table.getRow(e.parentId,!0)}function fve(e){let t=[],n=e;for(;;){let e=n.getParentRow();if(!e)break;t.push(e),n=e}return t.reverse()}function pve(e){let t=e.table.getAllLeafColumns(),n=e._cellsCache;n||=e._cellsCache=new WeakMap;let r=Array(t.length);for(let i=0;i<t.length;i++){let a=t[i],o=n.get(a);o||(o=rve(a,e,e.table),n.set(a,o)),r[i]=o}return r}function mve(e){let t=A2(),n=e.getAllCells();for(let e=0;e<n.length;e++){let r=n[e];t[r.column.id]=r}return t}function hve(e,t,n,r){return t.options.getRowId?.(e,n,r)??(r?`${r.id}.${n}`:String(n))}function gve(e,t,n){let r=(n?e.getPrePaginatedRowModel():e.getRowModel()).rowsById[t];if(!r&&(r=e.getCoreRowModel().rowsById[t],!r))throw Error();return r}var _ve={assignRowPrototype:(e,t)=>{B2(`coreRowsFeature`,e,t,{row_getDisplayIndex:{fn:e=>ive(e)},row_getAllCellsByColumnId:{fn:e=>mve(e),memoDeps:e=>[e.getAllCells()]},row_getAllCells:{fn:e=>pve(e),memoDeps:e=>[e.table.getAllLeafColumns()]},row_getLeafRows:{fn:e=>lve(e),memoDeps:e=>[e.subRows]},row_getParentRow:{fn:e=>dve(e)},row_getParentRows:{fn:e=>fve(e)},row_getUniqueValues:{fn:(e,t)=>sve(e,t)},row_getValue:{fn:(e,t)=>ove(e,t)},row_renderValue:{fn:(e,t)=>cve(e,t)}})},constructTableAPIs:e=>{z2(`coreRowsFeature`,e,{table_getRowsInDisplayOrder:{fn:()=>ave(e),memoDeps:()=>[e.getPrePaginatedRowModel().rows,e.options.paginateExpandedRows,e.options.paginateExpandedRows===!1?e.atoms.expanded?.get():void 0]},table_getRowId:{fn:(t,n,r)=>hve(t,e,n,r)},table_getRow:{fn:(t,n)=>gve(e,t,n)},table_getMaxSubRowDepth:{fn:()=>uve(e),memoDeps:()=>[e.getCoreRowModel()]}})}};function y4(e,t,n=(e,t)=>e===t){let r=t===void 0?e.options.state:t;e._reactivity.batch(()=>{if(r)for(let t in r){let i=e.baseAtoms[t];if(!i)continue;let a=r[t],o=a===void 0?e.initialState[t]:a;n(e._reactivity.untrack(()=>i.get()),o)||i.set(()=>o)}})}function b4(e,t,n=(e,t)=>e===t){e._reactivity.batch(()=>{y4(e,t,n),e._reactivity.commit?.()})}function vve(e){let t=k2(e.initialState);e._reactivity.batch(()=>{let n=Object.keys(t);for(let r=0;r<n.length;r++){let i=n[r];e.baseAtoms[i].set(t[i])}});let n=Object.values(e._features);for(let t=0;t<n.length;t++)n[t].resetTableInstanceData?.(e)}function yve(e,t){let{features:n,atoms:r,initialState:i}=e.options;if(!e.options.mergeOptions)return{...e.options,...t,features:n,atoms:r,initialState:i};let a=e.options.mergeOptions(e.options,t),o={...Object.getOwnPropertyDescriptors(a)};return Object.defineProperties(Object.create(Object.getPrototypeOf(a)),{...o,features:{value:n,enumerable:!0,configurable:!0,writable:!0},atoms:{value:r,enumerable:!0,configurable:!0,writable:!0},initialState:{value:i,enumerable:!0,configurable:!0,writable:!0}})}function x4(e,t,n){let r=yve(e,O2(t,e.options));e.optionsStore?e.optionsStore.set(()=>r):e.options=r,n?.syncExternalState!==!1&&b4(e,r.state??null)}var bve={coreCellsFeature:Jge,coreColumnsFeature:p_e,coreHeadersFeature:b_e,coreRowModelsFeature:tve,coreRowsFeature:_ve,coreTablesFeature:{constructTableAPIs:e=>{z2(`coreTablesFeature`,e,{table_reset:{fn:()=>vve(e)},table_setOptions:{fn:t=>x4(e,t)}})}}};function xve(){return{accessor:(e,t)=>typeof e==`function`?{...t,accessorFn:e}:{...t,accessorKey:e},columns:e=>e,display:e=>e,group:e=>e}}function Sve(e){return e}function Cve(e,t={}){return Object.values(e).forEach(e=>{t=e.getInitialState?.(t)??t}),k2(t)}function wve(e){let t=e.features.coreReactivityFeature,{aggregationFns:n,columnMeta:r,coreRowModel:i,expandedRowModel:a,facetedMinMaxValues:o,facetedRowModel:s,facetedUniqueValues:c,filterFns:l,filterMeta:u,filteredRowModel:d,groupedRowModel:f,paginatedRowModel:p,sortFns:m,sortedRowModel:h,tableMeta:g,..._}=e.features,v={_cellInstanceInitFns:[],_columnInstanceInitFns:[],_features:{...bve,..._},_headerGroupInstanceInitFns:[],_headerInstanceInitFns:[],_reactivity:t,_rowInstanceInitFns:[],_rowModelFns:{aggregationFns:n,filterFns:l,sortFns:m},_rowModels:{},atoms:{},baseAtoms:{}},y=Object.values(v._features),b={...y.reduce((e,t)=>Object.assign(e,t.getDefaultTableOptions?.(v)),{}),...e};if(t.wrapExternalAtoms&&b.atoms)for(let[e,n]of Object.entries(b.atoms)){let r=n,i=t.createWritableAtom(r.get(),{debugName:`externalAtom/${e}`});b.atoms[e]=i;let a=!1,o=r.subscribe(e=>{a||i.set(e)}),s=i.subscribe(e=>{a=!0,r.set(e),a=!1});t.addSubscription(o),t.addSubscription(s)}t.createOptionsStore?(v.optionsStore=t.createWritableAtom(b,{debugName:`table/optionsStore`}),Object.defineProperty(v,"options",{configurable:!0,enumerable:!0,get(){return v.optionsStore.get()},set(e){v.optionsStore.set(()=>e)}})):v.options=b,v.initialState=Cve(v._features,v.options.initialState);let x=Object.keys(v.initialState);for(let e=0;e<x.length;e++){let n=x[e];v.baseAtoms[n]=t.createWritableAtom(v.initialState[n],{debugName:`table/baseAtoms/${n}`}),v.atoms[n]=t.createReadonlyAtom(()=>{let e=v.options,t=e.atoms?.[n],r=t?t.get():v.baseAtoms[n].get();if(t)return r;let i=e.state;if(i&&j2(i,n)){let e=i[n];return e===void 0?v.initialState[n]:e}return r},{debugName:`table/atoms/${n}`})}y4(v),v.store=Pge(t.createReadonlyAtom(()=>{let e={};for(let t=0;t<x.length;t++){let n=x[t];e[n]=v.atoms[n].get()}return e},{compare:T2,debugName:`table/store`}));for(let e=0;e<y.length;e++){let t=y[e];t.initTableInstanceData?.(v),t.initCellInstanceData&&v._cellInstanceInitFns.push(t.initCellInstanceData.bind(t)),t.initColumnInstanceData&&v._columnInstanceInitFns.push(t.initColumnInstanceData.bind(t)),t.initHeaderGroupInstanceData&&v._headerGroupInstanceInitFns.push(t.initHeaderGroupInstanceData.bind(t)),t.initHeaderInstanceData&&v._headerInstanceInitFns.push(t.initHeaderInstanceData.bind(t)),t.initRowInstanceData&&v._rowInstanceInitFns.push(t.initRowInstanceData.bind(t)),t.constructTableAPIs?.(v)}return v}function Tve(){return A2()}function S4(e,t){e.options.onRowSelectionChange?.(t)}function Eve(e,t){e._lastSelectedRowId=null,S4(e,t?A2():Object.assign(A2(),k2(e.initialState.rowSelection??{})))}function C4(e,t,n){e._lastSelectedRowId=null,S4(e,r=>{if(t=t===void 0?!V2(e,`getIsAllRowsSelected`,E4):t,n?.deselectAll&&!t)return A2();let i=Object.assign(A2(),r),a=e.getPreGroupedRowModel().flatRows;if(t){let e=new Map;a.forEach(t=>{I4(t,e)&&(i[t.id]=!0)})}else a.forEach(e=>{M4(e)&&delete i[e.id]});return i})}function w4(e,t,n){e._lastSelectedRowId=null,S4(e,r=>{let i=t===void 0?!V2(e,`getIsAllPageRowsSelected`,D4):t;if(n?.deselectAll&&!i)return A2();let a=Object.assign(A2(),r);return e.getRowModel().rows.forEach(t=>{F4(a,t.id,i,!0,e,!0)}),a})}function Dve(e){return e.getCoreRowModel()}function Ove(e){let t=e.getCoreRowModel();return V2(e,`getIsSomeRowsSelected`,O4)?z4(t,e):{rows:[],flatRows:[],rowsById:A2()}}function kve(e){let t=e.getFilteredRowModel();return V2(e,`getIsSomeRowsSelected`,O4)?z4(t,e):{rows:[],flatRows:[],rowsById:A2()}}function Ave(e){let t=e.getSortedRowModel();return V2(e,`getIsSomeRowsSelected`,O4)?z4(t,e):{rows:[],flatRows:[],rowsById:A2()}}function T4(e){return Object.keys(e.atoms.rowSelection?.get()??{})}function E4(e){let t=e.getFilteredRowModel().flatRows,n=e.atoms.rowSelection?.get()??{},r=!!(t.length&&Object.keys(n).length);if(r){let e=new Map;t.some(t=>!B4(t,n)&&I4(t,e))&&(r=!1)}return r}function D4(e){let t=e.getPaginatedRowModel().flatRows,n=e.atoms.rowSelection?.get()??{},r=new Map,i=!1;for(let e=0;e<t.length;e++){let a=t[e];if(B4(a,n))!i&&I4(a,r)&&(i=!0);else if(I4(a,r))return!1}return i}function O4(e){return V2(e,`getSelectedRowIds`,T4).length>0}function jve(e){return e.getPaginatedRowModel().flatRows.filter(e=>M4(e)).some(e=>A4(e)||V2(e,`getIsSomeSelected`,j4))}function Mve(e){return t=>{C4(e,t.target.checked)}}function Nve(e){return t=>{w4(e,t.target.checked)}}function k4(e,t,n){let r=A4(e);S4(e.table,i=>{t=t===void 0?!r:t;let a=Object.assign(A2(),i);return F4(a,e.id,t,(n?.selectChildren??!0)&&P4(e),e.table),!t&&n?.deselectParents&&L4(a,e),a})}function A4(e){return B4(e,e.table.atoms.rowSelection?.get()??{})}function j4(e){return V4(e)===`some`}function Pve(e){return V4(e)===`all`}function M4(e){let t=e.table.options;return typeof t.enableRowSelection==`function`?t.enableRowSelection(e):t.enableRowSelection??!0}function N4(e){let t=e.table.options;return typeof t.enableSubRowSelection==`function`?t.enableSubRowSelection(e):t.enableSubRowSelection??!0}function P4(e){let t=e.table.options;return typeof t.enableMultiRowSelection==`function`?t.enableMultiRowSelection(e):t.enableMultiRowSelection??!0}function Fve(e,t){let n=M4(e);return r=>{if(!n)return;let i=r,a=e.table,o=i.target.checked,s=a._lastSelectedRowId;(!(a.options.enableRowRangeSelection!==!1&&s!==null&&P4(e)&&(a.options.isRowRangeSelectionEvent?.(r)??!1))||!Ive(e,s,o,t))&&k4(e,o,t),a._lastSelectedRowId=e.id}}function Ive(e,t,n,r){let i=r?.selectChildren??!0,a=e.table,o=a.getRowsInDisplayOrder(),s=a.getPrePaginatedRowModel().rowsById[t]??a.getCoreRowModel().rowsById[t];if(!s)return!1;let c=s.getDisplayIndex(),l=e.getDisplayIndex(),u=o[c],d=o[l];if(c<0||l<0||c>=o.length||l>=o.length||u?.id!==s.id||d?.id!==e.id||!P4(s)||!P4(e))return!1;let f=Math.min(c,l),p=Math.max(c,l);return S4(a,e=>{let t=Object.assign(A2(),e);for(let e=f;e<=p;e++){let s=o[e];M4(s)&&P4(s)&&(F4(t,s.id,n,i,a),!n&&r?.deselectParents&&L4(t,s))}return t}),!0}function F4(e,t,n,r,i,a){let o=i.getRow(t,!0);n?(P4(o)||Object.keys(e).forEach(t=>delete e[t]),M4(o)&&(e[t]=!0)):(!a||M4(o))&&delete e[t],r&&o.subRows.length&&N4(o)&&o.subRows.forEach(t=>F4(e,t.id,n,r,i,a))}function I4(e,t){if(!M4(e))return!1;let n=e.table;if(n.options.enableSubRowSelection===!0)return!0;let r=e.parentId;if(r===void 0)return!0;let i=t.get(r);if(i!==void 0)return i;let a=n.getCoreRowModel().rowsById,o=[],s=!0,c=r;for(;c!==void 0;){let e=t.get(c);if(e!==void 0){s=e;break}o.push(c);let r=a[c]??n.getRow(c,!0);if(!N4(r)){s=!1;break}c=r.parentId}return o.forEach(e=>t.set(e,s)),s}function L4(e,t){let n=t.table.getCoreRowModel().rowsById,r=t.parentId;for(;r!==void 0;)delete e[r],r=(n[r]??t.table.getRow(r,!0)).parentId}function R4(e,t,n,r){let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=B4(o,t);if(s&&(n.push(o),r[o.id]=o),o.subRows.length){let e=R4(o.subRows,t,n,r);if(s){let t=Object.create(Object.getPrototypeOf(o));Rge(t,o),t.subRows=e,i.push(t)}}else s&&i.push(o)}return i}function z4(e,t){let n=[],r=A2(),i=t.atoms.rowSelection?.get()??{};return{rows:R4(e.rows,i,n,r),flatRows:n,rowsById:r}}function B4(e,t){return!!(j2(t,e.id)&&t[e.id])}function V4(e){if(!e.subRows.length)return!1;let t=e.table.atoms.rowSelection?.get()??{},n=!1,r=!0,i=!1;for(let a=0;a<e.subRows.length;a++){let o=e.subRows[a];if(n&&!r)break;if(M4(o)&&(i=!0,B4(o,t)?n=!0:r=!1),o.subRows.length){let e=V4(o);e===`all`?(n=!0,i=!0):e===`some`?(n=!0,r=!1,i=!0):r=!1}}return i?r?`all`:n?`some`:!1:!1}var Lve={initTableInstanceData:e=>{e._lastSelectedRowId=null},resetTableInstanceData:e=>{e._lastSelectedRowId=null},getInitialState:e=>({rowSelection:Tve(),...e}),getDefaultTableOptions:e=>({onRowSelectionChange:M2(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableRowRangeSelection:!0,enableSubRowSelection:!0,isRowRangeSelectionEvent:e=>{let t=e;return!!(t.shiftKey||t.nativeEvent?.shiftKey)}}),assignRowPrototype:(e,t)=>{B2(`rowSelectionFeature`,e,t,{row_toggleSelected:{fn:(e,t,n)=>k4(e,t,n)},row_getIsSelected:{fn:e=>A4(e)},row_getIsSomeSelected:{fn:e=>j4(e),memoDeps:e=>[e.subRows,e.table.atoms.rowSelection?.get(),e.table.options.enableRowSelection]},row_getIsAllSubRowsSelected:{fn:e=>Pve(e),memoDeps:e=>[e.subRows,e.table.atoms.rowSelection?.get(),e.table.options.enableRowSelection]},row_getCanSelect:{fn:e=>M4(e)},row_getCanSelectSubRows:{fn:e=>N4(e)},row_getCanMultiSelect:{fn:e=>P4(e)},row_getToggleSelectedHandler:{fn:(e,t)=>Fve(e,t)}})},constructTableAPIs:e=>{z2(`rowSelectionFeature`,e,{table_setRowSelection:{fn:t=>S4(e,t)},table_resetRowSelection:{fn:t=>Eve(e,t)},table_toggleAllRowsSelected:{fn:(t,n)=>C4(e,t,n)},table_toggleAllPageRowsSelected:{fn:(t,n)=>w4(e,t,n)},table_getPreSelectedRowModel:{fn:()=>Dve(e)},table_getSelectedRowModel:{fn:()=>Ove(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getCoreRowModel()]},table_getFilteredSelectedRowModel:{fn:()=>kve(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getFilteredRowModel()]},table_getGroupedSelectedRowModel:{fn:()=>Ave(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getSortedRowModel()]},table_getSelectedRowIds:{fn:()=>T4(e),memoDeps:()=>[e.atoms.rowSelection?.get()]},table_getIsAllRowsSelected:{fn:()=>E4(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getFilteredRowModel(),e.options.enableRowSelection,e.options.enableSubRowSelection]},table_getIsAllPageRowsSelected:{fn:()=>D4(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getPaginatedRowModel(),e.options.enableRowSelection,e.options.enableSubRowSelection]},table_getIsSomeRowsSelected:{fn:()=>O4(e),memoDeps:()=>[e.atoms.rowSelection?.get()]},table_getIsSomePageRowsSelected:{fn:()=>jve(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getPaginatedRowModel(),e.options.enableRowSelection]},table_getToggleAllRowsSelectedHandler:{fn:()=>Mve(e)},table_getToggleAllPageRowsSelectedHandler:{fn:()=>Nve(e)}})}},Rve={getInitialState(e){return{sorting:F_e(),...e}},getDefaultColumnDef(){return{sortFn:`auto`,sortUndefined:1}},getDefaultTableOptions(e){return{autoResetSorting:!1,onSortingChange:M2(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}},assignColumnPrototype(e,t){B2(`rowSortingFeature`,e,t,{column_getAutoSortFn:{fn:e=>u4(e)},column_getAutoSortDir:{fn:e=>d4(e)},column_getSortFn:{fn:e=>L_e(e)},column_toggleSorting:{fn:(e,t,n)=>f4(e,t,n)},column_getFirstSortDir:{fn:e=>p4(e)},column_getNextSortingOrder:{fn:(e,t)=>m4(e,t)},column_getCanSort:{fn:e=>h4(e)},column_getCanMultiSort:{fn:e=>g4(e)},column_getIsSorted:{fn:e=>_4(e)},column_getSortIndex:{fn:e=>R_e(e)},column_clearSorting:{fn:e=>z_e(e)},column_getToggleSortingHandler:{fn:e=>B_e(e)}})},constructTableAPIs(e){z2(`rowSortingFeature`,e,{table_setSorting:{fn:t=>c4(e,t)},table_resetSorting:{fn:t=>l4(e,t)}})}},zve=typeof window>`u`?L.useEffect:L.useLayoutEffect;function Bve(e,t){let[{table:n,rootSource:r}]=(0,L.useState)(()=>{let t=wve({...e,features:{coreReactivityFeature:Lge(),...e.features}});return t.Subscribe=(e=>Nge({...e,source:e.source??t.store})),t.FlexRender=wge,{table:t,rootSource:Ige(t.store,T2)}}),i=n;x4(i,t=>({...t,...e}),{syncExternalState:!1});let a=i.options.state,o=r.get(),s=D2(r,t,{compare:T2});return zve(()=>{r.markCommitted(o),b4(i,a??null,T2)}),(0,L.useMemo)(()=>({...n,options:e,state:s}),[n,e,s])}var Vve=e=>t=>{let n=t.currentTarget;n.scrollWidth>Math.ceil(n.getBoundingClientRect().width)?n.title=e:n.removeAttribute(`title`)},H4=({text:e,className:t})=>(0,z.jsx)(`span`,{className:g(`truncate`,t),onMouseEnter:Vve(e),children:e}),U4=e=>(0,z.jsx)(`span`,{className:`text-faint-foreground`,children:e}),W4=(e,t)=>{if(t==null)return U4(`—`);let n=_x(e,t)??``;switch(e.kind){case`text`:return e.link?(0,z.jsx)(xC,{format:e.link,value:n,className:`block min-w-0 truncate`}):(0,z.jsx)(H4,{text:n});case`id`:return(0,z.jsx)(H4,{text:n,className:`font-mono text-xs text-muted-foreground`});case`money`:return(0,z.jsx)(`span`,{className:`tabular-nums`,children:n});case`date`:return(0,z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n});case`datetime`:return(0,z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,title:e.relative?np(Number(t)):hx(`shownIn`,Gf(Number(t),If())),children:n});case`number`:return(0,z.jsx)(`span`,{className:`tabular-nums`,children:n});case`signed`:return(0,z.jsx)(`span`,{className:g(`tabular-nums`,Number(t)<0?`text-danger-text`:`text-success-text`),children:n});case`percent`:return Number(t)===0?U4(`—`):(0,z.jsx)(`span`,{className:`tabular-nums`,children:n});case`status`:return(0,z.jsx)(_d,{tone:e.tones?.[String(t)]??`neutral`,color:Z0(e.colors,t),shape:e.shape,children:n});case`relation`:return(0,z.jsx)(H4,{text:n,className:`font-medium text-primary-text hover:underline`});case`boolean`:return t?(0,z.jsx)(`span`,{className:`inline-flex size-4 items-center justify-center rounded-full bg-success-soft text-success-text`,children:(0,z.jsx)(xi,{className:`size-3`,strokeWidth:3})}):U4(hx(`no`));case`file`:{let e=rx(t);if(!e)return U4(`—`);if(`missing`in e)return(0,z.jsx)(H4,{text:e.name,className:`text-danger-text`});let n=dx(t,{width:20,height:20});return(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[n?(0,z.jsx)(fC,{image:n,className:`size-5 shrink-0 rounded-sm object-cover`}):(0,z.jsx)(Ya,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(H4,{text:e.name})]})}case`user`:{let e=hb(String(t));return(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2 truncate`,children:[(0,z.jsx)(cd,{initials:e.initials,hue:e.hue,size:`xs`,className:`ring-0`}),(0,z.jsx)(H4,{text:e.name,className:`text-muted-foreground`})]})}}},Hve=Sve({rowSortingFeature:Rve,rowSelectionFeature:Lve}),G4=xve(),Uve=e=>G4.columns(e.map(e=>G4.accessor(t=>e.value?e.value(t):t[e.id],{id:e.id,header:e.header,enableSorting:e.sortable??!1,cell:t=>e.render?e.render(t.row.original):W4(e,t.getValue())}))),Wve=(e,t)=>e.flatMap(e=>{let n=e.available?t.filter(e.available):t;return n.length===0?[]:[{action:e,rows:n,skipped:t.length-n.length}]}),Gve=({total:e,selectedCount:t,bulkActions:n=[],className:r})=>(0,z.jsx)(`div`,{className:g(`flex h-9 shrink-0 items-center border-t bg-surface px-3 text-xs text-muted-foreground`,r),children:(0,z.jsxs)(`span`,{className:`flex items-center tabular-nums`,children:[Ff(e),t>0&&(0,z.jsx)(`span`,{className:`ml-3 font-medium text-primary-text`,children:hx(`selected`,Mf(t))}),t>0&&n.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:e.onRun,className:g(`ml-3 rounded border bg-background px-2 py-0.5 font-medium hover:bg-muted`,e.destructive?`border-danger/40 text-danger-text`:`text-foreground`),children:e.label},e.label))]})}),Kve=(e,t)=>typeof e.label==`string`?e.label:e.label(t),qve=(e,t)=>e.filter(e=>e.available?.(t)??!0),Jve=({row:e,actions:t})=>{let{open:n,setOpen:r,place:i,button:a,menu:o}=FS();return(0,z.jsxs)(`div`,{className:`relative flex justify-center bg-inherit`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`button`,{ref:a,type:`button`,"aria-label":hx(`rowActions`),"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(!n),className:`inline-flex items-center justify-center rounded p-1 text-faint-foreground hover:bg-muted hover:text-foreground pointer-coarse:size-11`,children:(0,z.jsx)(qi,{className:`size-4`})}),n&&(0,ls.createPortal)((0,z.jsx)(`ul`,{ref:o,role:`menu`,onClick:e=>e.stopPropagation(),style:i??{visibility:`hidden`},className:`fixed z-50 min-w-36 rounded-md border bg-background py-1 shadow-pop`,children:t.map((t,n)=>{let i=Kve(t,e),a=t.blocked?.(e),o=g(`block w-full px-3 py-1.5 text-left hover:bg-muted disabled:cursor-default disabled:opacity-60 disabled:hover:bg-transparent`,t.destructive&&`text-danger-text`);return(0,z.jsx)(`li`,{role:`none`,children:t.link?(0,z.jsx)(Qu,{role:`menuitem`,to:t.link(e),onClick:()=>r(!1),className:o,children:i}):(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:a!==void 0,title:a,className:o,onClick:()=>{r(!1),t.onSelect(e)},children:i})},n)})}),document.body)]})},Yve=e=>52+Math.ceil(String(e).length*1.33)*7,K4=.6,q4=(e,t)=>Math.max(e.minWidth??0,e.width*t),Xve=(e,t)=>e.fixed?`${Math.max(e.minWidth??0,e.width)}px`:`minmax(${q4(e,t)}px, ${e.width}fr)`,J4=(e,t,n=0,r=K4)=>`${t}px ${e.map(e=>Xve(e,r)).join(` `)}${n>0?` ${n}px`:``}`,Zve=(e,t,n=0,r=K4)=>t+n+e.reduce((e,t)=>e+(t.fixed?Math.max(t.minWidth??0,t.width):q4(t,r)),0),Qve=()=>{let e=(0,L.useRef)(null),t=(0,L.useRef)(null),[n,r]=(0,L.useState)({scrolled:!1,more:!1}),i=(0,L.useCallback)(()=>{let t=e.current;if(!t)return;let n={scrolled:t.scrollLeft>1,more:t.scrollLeft+t.clientWidth<t.scrollWidth-1};r(e=>e.scrolled===n.scrolled&&e.more===n.more?e:n)},[]);return{ref:e,attach:(0,L.useCallback)(n=>{if(t.current?.disconnect(),t.current=null,e.current=n,!n)return;let r=new ResizeObserver(i);r.observe(n);for(let e of Array.from(n.children))r.observe(e);t.current=r,i()},[i]),onScroll:i,...n}},$ve=`protobase:pinned:`,eye=(e,t)=>`${$ve}${e}:${t}`,tye=(e,t)=>u(()=>{let n=e.getItem(t);if(n===null)return;let r=JSON.parse(n);return Array.isArray(r)&&r.every(e=>typeof e==`string`)?r:void 0},void 0),nye=(e,t,n)=>u(()=>e.setItem(t,JSON.stringify(n)),void 0),rye=(e,t=[])=>{let[n,r]=(0,L.useState)(()=>e?tye(localStorage,e):void 0),i=(0,L.useCallback)(t=>{r(t),e&&nye(localStorage,e,t)},[e]);return[n??t,i]},iye=e=>{let t=e.findIndex(e=>e.title);return t<0||t>1?[]:e.slice(0,t+1).map(e=>e.id)},aye=e=>Object.fromEntries(e.map(({id:e,width:t,minWidth:n,fixed:r})=>[e,{width:t,minWidth:n,fixed:r}])),oye=(e,t)=>{let n=e.map(e=>e.id).sort().join(` `),[r,i]=(0,L.useState)(),a=r?.key===n?r:void 0;!a&&t.length>0&&i({key:n,sizes:aye(Px(e,t))});let o=a?.sizes;return(0,L.useMemo)(()=>o?e.map(e=>({...e,...o[e.id]})):e,[e,o])},Y4=e=>e===`money`||e===`number`||e===`signed`||e===`percent`,X4=()=>hx(`unsortable`),sye=({header:e,pinned:t,sortable:n,onTogglePin:r})=>{let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(!i)return;let e=e=>{(e instanceof KeyboardEvent?e.key===`Escape`:!o.current?.contains(e.target))&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[i]),(0,z.jsxs)(`div`,{ref:o,className:`relative ml-auto shrink-0`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":hx(`columnMenu`,e),"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>a(!i),className:`relative inline-flex size-5 items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground focus-visible:opacity-100 after:absolute after:-inset-2 after:content-[''] md:opacity-0 md:group-hover/cell:opacity-100 aria-expanded:opacity-100`,children:(0,z.jsx)(qi,{className:`size-3.5`})}),i&&(0,z.jsxs)(`ul`,{role:`menu`,className:`absolute right-0 top-full z-30 mt-1 min-w-32 rounded-md border bg-background py-1 text-body font-normal text-foreground shadow-pop`,children:[!n&&(0,z.jsx)(`li`,{role:`none`,children:(0,z.jsx)(`span`,{role:`menuitem`,"aria-disabled":`true`,className:`block min-h-9 whitespace-nowrap px-3 py-1.5 text-muted-foreground`,children:X4()})}),(0,z.jsx)(`li`,{role:`none`,children:(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block min-h-9 w-full whitespace-nowrap px-3 py-1.5 text-left hover:bg-muted`,onClick:()=>{a(!1),r()},children:hx(t?`unpin`:`pinToLeft`)})})]})]})},cye=({sorted:e})=>e===`asc`?(0,z.jsx)(qr,{className:`size-3 text-foreground`}):e===`desc`?(0,z.jsx)(Lr,{className:`size-3 text-foreground`}):(0,z.jsx)(ki,{className:`size-3 opacity-0 group-hover/head:opacity-100`}),Z4=({spec:e})=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.header}),e.highlight&&(0,z.jsx)(`span`,{className:`rounded bg-primary px-1 text-[10px] font-semibold uppercase leading-4 text-primary-foreground`,children:hx(`new`)})]}),lye=({cells:e,specs:t,gutter:n,selectedCount:r,selectable:i,trailing:a,minScale:o,pins:s={},lastPinned:c,scrolled:l,onTogglePin:u,onClearSelection:d})=>(0,z.jsxs)(`div`,{className:`grid h-8 shrink-0 items-center border-b bg-surface text-body font-medium text-muted-foreground`,style:{gridTemplateColumns:J4(t,n,a,o)},role:`row`,children:[(0,z.jsxs)(`div`,{className:g(`sticky left-0 z-10 flex h-full items-center gap-2 bg-inherit pl-3`,l&&!c&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),style:{width:n},children:[i&&(0,z.jsx)(xg,{checked:!1,indeterminate:r>0,label:hx(r>0?`clearSelection`:`noRowsSelected`),disabled:r===0,onChange:d,className:g(r===0&&`opacity-60`)}),n>40&&(0,z.jsx)(`span`,{className:`w-6 text-right text-faint-foreground`,children:`#`})]}),e.map(({spec:e,sorted:t,onSort:n})=>{let r=e.id in s;return(0,z.jsxs)(`div`,{"data-col-id":e.id,style:r?{left:s[e.id]}:void 0,className:g(`group/cell flex h-full min-w-0 items-center`,r&&`sticky z-10 bg-inherit`,r&&l&&e.id===c&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`,e.highlight&&`bg-primary-soft text-primary-text`),children:[e.sortable?(0,z.jsxs)(`button`,{type:`button`,onClick:n,className:g(`group/head flex h-full min-w-0 flex-1 items-center gap-1 pl-3 pr-1 text-left`,Y4(e.kind)&&`justify-end`,`hover:text-foreground`,t&&`text-foreground`),children:[(0,z.jsx)(Z4,{spec:e}),(0,z.jsx)(cye,{sorted:t})]}):(0,z.jsx)(`div`,{title:X4(),className:g(`flex h-full min-w-0 flex-1 items-center gap-1 pl-3 pr-1 text-left`,Y4(e.kind)&&`justify-end`),children:(0,z.jsx)(Z4,{spec:e})}),(0,z.jsx)(`div`,{className:`pr-1.5`,children:(0,z.jsx)(sye,{header:e.header,pinned:r,sortable:!!e.sortable,onTogglePin:()=>u(e.id)})})]},e.id)}),a?(0,z.jsx)(`div`,{className:`sticky right-0 z-10 h-full bg-inherit`}):null]}),Q4=e=>({gridTemplateColumns:J4(e.specs,e.gutter,e.trailing,e.minScale),height:e.height,transform:`translateY(${e.offset}px)`}),$4=(e,t)=>g(`flex h-full min-w-0 items-center overflow-hidden whitespace-nowrap px-3`,Y4(e.kind)&&`justify-end`,e.highlight&&`bg-primary-soft/60`,t.pins&&e.id in t.pins&&`sticky z-10 bg-inherit`,t.scrolled&&e.id===t.lastPinned&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),e3=(e,t)=>t&&e.id in t?{left:t[e.id]}:void 0,t3=({width:e,index:t,selectable:n,selected:r,onToggle:i,edge:a})=>(0,z.jsxs)(`div`,{onClick:n?e=>{e.stopPropagation(),i?.()}:void 0,className:g(`sticky left-0 z-10 flex h-full items-center gap-2 bg-inherit pl-3`,n&&`cursor-default`,a&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),style:{width:e},children:[n&&(0,z.jsx)(xg,{checked:!!r,label:hx(`selectRow`,t+1)}),e>40&&(0,z.jsx)(`span`,{className:`min-w-6 text-right text-[11px] tabular-nums text-faint-foreground`,children:Mf(t+1)})]}),uye=(e,t,n)=>({gridTemplateColumns:J4(e.specs,e.gutter,e.trailing,e.minScale),height:e.height,top:e.offset,transform:t===0?void 0:`translateY(${t}px)`,transition:n}),dye=e=>t=>{t.target.closest(`a`)||e()},n3=({cells:e,selected:t,onToggle:n,onOpen:r,menu:i,handle:a,rowRef:o,dragY:s,transition:c,dragging:l,...u})=>(0,z.jsxs)(`div`,{ref:o,role:`row`,onClick:r&&dye(r),className:g(`absolute inset-x-0 top-0 grid items-center border-b`,t?`bg-primary-soft`:`bg-background hover:bg-surface`,r&&`cursor-pointer`,l&&`z-30 bg-surface shadow-pop`),style:s===void 0?Q4(u):uye(u,s,c),children:[a?(0,z.jsx)(`div`,{className:g(`sticky left-0 z-10 flex h-full items-center bg-inherit pl-1.5`,u.scrolled&&!u.lastPinned&&`shadow-[1px_0_0_var(--border),4px_0_6px_-2px_rgb(0_0_0/0.12)]`),style:{width:u.gutter},children:a}):(0,z.jsx)(t3,{width:u.gutter,index:u.index,selectable:u.selectable,selected:t,onToggle:n,edge:u.scrolled&&!u.lastPinned}),e.map(({spec:e,content:t,props:n,chosen:r,editing:i,editable:a})=>(0,z.jsx)(`div`,{role:n?`gridcell`:`cell`,...n,className:g($4(e,u),n&&`scroll-mb-[calc(var(--pb-sticky-bottom,0px)+3rem)] scroll-mt-[calc(var(--pb-sticky-top,0px)+2rem)] outline-none`,a&&!i&&`cursor-default`,r&&`shadow-[inset_0_0_0_2px_var(--primary)]`,i&&`z-30 overflow-visible bg-background px-1`),style:e3(e,u.pins),children:t},e.id)),i&&(0,z.jsx)(`div`,{className:`sticky right-0 z-10 flex h-full items-center justify-center bg-inherit`,children:i})]}),r3=[`w-3/4`,`w-1/2`,`w-2/3`,`w-5/6`,`w-2/5`],fye=e=>(0,z.jsxs)(`div`,{role:`row`,"aria-busy":!0,className:`absolute inset-x-0 top-0 grid items-center border-b bg-background`,style:Q4(e),children:[(0,z.jsx)(t3,{width:e.gutter,index:e.index,selectable:!1,edge:e.scrolled&&!e.lastPinned}),e.specs.map((t,n)=>(0,z.jsx)(`div`,{className:$4(t,e),style:e3(t,e.pins),children:(0,z.jsx)(Yu,{className:g(`h-2.5`,r3[(e.index+n)%r3.length],Y4(t.kind)&&`ml-auto`)})},t.id))]}),pye=(e,t)=>{let n=new Map;return{get:t=>n.get(Math.floor(t/e))?.[t%e],hasPage:e=>n.has(e),setPage:(e,r)=>{if(n.delete(e),n.set(e,r),n.size<=t)return;let i=n.keys().next();i.done||n.delete(i.value)},keepOnly:e=>{for(let t of[...n.keys()])e.includes(t)||n.delete(t)},get size(){return n.size}}},i3=(e,t,n)=>{let r=Math.floor(e/n),i=Math.floor(t/n);return Array.from({length:i-r+1},(e,t)=>r+t)},a3=(e,t)=>Math.max(0,Math.min(40,e-t*40)),o3=({total:e,rowAt:t,loadRows:n,revision:r,latencyMs:i},a,o)=>{let s=(0,L.useMemo)(()=>pye(40,60),[t,n]),[c,l]=(0,L.useState)(0),u=Math.floor(a/40),d=Math.floor(o/40),f=!n&&i===0;(0,L.useEffect)(()=>{if(f)return;let r=i3(u*40,d*40,40).filter(e=>!s.hasPage(e)),a=t=>a3(e,t),o=(e,t)=>{s.setPage(e,t),l(e=>e+1)};if(n){let e=!1;for(let t of r)n(t*40,a(t)).then(n=>{e||o(t,n)});return()=>{e=!0}}let c=r.map(e=>setTimeout(()=>o(e,Array.from({length:a(e)},(n,r)=>t(e*40+r))),i));return()=>c.forEach(clearTimeout)},[s,u,d,i,e,t,n,f]);let p=(0,L.useRef)(r);return(0,L.useEffect)(()=>{if(!n||r===p.current)return;p.current=r;let t=i3(u*40,d*40,40);s.keepOnly(t);for(let r of t.filter(e=>s.hasPage(e)))n(r*40,a3(e,r)).then(e=>{s.setPage(r,e),l(e=>e+1)})},[s,r,n,u,d,e]),(0,L.useCallback)(e=>f?t(e):s.get(e),[s,f,t,c])},mye=1e7,s3=(e,t,n)=>{let r=e*t,i=Math.min(r,mye);return{rowHeight:t,trueHeight:r,contentHeight:i,scaled:r>i,maxTop:Math.max(0,r-n),maxScroll:Math.max(0,i-n)}},hye=(e,t)=>!e.scaled||t<=0?t:t>=e.maxScroll?e.maxTop+t-e.maxScroll:t/e.maxScroll*e.maxTop,c3=(e,t)=>!e.scaled||t<=0?t:t>=e.maxTop?e.maxScroll+t-e.maxTop:t/e.maxTop*e.maxScroll,gye=(e,t,n,r)=>{let i=t*e.rowHeight;return e.scaled?i-n+r:i},l3=(e,t,n,r,i)=>{let a=Math.min(e,Math.max(0,Math.floor(t/n)-i)),o=Math.min(e-1,Math.floor((t+r)/n)+i);return{first:a,last:Math.max(a-1,o)}},_ye=e=>{let t=document.scrollingElement??document.documentElement;for(let n=e.parentElement;n&&n!==t&&n!==document.body;n=n.parentElement)if(/auto|scroll/.test(getComputedStyle(n).overflowY))return n;return t},u3=e=>e===(document.scrollingElement??document.documentElement),vye=e=>u3(e)?window:e,d3=e=>Number.parseFloat(e)||0,yye=e=>{let t=getComputedStyle(e),n=u3(e)?{top:0,height:e.clientHeight}:{top:e.getBoundingClientRect().top+e.clientTop,height:e.clientHeight},r=d3(t.scrollPaddingTop);return{top:n.top+r,height:Math.max(0,n.height-r-d3(t.scrollPaddingBottom))}},f3=6,p3=(e,t,n)=>{let r=s3(t,n,e.height),i=hye(r,e.position);return{geometry:r,top:i,topIndex:Math.floor(Math.max(0,i)/n),...l3(t,i,n,e.height,f3)}},m3=({total:e,rowHeight:t,initialIndex:n,inset:r=0,settle:i,ready:a=!0,onScroll:o})=>{let s=(0,L.useRef)(null),c=(0,L.useRef)(null),[l,u]=(0,L.useState)({position:0,height:0}),d=(0,L.useRef)({total:e,rowHeight:t,initialIndex:n,inset:r,ready:a,onScroll:o});d.current={total:e,rowHeight:t,initialIndex:n,inset:r,ready:a,onScroll:o};let f=(0,L.useCallback)(()=>{let e=s.current;if(!e||!c.current)return;let t=yye(c.current),n=d.current.inset;return{position:t.top+n-e.getBoundingClientRect().top,height:Math.max(0,t.height-n)}},[]),p=(0,L.useRef)({pending:!0,laidOut:!1}),m=(0,L.useRef)(l);m.current=l;let h=(0,L.useCallback)(()=>{let e=f();if(!e)return;let t=m.current,{total:n,rowHeight:r,onScroll:i}=d.current,a=p3(t,n,r),o=p3(e,n,r);p.current.pending||i?.(Math.max(0,o.top));let s=!o.geometry.scaled&&a.first===o.first&&a.last===o.last&&a.topIndex===o.topIndex;(t.height!==e.height||t.position!==e.position&&!s)&&(m.current=e,u(e))},[f]),g=(0,L.useCallback)(()=>{if(!p.current.pending||!p.current.laidOut||!d.current.ready)return;let e=f(),t=c.current;if(!e||!t)return;p.current.pending=!1;let{total:n,rowHeight:r,initialIndex:i}=d.current;i>0?t.scrollTop+=c3(s3(n,r,e.height),i*r)-e.position:e.position>0&&(t.scrollTop=0)},[f]);(0,L.useLayoutEffect)(()=>{let e=s.current;if(!e)return;let t=_ye(e);c.current=t;let n=vye(t);n.addEventListener(`scroll`,h,{passive:!0}),window.addEventListener(`resize`,h,{passive:!0});let r=new ResizeObserver(()=>{p.current.laidOut=!0,g(),h()});return r.observe(t),r.observe(e),h(),()=>{n.removeEventListener(`scroll`,h),window.removeEventListener(`resize`,h),r.disconnect(),c.current=null}},[h,g]),(0,L.useLayoutEffect)(()=>{g(),h()});let _=(0,L.useCallback)(e=>{let t=f();if(!t||!c.current)return;let n=s3(d.current.total,d.current.rowHeight,t.height);c.current.scrollTop+=c3(n,e)-t.position,h()},[f,h]),v=p3(l,e,t),y=i?i(v.top):v.top,{first:b,last:x}=i?l3(e,y,t,l.height,f3):v,S=Array.from({length:x-b+1},(e,t)=>({index:b+t,offset:gye(v.geometry,b+t,y,l.position)}));return{ref:s,height:l.height,top:y,geometry:v.geometry,rows:S,first:b,last:x,scrollTo:_}},bye=e=>e===`ArrowUp`||e===`ArrowDown`||e===`ArrowLeft`||e===`ArrowRight`,xye=(e,t,n,r)=>{let i=n.indexOf(e.column);if(t===`ArrowUp`)return e.index>0?{...e,index:e.index-1}:void 0;if(t===`ArrowDown`)return e.index<r-1?{...e,index:e.index+1}:void 0;let a=n[t===`ArrowLeft`?i-1:i+1];return i>=0&&a!==void 0?{...e,column:a}:void 0},Sye=(e,t,n,r)=>{let i=t.indexOf(e);return(r===1?t.slice(i+1):t.slice(0,Math.max(0,i)).reverse()).find(n)},h3=e=>`${e.index}:${e.column}`,Cye=({editor:e,columns:t,total:n,rowAt:r,onOpenRow:i,container:a})=>{let[o,s]=(0,L.useState)(),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(!1),d=(0,L.useRef)(!1);if((0,L.useEffect)(()=>{if(!o||c||!u.current)return;u.current=!1;let e=a.current?.querySelector(`[data-cell="${h3(o)}"]`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`nearest`,inline:`nearest`}))},[o,c,a]),!e)return;let f=t=>{let n=r(t.index);return n!==void 0&&e.editable(n,t.column)},p=(e,t=!1)=>{u.current=!0,s(e),l(t&&f(e))},m=n=>{if(!o)return;let i=r(o.index),s=n&&i?Sye(o.column,t,t=>e.editable(i,t),n):void 0,c=!!a.current?.contains(document.activeElement);p(s?{...o,column:s}:o,s!==void 0),u.current=c};return{cell:(n,r,i,a)=>{let l={index:n,column:i},u=o?.index===n&&o.column===i,f=e.editable(r,i),h=u||!o&&n===0&&i===t[0];return{content:u&&c?e.render(r,i,m):a,chosen:u,editing:u&&c,editable:f,props:{"data-cell":h3(l),tabIndex:h?0:-1,"aria-selected":u,onMouseDown:()=>{d.current=u},onFocus:e=>{e.target===e.currentTarget&&!u&&s(l)},onClick:e=>{f&&(e.stopPropagation(),d.current&&!c&&p(l,!0))},onDoubleClick:e=>{f&&(e.stopPropagation(),u&&c||p(l,!0))}}}},onKeyDown:e=>{if(c||!o||!(e.target instanceof HTMLElement)||e.target.dataset.cell!==h3(o))return;let a=e.key===`Tab`?e.shiftKey?`ArrowLeft`:`ArrowRight`:e.key;if(bye(a)){let i=xye(o,a,t,n);if(!i&&e.key===`Tab`)return;e.preventDefault(),i&&r(i.index)&&p(i);return}if(e.key===`Enter`||e.key===`F2`){e.preventDefault();let t=r(o.index);f(o)?p(o,!0):e.key===`Enter`&&t&&i?.(t);return}e.key===`Escape`&&s(void 0)}}},wye=({ids:e,rowAt:t,reorder:n,children:r})=>{let i=ev($_($v,{activationConstraint:{distance:4}}),$_(ty,{activationConstraint:{delay:250,tolerance:5}}),$_(Gv,{coordinateGetter:cb})),a=t=>e.indexOf(String(t)),o=e=>{let r=t(a(e));return r?n.label(r):hx(`row`)};return(0,z.jsx)(Cy,{sensors:i,collisionDetection:sv,onDragEnd:({active:e,over:t})=>{t&&e.id!==t.id&&n.onMove(a(e.id),a(t.id))},accessibility:{announcements:{onDragStart:({active:t})=>hx(`pickedUp`,o(t.id),a(t.id)+1,e.length),onDragOver:({active:t,over:n})=>n?hx(`isOver`,o(t.id),a(n.id)+1,e.length):void 0,onDragEnd:({active:t,over:n})=>n?hx(`droppedAt`,o(t.id),a(n.id)+1,e.length):hx(`putBack`,o(t.id)),onDragCancel:({active:e})=>hx(`cancelled`,o(e.id),a(e.id)+1)},screenReaderInstructions:{draggable:hx(`reorderInstructions`)}},children:(0,z.jsx)(Xy,{items:e,strategy:Ky,children:r})})},Tye=({row:e,label:t,...n})=>{let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,transition:c,isDragging:l}=ib({id:e.id}),u=(0,z.jsx)(`button`,{ref:o,type:`button`,"aria-label":hx(`move`,t),...r,...i,onClick:e=>e.stopPropagation(),style:{touchAction:`none`},className:`flex size-7 cursor-grab items-center justify-center rounded text-faint-foreground hover:bg-muted hover:text-foreground focus-visible:text-foreground active:cursor-grabbing pointer-coarse:size-9`,children:(0,z.jsx)(ra,{className:`size-4`})});return(0,z.jsx)(n3,{...n,rowRef:a,handle:u,dragY:s?.y??0,transition:c,dragging:l})},g3=32,_3=({columns:e,source:t,naturalSort:n,initialScrollIndex:r=0,onScrollIndex:i,latencyMs:a=150,sort:o,onSortChange:s,onOpenRow:c,rowLink:l,rowActions:u,cellEditor:d,rowPatches:f,bulkActions:p,pinKey:m,defaultPinned:h,rowNumbers:_=!0,compact:v=!1,selectable:y=!0,reorder:b,fit:x=!1,scroll:S=`own`,className:C})=>{let w=y&&!b,T=v?28:36,E=!Mu(),D=(h??(E?[]:iye(e))).join(` `),[O,k]=rye(m,(0,L.useMemo)(()=>D?D.split(` `):[],[D])),A=(0,L.useMemo)(()=>[...O.flatMap(t=>e.find(e=>e.id===t)??[]),...e.filter(e=>!O.includes(e.id))],[e,O]),j=A.slice(0,A.filter(e=>O.includes(e.id)).length).map(e=>e.id),{total:M}=t,[N,P]=(0,L.useState)(n?[{id:n.columnId,desc:n.direction===`desc`}]:[]),ee=o?[{id:o.columnId,desc:o.direction===`desc`}]:N,te=e=>{let t=typeof e==`function`?e(ee):e,n=t[0];s&&n&&s({columnId:n.id,direction:n.desc?`desc`:`asc`}),o||P(t)},[ne,re]=(0,L.useState)({}),ie=(0,L.useMemo)(()=>Uve(A),[A]),ae=ee[0],oe=!!(!o&&n&&ae&&ae.id===n.columnId&&(ae.desc?`desc`:`asc`)!==n.direction),se=t.rowAt,ce=(0,L.useCallback)(e=>se(oe?M-1-e:e),[se,oe,M]),[le]=(0,L.useState)(r),{ref:ue,geometry:F,rows:de,first:fe,last:pe}=m3({total:M,rowHeight:T,initialIndex:le,inset:g3,onScroll:i&&(e=>i(e/T))}),me=E||!_?40:Yve(M),I=o3({total:M,rowAt:se?ce:void 0,loadRows:t.loadRows,revision:t.revision,latencyMs:a},fe,pe),he=(0,L.useCallback)(e=>{let t=I(e),n=t&&f?.get(t.id);return n?{...t,...n}:t},[I,f]),ge=de.map(({index:e,offset:t})=>({index:e,offset:t,row:he(e)})),_e=(0,L.useMemo)(()=>ge.flatMap(({row:e})=>e?[e]:[]),[he,fe,pe]),ve=oye(A,_e),ye=Bve({features:Hve,columns:ie,data:_e,state:{sorting:ee,rowSelection:ne},onSortingChange:te,onRowSelectionChange:re,manualSorting:!0,enableMultiSort:!1,enableSortingRemoval:!1,getRowId:e=>e.id}),be=new Map(ye.getRowModel().rows.map(e=>[e.id,e])),xe=Object.keys(ne).length,Se=(0,L.useRef)(new Map);for(let e of ye.getRowModel().rows)e.getIsSelected()&&Se.current.set(e.id,e.original);let Ce=u&&u.length>0?40:0,we=E?1:K4,Te=Qve(),Ee=(0,L.useRef)(null),De=()=>{Te.onScroll(),Ee.current&&Te.ref.current&&(Ee.current.scrollLeft=Te.ref.current.scrollLeft)},[Oe,ke]=(0,L.useState)({});(0,L.useLayoutEffect)(()=>{let e=Ee.current?.querySelector(`[role=row]`);if(!e)return;let t=me,n={};for(let r of j)n[r]=t,t+=e.querySelector(`[data-col-id="${r}"]`)?.offsetWidth??0;JSON.stringify(Oe)!==JSON.stringify(n)&&ke(n)});let Ae=j.at(-1),je=e=>k(O.includes(e)?O.filter(t=>t!==e):[...O,e]),Me=ye.getHeaderGroups().flatMap(e=>e.headers.map(e=>({spec:A.find(t=>t.id===e.column.id),sorted:e.column.getIsSorted(),onSort:t=>e.column.getToggleSortingHandler()?.(t)}))),Ne=(0,L.useRef)(null),Pe=Cye({editor:d,columns:(0,L.useMemo)(()=>A.map(e=>e.id),[A]),total:M,rowAt:he,onOpenRow:c,container:Ne}),Fe=(A.find(e=>e.title)??A[0])?.id,Ie=Zve(ve,me,Ce,we),Le=S===`own`,Re=(0,z.jsx)(`div`,{ref:Ee,className:g(`sticky z-20 shrink-0 overflow-hidden`,Le?`top-0`:`top-[var(--pb-sticky-top,0px)]`),children:(0,z.jsx)(`div`,{style:{minWidth:Ie},children:(0,z.jsx)(lye,{cells:Me,specs:ve,gutter:me,trailing:Ce,minScale:we,pins:Oe,lastPinned:Ae,scrolled:Te.scrolled,onTogglePin:je,selectable:w,selectedCount:xe,onClearSelection:()=>re({})})})}),ze=ge.map(({index:e,offset:t,row:n})=>{let r={specs:ve,gutter:me,index:e,offset:t,height:T,selectable:w,trailing:Ce,minScale:we,scrolled:Te.scrolled,pins:Oe,lastPinned:Ae},i=n?be.get(n.id):void 0;if(!i||!n)return(0,z.jsx)(fye,{...r},`skeleton-${e}`);let a=Ce?qve(u,n):[],o={...r,selected:i.getIsSelected(),onToggle:()=>i.toggleSelected(),onOpen:c?()=>c(n):void 0,menu:a.length>0?(0,z.jsx)(Jve,{row:n,actions:a}):void 0,cells:i.getAllCells().map(t=>{let r=(0,z.jsx)(ye.FlexRender,{cell:t}),i=!!d?.editable(n,t.column.id),a=l&&t.column.id===Fe&&!i?(0,z.jsx)(Qu,{to:l(n),className:`flex min-w-0 items-center hover:underline`,children:r}):r;return{spec:A.find(e=>e.id===t.column.id),...Pe?Pe.cell(e,n,t.column.id,a):{content:a}}})};return b?(0,z.jsx)(Tye,{...o,row:n,label:b.label(n)},n.id):(0,z.jsx)(n3,{...o},n.id)}),Be=(0,z.jsx)(`div`,{ref:Te.attach,onScroll:De,className:`overflow-x-auto overflow-y-hidden overscroll-x-contain [-webkit-overflow-scrolling:touch]`,children:(0,z.jsx)(`div`,{ref:ue,className:`relative`,style:{minWidth:Ie,height:F.contentHeight},children:b?(0,z.jsx)(wye,{ids:Array.from({length:M},(e,t)=>he(t)?.id??`missing-${t}`),rowAt:he,reorder:b,children:ze}):ze})});return(0,z.jsxs)(`div`,{ref:Ne,role:`grid`,"aria-rowcount":M,onKeyDown:Pe?.onKeyDown,className:g(`flex flex-col rounded-lg border bg-background`,Le?`min-h-0 overflow-hidden`:`overflow-clip`,C),style:x&&Le?{height:g3+M*T+2}:void 0,children:[(0,z.jsxs)(`div`,{className:g(`relative`,Le&&`flex min-h-0 flex-1 flex-col`),children:[Le?(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,children:[Re,Be]}):(0,z.jsxs)(z.Fragment,{children:[Re,Be]}),Te.more&&(0,z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 right-0 z-20 w-8 bg-gradient-to-l from-backdrop/15 to-transparent`})]}),!x&&(0,z.jsx)(Gve,{total:M,className:Le?void 0:`sticky bottom-[var(--pb-sticky-bottom,0px)] z-20`,selectedCount:xe,bulkActions:Wve(p??[],Object.keys(ne).flatMap(e=>Se.current.get(e)??[])).map(({action:e,rows:t,skipped:n})=>({label:e.label(t.length),destructive:e.destructive,onRun:()=>{e.onRun(t,n),re({}),Se.current.clear()}}))})]})},Eye=500,v3=async(e,t,n)=>{let r=[],i={},a;do{let o=await e.search(t,{...n,pageSize:Eye,...a&&{pageToken:a}});r.push(...o.items);for(let[e,t]of Object.entries(o.labels??{}))i[e]={...i[e],...t};a=o.nextPageToken||void 0}while(a);return{items:r,labels:i}},y3=Vn(),b3=(...e)=>{let t=e.filter(e=>!!e);return t.length===1?t[0]:t.map(e=>`(${e})`).join(` AND `)},x3=e=>e==null?void 0:String(e),Dye=(e,t,n)=>{let r=new Map;for(let[t,n]of e)r.set(n,(r.get(n)??new Set).add(t));let i=new Map;for(let e of t){let t=e[n],a=x3(typeof t==`object`&&t&&`id`in t?t.id:t);for(let t of a===void 0?[]:r.get(a)??[])i.set(t,[...i.get(t)??[],e])}return i},Oye=async(e,t,n,r)=>{let i=n.through;if(!i)return r.map(e=>[e,e]);let a=t[i.resource],o=i.key??a?.primaryKey[0];if(!a||o===void 0)throw Error(`The related column ${n.name} names a join resource the app does not have: ${i.resource}`);return(await v3(e,a.name,{filter:b3(Fn(y3.in(i.field,r)),i.filter),fields:[i.field,o]})).items.flatMap(e=>{let t=x3(e[i.field]),n=x3(e[o]);return t===void 0||n===void 0?[]:[[t,n]]})},kye=async({client:e,resources:t,views:n,load:r,owners:i})=>{let{column:a,fields:o}=r,s=t[a.resource];if(!s)throw Error(`The related column ${a.name} shows a resource the app does not have: ${a.resource}`);if(i.length===0)return new Map;let c=await Oye(e,t,a,i),l=[...new Set(c.map(([,e])=>e))];if(l.length===0)return new Map;let u=[...new Set([...s.primaryKey,a.field,a.status,...o])],d=Y0(t,n,s,u),f=await v3(e,s.name,{filter:b3(Fn(y3.in(a.field,l)),a.filter),...a.sort&&{orderBy:a.sort},fields:u,labels:d});return Dye(c,X0(t,s,u,f.items,f.labels),a.field)},Aye=5e3,jye=({queryClient:e,client:t,resources:n,views:r,model:i,columns:a,filter:o,orderBy:s,related:c=[]})=>{let l=c.map(e=>e.column.name).join(`,`),u=e=>c.length===0?U.page(i.name,o,s,40,e):[...U.page(i.name,o,s,40,e),l],d=Y0(n,r,i,a),f=oS(r[i.name]),p=async e=>e.nextPageToken===``?e.items.length:e.totalSizeEstimate>Aye?e.totalSizeEstimate:(await t.list(i.name,{filter:o,orderBy:s,pageSize:1,count:`exact`})).totalSize??e.totalSizeEstimate,m=async t=>{if(t===0)return``;let n=u(t-1),r=e.getQueryData(n);if(r)return r.nextPageToken;if(e.getQueryState(n)?.fetchStatus===`fetching`)return(await g(t-1)).nextPageToken},h=async e=>{let l=await m(e);if(e>0&&l===``)return{rows:[],total:0,nextPageToken:``};let u={filter:o,orderBy:s,pageSize:40,labels:d,photos:f},h=l===void 0?await t.seek(i.name,{...u,position:e*40}):await t.list(i.name,{...u,pageToken:l});if(h.items.length===0&&e>0)return{rows:[],total:0,nextPageToken:``};let g=h.items.map(e=>Gx(i,e)),_=X0(n,i,a,sS(i,h.items,h.photos),h.labels),v=await Promise.all(c.map(e=>kye({client:t,resources:n,views:r,load:e,owners:g})));return{rows:_.map((e,t)=>({...e,...Object.fromEntries(c.map((e,n)=>[e.column.name,v[n].get(g[t])??[]])),id:g[t]})),total:e===0?await p(h):h.totalSizeEstimate,nextPageToken:h.nextPageToken}},g=t=>e.fetchQuery({queryKey:u(t),staleTime:6e4,queryFn:()=>h(t)});return{page:g,loadRows:async e=>(await g(Math.floor(e/40))).rows}},S3=({resources:e,views:t,model:n,columns:r,filter:i,orderBy:a,related:o})=>{let s=W(),c=Km(),l=r.join(`,`),u=JSON.stringify(o??[]),d=(0,L.useMemo)(()=>jye({queryClient:c,client:s,resources:e,views:t,model:n,columns:r,filter:i,orderBy:a,...o&&{related:o}}),[c,s,e,t,n,l,i,a,u]),f=Kh({queryKey:[...U.first(n.name,i,a),l],queryFn:async()=>(await c.invalidateQueries({queryKey:U.pages(n.name,i,a),refetchType:`none`}),d.page(0))});return{source:(0,L.useMemo)(()=>f.data?{total:f.data.total,loadRows:d.loadRows,revision:f.dataUpdatedAt}:void 0,[f.data,f.dataUpdatedAt,d]),error:f.error,isLoading:f.isLoading,page:d.page,key:[...U.first(n.name,i,a),l]}},Q=a({en:{saveSearch:`Save search`,saveAsNew:e=>`Save as new ${e}`,updateName:e=>`Update ${e}`,updateNameQuestion:e=>`Update ${e}?`,updateNounQuestion:e=>`Update this ${e}?`,couldNotLoadYour:e=>`Could not load your ${e}`,noneYet:e=>`No ${e} yet.`,somethingWrong:`Something went wrong`,couldNotRename:`Could not rename the search`,renameTitle:e=>`Rename ${e}`,deleteTitle:e=>`Delete ${e}`,unreadableFilter:`A filter that cannot be read`,notFound:`Not found`,noResource:`There is no resource called {}.`,noSavedYet:e=>`No ${e} yet. Filter the {} and save the search.`,on:`On`,off:`Off`,saved:e=>`${e} saved`,couldNotChange:`Could not change the search`,asMany:e=>`As many ${e}`,more:(e,t)=>`${e} more ${t}`,fewer:(e,t)=>`${e} fewer ${t}`,cancel:`Cancel`,save:`Save`,optional:`Optional`,added:`Added`,removed:`Removed`,changed:`Changed`,filterChanges:`Filter changes`,firstOf:(e,t)=>`The first ${e} of ${t}.`,noPlural:e=>`No ${e}.`,update:`Update`,addedRemoved:(e,t)=>`${e} added, ${t} removed`,searchSaved:`Search saved`,openPlural:e=>`Open ${e.toLowerCase()}`,couldNotSave:`Could not save the search`,couldNotTakeOff:`Could not take the search off`,searchUpdated:`Search updated`,couldNotUpdate:`Could not update the search`,noneMatch:e=>`No ${e} match.`,noNew:e=>`No new ${e} since you last looked.`,viewAll:`View all results`,filters:`Filters`},nl:{saveSearch:`Zoekopdracht bewaren`,saveAsNew:e=>`Als extra ${e} bewaren`,updateName:e=>`${e} bijwerken`,updateNameQuestion:e=>`${e} bijwerken?`,updateNounQuestion:e=>`${e} bijwerken?`,couldNotLoadYour:e=>`Kon je ${e} niet laden`,noneYet:e=>`Nog geen ${e}.`,somethingWrong:`Er ging iets mis`,couldNotRename:`Kon de zoekopdracht niet hernoemen`,renameTitle:e=>`${e} hernoemen`,deleteTitle:e=>`${e} verwijderen`,unreadableFilter:`Een filter dat niet kan worden gelezen`,notFound:`Niet gevonden`,noResource:`Er is geen onderdeel met de naam {}.`,noSavedYet:e=>`Nog geen ${e}. Filter de {} en bewaar de zoekopdracht.`,on:`Aan`,off:`Uit`,saved:e=>`${e} bewaard`,couldNotChange:`Kon de zoekopdracht niet wijzigen`,asMany:e=>`Evenveel ${e}`,more:(e,t)=>`${e} ${t} meer`,fewer:(e,t)=>`${e} ${t} minder`,cancel:`Annuleren`,save:`Bewaren`,optional:`Optioneel`,added:`Erbij`,removed:`Eraf`,changed:`Gewijzigd`,filterChanges:`Wijzigingen in het filter`,firstOf:(e,t)=>`De eerste ${e} van ${t}.`,noPlural:e=>`Geen ${e}.`,update:`Bijwerken`,addedRemoved:(e,t)=>`${e} erbij, ${t} eraf`,searchSaved:`Zoekopdracht bewaard`,openPlural:e=>`${e} openen`,couldNotSave:`Kon de zoekopdracht niet bewaren`,couldNotTakeOff:`Kon de zoekopdracht niet weghalen`,searchUpdated:`Zoekopdracht bijgewerkt`,couldNotUpdate:`Kon de zoekopdracht niet bijwerken`,noneMatch:e=>`Geen ${e} gevonden.`,noNew:e=>`Geen nieuwe ${e} sinds je laatst keek.`,viewAll:`Alle resultaten bekijken`,filters:`Filters`}}),C3=`inline-flex h-6 items-center rounded-full border border-primary-border bg-primary-soft px-2.5 text-xs font-medium text-primary-text`,w3=({chips:e,className:t})=>(0,z.jsx)(`ul`,{className:g(`flex flex-wrap gap-1.5`,t),"aria-label":Q(`filters`),children:e.map(e=>(0,z.jsx)(`li`,{className:C3,children:e.label},e.key))}),T3=({chips:e})=>(0,z.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,t)=>(0,z.jsxs)(`span`,{className:C3,children:[t>0&&(0,z.jsx)(`span`,{className:`sr-only`,children:`, `}),e.label]},e.key))}),Mye=e=>e.map(e=>e.label).join(`, `),E3=a({en:{today:`Today`,yesterday:`Yesterday`,"24h":`Last 24 hours`,"7d":`Last 7 days`,"30d":`Last 30 days`,"90d":`Last 90 days`,month:`This month`,quarter:`This quarter`,year:`This year`,unknownPreset:e=>`The server offers the preset "${e}", which this UI does not know`,unsupported:e=>`${e} (unsupported)`,remove:e=>`Remove ${e}`,clearAll:`Clear all`,searchIn:e=>`Search ${e.toLowerCase()}`,noMatches:`No matches`,moreFilters:`More filters`,filters:`Filters`,date:`Date`,showOnly:`Show only`,minimum:e=>`${e} minimum`,maximum:e=>`${e} maximum`},nl:{today:`Vandaag`,yesterday:`Gisteren`,"24h":`Afgelopen 24 uur`,"7d":`Afgelopen 7 dagen`,"30d":`Afgelopen 30 dagen`,"90d":`Afgelopen 90 dagen`,month:`Deze maand`,quarter:`Dit kwartaal`,year:`Dit jaar`,unknownPreset:e=>`De server biedt de periode "${e}", die deze UI niet kent`,unsupported:e=>`${e} (niet ondersteund)`,remove:e=>`${e} verwijderen`,clearAll:`Alles wissen`,searchIn:e=>`Zoeken in ${e.toLowerCase()}`,noMatches:`Niets gevonden`,moreFilters:`Meer filters`,filters:`Filters`,date:`Datum`,showOnly:`Alleen tonen`,minimum:e=>`${e} minimum`,maximum:e=>`${e} maximum`}}),Nye=`inline-flex h-6 items-center gap-1 rounded-full border border-primary-border bg-primary-soft pl-2.5 pr-1.5 text-xs font-medium text-primary-text`,D3=({chips:e,lockedLabels:t=[],onRemove:n,onClear:r,scroll:i})=>e.length===0&&t.length===0?null:(0,z.jsxs)(`div`,{className:i?`flex flex-nowrap items-center gap-1.5 overflow-x-auto pb-1 [&>*]:shrink-0`:`flex flex-wrap items-center gap-1.5`,children:[t.map(e=>(0,z.jsxs)(`span`,{className:`inline-flex h-6 items-center gap-1.5 rounded-full border border-border-strong bg-muted px-2.5 text-xs font-medium text-foreground`,children:[(0,z.jsx)(ste,{className:`size-3 text-muted-foreground`}),e]},e)),e.map(e=>(0,z.jsxs)(`span`,{className:Nye,children:[e.label,(0,z.jsx)(`button`,{type:`button`,"aria-label":E3(`remove`,e.label),onClick:()=>n(e.key),className:`rounded-full p-0.5 hover:bg-primary-border/60`,children:(0,z.jsx)(ss,{className:`size-3`})})]},e.key)),e.length>0&&(0,z.jsx)(`button`,{type:`button`,onClick:r,className:`ml-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:E3(`clearAll`)})]}),Pye=[`today`,`7d`,`30d`,`year`],Fye=new Set([`today`,`yesterday`,`24h`,`7d`,`30d`,`90d`,`month`,`quarter`,`year`]),O3=e=>Fye.has(e)?E3(e):void 0,Iye=({value:e,presets:t=Pye,onChange:n})=>(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let r=O3(t);return(0,z.jsx)(`button`,{type:`button`,disabled:!r,title:r?void 0:E3(`unknownPreset`,t),onClick:()=>n(e===t?void 0:t),className:g(`h-7 rounded-md border px-2.5 text-body font-medium transition-colors`,!r&&`border-dashed text-danger-text`,e===t?`border-primary-border bg-primary-soft text-primary-text`:`border-border-strong bg-background text-muted-foreground hover:bg-muted`),children:r??E3(`unsupported`,t)},t)})}),k3=({label:e,onRemove:t})=>(0,z.jsxs)(`span`,{className:`inline-flex h-5 max-w-full items-center gap-0.5 rounded bg-primary-soft pl-1.5 pr-0.5 text-xs font-medium text-primary-text`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:e}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Kd(`remove`,e),className:`rounded p-0.5 hover:bg-primary-border/60`,onMouseDown:e=>e.preventDefault(),onClick:t,children:(0,z.jsx)(ss,{className:`size-3`})})]}),A3={facets:{},toggles:[]},j3=(e,t,n)=>{let r=e.facets[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{...e,facets:{...e.facets,[t]:i}}},M3=(e,t)=>({...e,toggles:e.toggles.includes(t)?e.toggles.filter(e=>e!==t):[...e.toggles,t]}),N3=(e,t,n)=>{let{[t]:r,...i}=e.ranges??{};return{...e,ranges:n?{...i,[t]:n}:i}},P3=(e,t)=>e.options.find(e=>e.value===t)?.label??e.labels?.[t]??t,F3=(e,t)=>{let n=e.facets.flatMap(e=>(t.facets[e.id]??[]).map(t=>({key:`facet:${e.id}:${t}`,label:`${e.label}: ${P3(e,t)}`}))),r=(e.ranges??[]).flatMap(e=>{let n=t.ranges?.[e.id];return n?[{key:`range:${e.id}`,label:`${e.label}: ${e.format(n[0])} – ${e.format(n[1])}`}]:[]}),i=t.date?[{key:`date`,label:O3(t.date)??t.date}]:[],a=t.toggles.map(t=>({key:`toggle:${t}`,label:e.toggles?.find(e=>e.id===t)?.label??t}));return[...n,...r,...i,...a]},I3=(e,t)=>{if(t===`date`)return{...e,date:void 0};let[n,r,i]=t.split(`:`);if(n===`range`)return N3(e,r,void 0);if(n===`toggle`)return M3(e,r);if(n===`facet`)return j3(e,r,i);throw Error(`Unknown filter chip key: ${t}`)},L3=(e,t)=>e.toLowerCase().includes(t.trim().toLowerCase()),Lye=(e,t)=>e.onSearch?e.options:e.options.filter(e=>L3(e.label,t)),Rye=(e,t,n)=>t===0?-1:n===`ArrowDown`?e<0?0:(e+1)%t:e<0?t-1:(e-1+t)%t,zye=({config:e,selected:t,onToggle:n,inline:r=!1})=>{let i=(0,L.useId)(),a=(0,L.useRef)(null),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(-1),f=r||c,p=Lye(e,o),m=(0,L.useRef)(e.onSearch);m.current=e.onSearch,(0,L.useEffect)(()=>()=>m.current?.(``),[]);let h=t=>{s(t),d(-1),e.onSearch?.(t)};return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-h-8 cursor-text flex-wrap items-center gap-1 rounded-md border border-border-strong bg-background px-2 py-1 shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20`,onClick:()=>a.current?.focus(),children:[(0,z.jsx)(_o,{className:`size-3.5 shrink-0 text-muted-foreground`}),t.map(t=>(0,z.jsx)(k3,{label:P3(e,t),onRemove:()=>n(t)},t)),(0,z.jsx)(`input`,{ref:a,autoFocus:r,role:`combobox`,"aria-label":e.label,"aria-expanded":f,"aria-controls":`${i}-options`,"aria-autocomplete":`list`,"aria-activedescendant":p[u]?`${i}-${u}`:void 0,placeholder:t.length>0?``:E3(`searchIn`,e.label),className:`h-6 min-w-16 flex-1 bg-transparent text-foreground outline-none placeholder:text-faint-foreground`,value:o,onChange:e=>h(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),d(Rye(u,p.length,e.key));return}if(e.key===`Enter`&&p[u]){e.preventDefault(),n(p[u].value);return}if(e.key===`Backspace`&&o===``&&t.length>0){n(t[t.length-1]);return}e.key===`Escape`&&o!==``&&(e.stopPropagation(),h(``))},onFocus:()=>l(!0),onBlur:()=>{l(!1),d(-1),!r&&o!==``&&h(``)}})]}),f&&(0,z.jsxs)(`ul`,{id:`${i}-options`,role:`listbox`,"aria-label":e.label,"aria-multiselectable":!0,className:g(`flex max-h-60 flex-col gap-px overflow-y-auto`,!r&&`rounded-md border bg-background p-1 shadow-sm`),children:[p.map((e,r)=>{let a=t.includes(e.value);return(0,z.jsxs)(`li`,{id:`${i}-${r}`,role:`option`,"aria-selected":a,tabIndex:-1,className:g(`flex cursor-pointer items-center gap-2 rounded px-1.5 py-1 hover:bg-muted`,r===u&&`bg-muted`),onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.value),children:[(0,z.jsx)(`span`,{className:g(`inline-flex size-4 shrink-0 items-center justify-center rounded border`,a?`border-primary bg-primary text-primary-foreground`:`border-border-strong bg-background`),children:a&&(0,z.jsx)(xi,{className:`size-3`,strokeWidth:3})}),(0,z.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,z.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:Mf(e.count)})]},e.value)}),p.length===0&&(0,z.jsx)(`li`,{className:`px-1.5 py-1 text-xs text-faint-foreground`,children:E3(`noMatches`)})]})]})},Bye=({config:e,selected:t,onToggle:n})=>{let[r,i]=(0,L.useState)(``),a=e.options.filter(e=>L3(e.label,r));return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.searchable&&(0,z.jsx)(Wd,{wrapperClassName:`mb-1 h-7`,leading:(0,z.jsx)(_o,{className:`size-3.5`}),placeholder:E3(`searchIn`,e.label),value:r,onChange:e=>i(e.target.value)}),a.map(e=>(0,z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-1 hover:bg-muted`,children:[(0,z.jsx)(xg,{checked:t.includes(e.value),onChange:()=>n(e.value),label:e.label}),(0,z.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,z.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:Mf(e.count)})]},e.value)),a.length===0&&(0,z.jsx)(`span`,{className:`px-1 py-1 text-xs text-faint-foreground`,children:E3(`noMatches`)})]})},R3=({label:e,activeCount:t,width:n=240,defaultOpen:r=!1,children:i})=>{let[a,o]=(0,L.useState)(r),[s,c]=(0,L.useState)(!1),l=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{a&&l.current&&c(l.current.getBoundingClientRect().left+n>document.documentElement.clientWidth)},[a,n]),(0,L.useEffect)(()=>{if(!a)return;let e=e=>{e.target instanceof Node&&!l.current?.contains(e.target)&&o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]),(0,z.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,z.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(!a),className:g(`inline-flex h-8 items-center gap-1.5 rounded-md border bg-background px-2.5 font-medium shadow-sm transition-colors hover:bg-muted`,t>0?`border-primary-border text-primary-text`:`border-border-strong text-foreground`),children:[e,t>0&&(0,z.jsx)(`span`,{className:`rounded-full bg-primary px-1.5 text-[11px] leading-4 text-primary-foreground`,children:t}),(0,z.jsx)(Ci,{className:`size-3.5 text-muted-foreground`})]}),a&&(0,z.jsx)(`div`,{className:g(`absolute top-full z-30 mt-1.5 rounded-lg border bg-background p-3 shadow-pop`,s?`right-0`:`left-0`),style:{width:n},children:typeof i==`function`?i(()=>o(!1)):i})]})},z3=({title:e,children:t})=>(0,z.jsxs)(`section`,{className:`flex flex-col gap-2 border-b py-3 last:border-b-0`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),t]}),B3=(e,t,n)=>{if(n!==0){if(e===`Home`)return 0;if(e===`End`)return n-1;if(e===`ArrowDown`)return t<0?0:(t+1)%n;if(e===`ArrowUp`)return t<0?n-1:(t-1+n)%n}},Vye=({items:e,onPick:t,close:n})=>{let r=(0,L.useRef)([]);return(0,L.useEffect)(()=>r.current[0]?.focus(),[]),(0,z.jsx)(`ul`,{role:`menu`,"aria-label":E3(`moreFilters`),onKeyDown:t=>{if(t.key===`Escape`)return n();let i=B3(t.key,r.current.indexOf(document.activeElement),e.length);i!==void 0&&(t.preventDefault(),r.current[i]?.focus())},className:`-mx-3 -my-3`,children:e.map((e,i)=>(0,z.jsx)(`li`,{role:`none`,children:(0,z.jsx)(`button`,{ref:e=>{r.current[i]=e},type:`button`,role:`menuitem`,className:goe,onClick:()=>{n(),t(e.key)},children:e.label})},e.key))})},Hye=({items:e,onPick:t})=>e.length===0?null:(0,z.jsx)(R3,{label:E3(`moreFilters`),activeCount:0,children:n=>(0,z.jsx)(Vye,{items:e,onPick:t,close:n})}),V3=(e,t)=>{let[n,r]=(0,L.useState)(e);return(0,L.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n},Uye=(e,t,n,r,i)=>{let a=n+(r-n)*e/t;return n+(r-n)*(e+1)/t>i[0]&&a<i[1]},H3=(e,t,n)=>n===t?0:(e-t)/(n-t),Wye=(e,t,n)=>t===0?[Math.min(n,e[1]),e[1]]:[e[0],Math.max(n,e[0])],Gye=1e3,Kye=({config:e,value:t,onChange:n})=>{let{min:r,max:i,step:a,histogram:o,format:s}=e,[c,l]=(0,L.useState)(),u=c??t??[r,i],d=Math.max(...o),f=()=>{c&&(l(void 0),n(c[0]===r&&c[1]===i?void 0:c))},p=V3(c,Gye);return(0,L.useEffect)(()=>{p&&f()},[p]),(0,z.jsxs)(`div`,{className:`w-full`,children:[(0,z.jsxs)(`div`,{className:`px-[7px]`,children:[o.length>0&&(0,z.jsx)(`div`,{className:`mb-1 flex h-12 items-end gap-0.5`,children:o.map((e,t)=>(0,z.jsx)(`span`,{className:g(`flex-1 rounded-t-sm`,Uye(t,o.length,r,i,u)?`bg-primary/70`:`bg-border`),style:{height:`${Math.max(6,e/d*100)}%`}},t))}),(0,z.jsxs)(`div`,{className:`relative h-4`,children:[(0,z.jsx)(`span`,{className:`absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-border`}),(0,z.jsx)(`span`,{className:`absolute top-1/2 h-1 -translate-y-1/2 rounded-full bg-primary`,style:{left:`${H3(u[0],r,i)*100}%`,right:`${100-H3(u[1],r,i)*100}%`}})]})]}),(0,z.jsx)(`div`,{className:`relative -mt-4 h-4`,children:[0,1].map(t=>(0,z.jsx)(`input`,{type:`range`,className:`pb-range`,"aria-label":E3(t===0?`minimum`:`maximum`,e.label),min:r,max:i,step:a,value:u[t],onChange:e=>l(Wye(u,t,Number(e.target.value))),onPointerUp:f,onTouchEnd:f,onBlur:f},t))}),(0,z.jsxs)(`div`,{className:`mt-2 flex justify-between text-xs tabular-nums text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:s(u[0])}),(0,z.jsx)(`span`,{children:s(u[1])})]})]})},qye=e=>[...new Set(e.map(e=>e.key.split(`:`).slice(0,2).join(`:`)))],U3=(e,t)=>{let n=t.filter(t=>!e.includes(t));return n.length===0?e:[...e,...n]},Jye=(e,t)=>{let n=[...e.facets.map(e=>({key:`facet:${e.id}`,label:e.label,secondary:e.secondary})),...(e.ranges??[]).map(e=>({key:`range:${e.id}`,label:e.label,secondary:e.secondary})),...e.datePresets?[{key:`date`,label:E3(`date`),secondary:e.dateSecondary}]:[],...(e.toggles??[]).map(e=>({key:`toggle:${e.id}`,label:e.label,secondary:e.secondary}))],r=new Set,i=[];for(let e of n)!e.secondary||t.includes(e.key)?r.add(e.key):i.push({key:e.key,label:e.label});return{shown:r,more:i}},W3=({label:e,checked:t,onChange:n})=>(0,z.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between gap-3 py-1`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(iC,{checked:t,onChange:n,label:e})]}),G3=(e,t)=>e.some(e=>e.length>0)||!!t,K3=({groups:e,trailing:t})=>{if(!G3(e,t))return null;let n=e.filter(e=>e.length>0);return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.map((e,t)=>(0,z.jsxs)(L.Fragment,{children:[t>0&&(0,z.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`}),e]},t)),t&&(0,z.jsx)(`div`,{className:`flex min-w-32 flex-1 justify-end`,children:t})]})},Yye=(e,t,n)=>{let[r,i]=(0,L.useState)(t??A3);return[e??r,e=>{i(e),n?.(e)}]},q3=({config:e,layout:t,value:n,defaultValue:r,onChange:i,lockedLabels:a,defaultOpenMenu:o,fullWidth:s,leading:c,trailing:l})=>{let[u,d]=Yye(n,r,i),f=F3(e,u),p=qye(f),[m,h]=(0,L.useState)(()=>p),[g,_]=(0,L.useState)();(0,L.useEffect)(()=>h(e=>U3(e,p)),[p.join(`,`)]);let v=(0,z.jsx)(D3,{chips:f,lockedLabels:a,onRemove:e=>d(I3(u,e)),onClear:()=>d(A3)}),y=(e,t=!1)=>{let n=u.facets[e.id]??[],r=t=>d(j3(u,e.id,t));return e.combobox?(0,z.jsx)(zye,{config:e,selected:n,onToggle:r,inline:t}):(0,z.jsx)(Bye,{config:e,selected:n,onToggle:r})},b=e.ranges??[],x=e=>(0,z.jsx)(Kye,{config:e,value:u.ranges?.[e.id],onChange:t=>d(N3(u,e.id,t))}),S=e.datePresets&&(0,z.jsx)(Iye,{value:u.date,presets:Array.isArray(e.datePresets)?e.datePresets:void 0,onChange:e=>d({...u,date:e})}),C=(e.toggles??[]).map(e=>(0,z.jsx)(W3,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(M3(u,e.id))},e.id));if(t===`panel`)return(0,z.jsxs)(`aside`,{className:s?`flex w-full flex-col gap-1`:`flex w-64 shrink-0 flex-col gap-1 overflow-y-auto rounded-lg border bg-background px-4 py-3`,children:[(0,z.jsx)(`div`,{className:`flex items-center justify-between pb-1`,children:(0,z.jsx)(`h2`,{className:`font-semibold`,children:E3(`filters`)})}),(f.length>0||(a?.length??0)>0)&&(0,z.jsx)(`div`,{className:`border-b pb-3`,children:v}),c,e.facets.map(e=>(0,z.jsx)(z3,{title:e.label,children:y(e)},e.id)),b.map(e=>(0,z.jsx)(z3,{title:e.label,children:x(e)},e.id)),S&&(0,z.jsx)(z3,{title:E3(`date`),children:S}),C.length>0&&(0,z.jsx)(z3,{title:E3(`showOnly`),children:C})]});let{shown:w,more:T}=Jye(e,m),E=e=>{h(t=>U3(t,[e])),_(e)},D=[...e.facets.filter(e=>w.has(`facet:${e.id}`)).map(e=>(0,z.jsx)(R3,{label:e.label,activeCount:(u.facets[e.id]??[]).length,width:e.combobox?280:void 0,defaultOpen:o===e.id||g===`facet:${e.id}`,children:y(e,!0)},e.id)),...b.filter(e=>w.has(`range:${e.id}`)).map(e=>(0,z.jsx)(R3,{label:e.label,activeCount:+!!u.ranges?.[e.id],width:280,defaultOpen:o===e.id||g===`range:${e.id}`,children:x(e)},`range:${e.id}`)),...S&&w.has(`date`)?[(0,z.jsx)(L.Fragment,{children:S},`date`)]:[]],O=(e.toggles??[]).filter(e=>w.has(`toggle:${e.id}`)).map(e=>(0,z.jsx)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:(0,z.jsx)(W3,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(M3(u,e.id))})},e.id)),k=[c?[(0,z.jsx)(L.Fragment,{children:c},`leading`)]:[],D,O,T.length>0?[(0,z.jsx)(Hye,{items:T,onPick:E},`more`)]:[]];return!G3(k,l)&&f.length===0&&!a?.length?null:(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(K3,{groups:k,trailing:l}),v]})},J3=Vn(),Y3={start:0,end:0},X3={"24h":{amount:24,unit:`h`},"7d":{amount:7,unit:`d`},"30d":{amount:30,unit:`d`},"90d":{amount:90,unit:`d`}},Xye=e=>new Date(e).toISOString().replace(`.000Z`,`Z`),Z3=(e,t,n)=>{let r=Hf(t.getTime(),n),[i,a]=[Number(r.slice(0,4)),Number(r.slice(5,7))-1],o=e=>new Date(e).toISOString().slice(0,10);return e===`year`?o(Date.UTC(i,0,1)):e===`quarter`?o(Date.UTC(i,Math.floor(a/3)*3,1)):e===`month`?o(Date.UTC(i,a,1)):e===`yesterday`?o(Date.parse(`${r}T00:00:00Z`)-864e5):r},Q3=[`year`,`quarter`,`month`,`yesterday`,`today`],$3=(e,t,n)=>t===`date`?e:Xye(Wf(e,n)),e6=(e,t,n)=>t===`date`?{kind:`string`,value:$3(e,t,n),span:Y3}:{kind:`timestamp`,value:$3(e,t,n),span:Y3},Zye=(e,t,n,r,i)=>{if(t in X3)return[J3.gte(e,J3.ago(t))];let a=J3.gte(e,e6(Z3(t,n,i),r,i));return t===`yesterday`?[a,J3.lt(e,e6(Z3(`today`,n,i),r,i))]:[a]},Qye=(e,t,n=new Date,r=If())=>{let i=e.facets.flatMap(e=>{let n=t.facets[e.id]??[];if(n.length===0)return[];if(e.flags){let t=e.options.filter(e=>n.includes(e.value)).map(e=>J3.eq(e.value,!0));return t.length===0?[]:[t.length===1?t[0]:J3.or(...t)]}return[n.length===1?J3.eq(e.id,n[0]):J3.in(e.id,n)]}),a=(e.ranges??[]).flatMap(e=>{let n=t.ranges?.[e.id];return n?[J3.gte(e.id,n[0]),J3.lte(e.id,n[1])]:[]}),o=e.dateField&&t.date?Zye(e.dateField,t.date,n,e.dateKind,r):[],s=(e.toggles??[]).filter(e=>t.toggles.includes(e.id)).map(e=>J3.eq(e.id,!0));return[...i,...a,...o,...s]},$ye=e=>e.length===0?``:Fn(J3.and(...e)),t6=(e,t,n=[],r=new Date,i=If())=>$ye([...Qye(e,t,r,i),...n]),n6=e=>e.kind===`and`?e.args.flatMap(n6):[e],r6=e=>e.field.path.join(`.`),ebe=e=>e.kind===`compare`&&e.op===`=`&&e.value.kind===`boolean`&&e.value.value,tbe=(e,t)=>{let n=e.kind===`or`?e.args:[e];if(!n.every(ebe))return;let r=n.map(r6),i=t.get(r[0]);return i!==void 0&&r.every(e=>t.get(e)===i)?{group:i,fields:r}:void 0},i6=e=>e.kind===`number`?String(e.raw):e.kind===`string`?String(e.value):void 0,a6=(e,t,n)=>{let r=e.value;if(r.kind===`now`&&r.offset?.sign===`-`){let{amount:e,unit:t}=r.offset.duration;return Object.entries(X3).find(([,n])=>n.amount===e&&n.unit===t)?.[0]}if(r.kind===`timestamp`)return Q3.find(e=>$3(Z3(e,t,n),`timestamp`,n)===r.value);if(r.kind===`string`)return Q3.find(e=>Z3(e,t,n)===r.value)},o6=(e,t,n=new Date,r=If())=>{let i=Xt(t);if(!i.ok)return{ok:!1,errors:i.errors};let a={facets:{},toggles:[]},o=[],s=new Set(e.facets.filter(e=>!e.flags).map(e=>e.id)),c=new Map(e.facets.filter(e=>e.flags).flatMap(e=>e.options.map(t=>[t.value,e.id]))),l=new Set((e.toggles??[]).map(e=>e.id)),u=new Set((e.ranges??[]).map(e=>e.id)),d=new Map,f,p;for(let t of i.ast?n6(i.ast):[]){let i=tbe(t,c);if(i&&!a.facets[i.group])a.facets[i.group]=i.fields;else if(t.kind===`compare`&&s.has(r6(t))&&t.op===`=`&&i6(t.value)!==void 0)a.facets[r6(t)]=[...a.facets[r6(t)]??[],i6(t.value)];else if(t.kind===`in`&&s.has(r6(t))&&t.values.every(e=>i6(e)!==void 0))a.facets[r6(t)]=[...a.facets[r6(t)]??[],...t.values.map(e=>i6(e))];else if(t.kind===`compare`&&e.dateField===r6(t)&&t.op===`>=`&&a6(t,n,r)&&!a.date)a.date=a6(t,n,r),f=t;else if(t.kind===`compare`&&e.dateField===r6(t)&&t.op===`<`&&(t.value.kind===`timestamp`||t.value.kind===`string`)&&t.value.value===$3(Z3(`today`,n,r),t.value.kind===`string`?`date`:`timestamp`,r))p=t;else if(t.kind===`compare`&&l.has(r6(t))&&t.op===`=`&&t.value.kind===`boolean`&&t.value.value)a.toggles.push(r6(t));else if(t.kind===`compare`&&u.has(r6(t))&&(t.op===`>=`||t.op===`<=`)&&t.value.kind===`number`){let e=d.get(r6(t))??{clauses:[]};t.op===`>=`?e.low=t.value.value:e.high=t.value.value,e.clauses.push(t),d.set(r6(t),e)}else o.push(t)}a.date===`yesterday`&&!p&&(o.push(f),a.date=void 0),p&&a.date!==`yesterday`&&o.push(p);for(let[e,t]of d)t.low!==void 0&&t.high!==void 0?a.ranges={...a.ranges,[e]:[t.low,t.high]}:o.push(...t.clauses);return{ok:!0,state:a,extras:o}},nbe=[`integer`,`bigint`,`decimal`],rbe=(e,t)=>{let n=e?.fields[t]?.type;return n!==void 0&&nbe.includes(n)},s6=(e,t)=>e.kind===`range`||e.kind===`facets`&&rbe(t,e.field),c6=e=>e.secondary?{secondary:!0}:{},ibe=e=>({id:e.field,label:e.field,min:0,max:0,step:1,histogram:[],format:String,...c6(e)}),l6=(e,t)=>{let n=e?.filters??[],r=n.find(e=>e.kind===`dateRange`);return{facets:n.flatMap(e=>e.kind===`facets`&&!s6(e,t)?[{id:e.field,label:e.field,options:[],searchable:e.search,...t?.fields[e.field]?.type===`relation`&&{combobox:!0},...c6(e)}]:e.kind===`flags`?[{id:e.fields.join(`|`),label:e.label,options:e.fields.map(e=>({value:e,label:e,count:0})),flags:!0,...c6(e)}]:[]),ranges:n.flatMap(e=>e.kind!==`flags`&&s6(e,t)?[ibe(e)]:[]),...r&&{dateField:r.field,...r.secondary&&{dateSecondary:!0},dateKind:t?.fields[r.field]?.type===`date`?`date`:`timestamp`,...r.presets.length>0&&{datePresets:r.presets}},toggles:n.flatMap(e=>e.kind===`toggle`?[{id:e.field,label:e.field,...c6(e)}]:[])}},u6=(e,t)=>(e?.filters??[]).some(e=>e.kind===`range`&&e.field===t&&e.histogram),d6=(e,t)=>{let n=e?.fields[t],r=n?.suffix??``;return e=>`${n?.prefix===`€`?kf(e*100).replace(`.00`,``):String(e)}${r}`},f6=Vn(),abe={start:0,end:0},obe=(e,t,n)=>{let r=o6(l6(t,e),n);return r.ok?Object.fromEntries(Object.entries(r.state.facets).filter(([t,n])=>e.fields[t]?.type===`relation`&&n.length>0)):{}},sbe=(e,t,n)=>{let r=e=>t?.fields[e]?.label??q(e),i=l6(t,e);return{...i,facets:i.facets.map(i=>{if(i.flags)return{...i,options:i.options.map(e=>({...e,label:r(e.value)}))};let a=e.fields[i.id]?.enumValues??[],o=e.fields[i.id]?.type===`enum`?Object.fromEntries(a.map(e=>[e,ps(e,t?.fields[i.id]?.valueLabels)])):n[i.id]??{};return{...i,label:r(i.id),labels:o}}),ranges:(i.ranges??[]).map(e=>({...e,label:r(e.id),format:d6(t,e.id)})),toggles:i.toggles?.map(e=>({...e,label:r(e.id)}))}},p6=(e,t,n,r={})=>{let i=sbe(e,t,r),a=o6(i,n);if(!a.ok)return[{key:`unreadable`,label:Q(`unreadableFilter`)}];let o=a.extras.map((e,t)=>({key:`extra:${t}`,label:e.kind===`search`?`"${e.text}"`:Fn(e)}));return[...F3(i,a.state),...o]},cbe=e=>Object.fromEntries(e.facets.filter(e=>!e.flags).map(e=>[e.id,{...e.labels,...Object.fromEntries(e.options.map(e=>[e.value,e.label]))}])),lbe=(e,t,n)=>{if(typeof n!=`string`||n===``)return e;let r=f6.gt(t,{kind:`timestamp`,value:new Date(n).toISOString(),span:abe}),i=Xt(e);if(!i.ok)throw Error(`The saved filter cannot be read: ${i.errors.map(e=>e.message).join(`; `)}`);return Fn(i.ast?f6.and(i.ast,r):r)},ube=(e,t)=>typeof t!=`string`||t===``?!0:typeof e!=`string`||e===``?!1:new Date(e).getTime()>new Date(t).getTime(),m6=(e,t)=>{let n=W(),r=Km(),{resources:i,views:a}=G(),o=a[e.name],s=Object.entries(obe(e,o,t)),c=Wh({queries:s.map(([t,o])=>{let s=i[e.fields[t].relation.resource];return{queryKey:U.labels(`chips:${e.name}.${t}`,o.join(`,`)),enabled:s!==void 0,queryFn:async()=>Object.fromEntries(await q0(r,n,s,o,a[s.name]))}})});return p6(e,o,t,Object.fromEntries(s.flatMap(([e],t)=>c[t]?.data?[[e,c[t].data]]:[])))},dbe=(e,t)=>({record:Object.fromEntries(Object.entries(t).filter(([t])=>Object.hasOwn(e.fields,t))),etag:typeof t.etag==`string`?t.etag:``,...typeof t.permissions==`object`&&t.permissions!==null&&{permissions:t.permissions}}),h6=e=>{let t=Km();return(0,L.useCallback)(n=>t.setQueryData(U.recordPreview(e.name,sr(Kx(e,n))),dbe(e,n)),[t,e])},fbe=Vn(),g6=e=>{if(typeof e==`string`||typeof e==`number`)return e;if(e&&typeof e==`object`&&`id`in e)return g6(e.id)},pbe=(e,t,n)=>n.flatMap(n=>{let r=g6(n[t]);return r===void 0?[]:[{key:sr(Kx(e,n)),target:r}]}),mbe=(e,t)=>e.find(e=>sr(e.target)===t),hbe=(e,t)=>[...e,{key:``,target:t}],gbe=(e,t)=>e.filter(e=>sr(e.target)!==t),_6=(e,t)=>{let[n]=e.primaryKey;if(e.primaryKey.length!==1||n===void 0)throw Error(`${e.name} has a composite key, so its saved records cannot be listed`);let r=[...new Set(t.map(e=>e.target))];return r.length===0?void 0:fbe.in(n,r)},v6=(e,t)=>U.list(e,``,``,500,`saved:${t}`),y6=(e,t,n)=>{let r=W(),i=G().resources[e];return Kh({queryKey:v6(e,t),enabled:n&&i!==void 0,queryFn:async()=>{let n=[],a;do{let o=await r.list(e,{pageSize:500,fields:[...i.primaryKey,t],...a&&{pageToken:a}});n.push(...o.items),a=o.nextPageToken||void 0}while(a);return pbe(i,t,n)}})},b6=a({en:{favorite:`Favorite`,couldNotLoadYour:e=>`Could not load your ${e}`,noneYet:e=>`No ${e} yet.`,somethingWrong:`Something went wrong`,couldNotTakeOff:`Could not take it off`,couldNotSave:`Could not save it`},nl:{favorite:`Favoriet`,couldNotLoadYour:e=>`Kon je ${e} niet laden`,noneYet:e=>`Nog geen ${e}.`,somethingWrong:`Er ging iets mis`,couldNotTakeOff:`Kon het niet weghalen`,couldNotSave:`Kon het niet bewaren`}}),_be=e=>e instanceof Error?e.message:b6(`somethingWrong`),vbe=(e,t,n)=>{let r=G(),i=W(),a=Km(),o=Hb(),s=RT(),{resource:c,field:l}=e,u=r.permissions[c],d=r.resources[c]!==void 0&&u!==void 0&&xT(u,`create`)&&xT(u,`delete`),f=r.signIn?.[c]?.signIn,p=y6(c,l,d),m=p.data&&mbe(p.data,t),h=v6(c,l),g=qh({mutationFn:async e=>{e?await i.remove(c,e.key):await i.create(c,{[l]:n})},onMutate:async e=>{await a.cancelQueries({queryKey:h,exact:!0});let r=a.getQueryData(h);return a.setQueryData(h,(r=[])=>e?gbe(r,t):hbe(r,n)),{before:r}},onError:(e,t,n)=>{a.setQueryData(h,n?.before),o.show({state:`error`,title:b6(t?`couldNotTakeOff`:`couldNotSave`),description:_be(e)})},onSettled:()=>s(c)});return{mode:d?`save`:f?`sign-in`:void 0,prompt:f,saved:m!==void 0,ready:p.data!==void 0&&!g.isPending,toggle:()=>g.mutate(m)}},ybe=({favorite:e,recordKey:t,target:n,className:r})=>{let i=vbe(e,t,n),[a,o]=(0,L.useState)(!1);if(!i.mode)return null;let s=e.label??b6(`favorite`),c=g(`absolute right-2 top-2 flex size-8 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm transition-colors hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,r);return i.mode===`sign-in`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":s,"aria-haspopup":`dialog`,className:c,onClick:()=>o(!0),children:(0,z.jsx)(oa,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(Wm,{as:`dialog`,prompt:i.prompt,open:a,onClose:()=>o(!1)})]}):(0,z.jsx)(`button`,{type:`button`,"aria-label":s,"aria-pressed":i.saved,"aria-disabled":!i.ready,className:c,onClick:()=>i.ready&&i.toggle(),children:(0,z.jsx)(oa,{className:g(`size-4`,i.saved&&`fill-current text-danger`),"aria-hidden":!0})})},x6=6,bbe=(e,t,n)=>{let r=e.bottom+x6;return{top:r+t.height>n.height-x6?Math.max(x6,e.top-x6-t.height):r,left:Math.max(x6,Math.min(e.left,n.width-x6-t.width))}},S6=(e,t)=>{let n=fS(e).find(e=>e.kind===`cards`);if(!n)return{kind:`cards`,name:`dot`,badge:t};let{photos:r,favorite:i,dots:a,...o}=n;return o},xbe=(e,t,n,r)=>(e?.list?.relatedColumns??[]).filter(e=>r.includes(e.name)).flatMap(e=>{let r=t[e.resource];return r?[{column:e,fields:xS(r,n[r.name],S6(n[r.name],e.status))}]:[]}),Sbe=a({en:{none:e=>`No ${e}`},nl:{none:e=>`Geen ${e}`}}),Cbe=(e,{values:t,label:n,singular:r,plural:i})=>{if(e.length===0)return Sbe(`none`,i);let a=new Map;for(let t of e)t!=null&&a.set(String(t),(a.get(String(t))??0)+1);let o=[...t,...[...a.keys()].filter(e=>!t.includes(e))].filter(e=>a.has(e)).map(e=>`${a.get(e)} ${n(e)}`),s=`${e.length} ${e.length===1?r:i}`;return o.length===0?s:`${s}: ${o.join(`, `)}`},C6=`flex shrink-0 items-center justify-center rounded-full p-0.5 pointer-coarse:p-1.5`,w6=`size-2.5 rounded-full`,T6=`flex min-w-0 items-center gap-0.5`,wbe=150,E6=288,Tbe=({shown:e,row:t,target:n,view:r,column:i,Card:a,onEnter:o,onLeave:s})=>{let c=(0,L.useRef)(null),[l,u]=(0,L.useState)();return(0,L.useLayoutEffect)(()=>{c.current&&u(bbe(e.dot,{width:E6,height:c.current.offsetHeight},{width:window.innerWidth,height:window.innerHeight}))},[e]),(0,ls.createPortal)((0,z.jsx)(`div`,{ref:c,"data-dot-card":!0,onMouseEnter:o,onMouseLeave:s,style:{width:E6,...l??{visibility:`hidden`,top:0,left:0}},className:`fixed z-50 rounded-lg shadow-pop`,children:(0,z.jsx)(a,{model:n,view:r,display:S6(r,i.status),row:t})}),document.body)},D6=({column:e,records:t,target:n,view:r,wrap:i=!1,Card:a})=>{let o=(0,L.useMemo)(()=>t.map(e=>CS(n,e)),[t,n]),[s,c]=(0,L.useState)(),l=(0,L.useRef)(void 0),u=(0,L.useRef)(`mouse`),d=(0,L.useRef)(null),f=n.fields[e.status],p=r?.fields[e.status],m=t=>f?rS(f,t.record[e.status],p):``,h=Hx(n,r),_=e=>e.labels[h]??String(e.record[h]??e.key),v=(r?.names?.singular??q(n.name)).toLowerCase(),y=(r?.names?.plural??q(n.name)).toLowerCase(),b=Cbe(o.map(t=>t.record[e.status]),{values:f?.enumValues??[],label:e=>f?rS(f,e,p):e,singular:v,plural:y}),x=()=>window.clearTimeout(l.current),S=()=>{x(),l.current=window.setTimeout(()=>c(void 0),wbe)},C=(e,t)=>{x(),c({key:e,dot:t.getBoundingClientRect()})};(0,L.useEffect)(()=>x,[]),(0,L.useEffect)(()=>{if(!s)return;let e=()=>c(void 0),t=t=>t.key===`Escape`&&e(),n=t=>{let n=t.target;!d.current?.contains(n)&&!n?.closest?.(`[data-dot-card]`)&&e()};return document.addEventListener(`keydown`,t),document.addEventListener(`pointerdown`,n),document.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{document.removeEventListener(`keydown`,t),document.removeEventListener(`pointerdown`,n),document.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[s]);let w=e=>t=>{u.current===`touch`&&s?.key!==e&&(t.preventDefault(),C(e,t.currentTarget))},T=e=>{e.relatedTarget?.closest?.(`[data-dot-card]`)||S()},E=s&&o.find(e=>e.key===s.key);return(0,z.jsxs)(`div`,{ref:d,className:g(T6,i&&`pointer-events-none flex-wrap`),onClick:e=>e.stopPropagation(),onPointerDown:e=>u.current=e.pointerType,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:b}),o.map(t=>{let r=t.record[e.status],i=Z0(p?.valueColors,r);return(0,z.jsx)(jS,{to:{kind:`record`,resource:n.name,key:t.key},"aria-label":`${_(t)}, ${m(t)}`,onPointerEnter:e=>e.pointerType!==`touch`&&C(t.key,e.currentTarget),onPointerLeave:e=>e.pointerType!==`touch`&&S(),onFocus:e=>e.currentTarget.matches(`:focus-visible`)&&C(t.key,e.currentTarget),onBlur:T,onClick:w(t.key),className:g(C6,`pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`),children:(0,z.jsx)(`span`,{"aria-hidden":!0,style:i===void 0?void 0:{backgroundColor:i},className:g(w6,i===void 0&&hd[Qx(String(r))],s?.key===t.key&&`ring-2 ring-foreground/30`)})},t.key)}),s&&E&&(0,z.jsx)(Tbe,{shown:s,row:E,target:n,view:r,column:e,Card:a,onEnter:x,onLeave:S})]})},Ebe=({count:e})=>(0,z.jsx)(`span`,{"aria-hidden":!0,className:g(T6,`invisible flex-wrap`),children:Array.from({length:e},(e,t)=>(0,z.jsx)(`span`,{className:C6,children:(0,z.jsx)(`span`,{className:w6})},t))}),O6=`flex flex-col gap-1.5`,Dbe=({dots:e})=>(0,z.jsx)(`span`,{className:O6,children:e.map(({column:e,records:t})=>(0,z.jsx)(Ebe,{count:t.length},e.name))}),Obe=({dots:e,Card:t})=>{let{resources:n,views:r}=G();return(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-[calc(0.75rem+1px)] bottom-[calc(0.75rem+1px)] ${O6}`,children:e.map(({column:e,records:i})=>{let a=n[e.resource];return a&&(0,z.jsx)(D6,{column:e,records:i,target:a,view:r[a.name],Card:t,wrap:!0},e.name)})})},kbe=(e,t,n)=>(t.dots??[]).flatMap(t=>{let r=e?.list?.relatedColumns?.find(e=>e.name===t),i=n.record[t];return r&&Array.isArray(i)&&i.length>0?[{column:r,records:i}]:[]}),k6=({value:e})=>{let t=dx(e,{width:320,height:240});return t?(0,z.jsx)(fC,{image:t,loading:`lazy`,className:`size-full object-cover`}):null},A6=({children:e})=>(0,z.jsx)(`span`,{className:`-mx-3 -mt-3 mb-1.5 block aspect-[4/3] overflow-hidden rounded-t-lg border-b border-border bg-muted`,children:e}),Abe=({value:e})=>(0,z.jsx)(A6,{children:(0,z.jsx)(k6,{value:e})}),jbe=10,Mbe=(e,t)=>{let n=tx(e)?e.uri:void 0,r=t.filter(e=>tx(e)&&e.uri!==n);return(n===void 0?r:[e,...r]).slice(0,jbe)},Nbe=(e,t)=>t===0?0:(e%t+t)%t,Pbe=(e,t,n)=>t<=0||n===0?0:Math.min(n-1,Math.max(0,Math.round(e/t))),j6=`pointer-events-auto absolute top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm opacity-0 transition-opacity group-has-[[data-card-photos]:hover]/card:opacity-100 group-hover/arrows:opacity-100 group-has-[:focus-visible]/arrows:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,M6=`[@media(hover:none)]:opacity-100`,Fbe=({photos:e,cover:t,swipe:n=!0,children:r})=>{let i=(0,L.useRef)(null),a=(0,L.useRef)(void 0),[o,s]=(0,L.useState)(0),c=Mbe(t,e),l=e=>{let t=i.current;t&&t.scrollTo({left:e*t.clientWidth})},u=e=>{a.current=Nbe((a.current??o)+e,c.length),l(a.current)},d=()=>{a.current=void 0},f=e=>{s(Pbe(e.scrollLeft,e.clientWidth,c.length)),a.current!==void 0&&Math.abs(e.scrollLeft-a.current*e.clientWidth)<1&&(a.current=void 0)},p=(0,z.jsx)(A6,{children:(0,z.jsx)(`span`,{ref:i,tabIndex:-1,"data-card-photos":!0,onPointerDown:d,onScroll:e=>f(e.currentTarget),className:g(`flex size-full snap-x snap-mandatory outline-none [scrollbar-width:none] motion-safe:scroll-smooth [&::-webkit-scrollbar]:hidden`,n?`overflow-x-auto overscroll-x-contain`:`overflow-x-hidden`),children:c.map((e,t)=>(0,z.jsx)(`span`,{className:`block size-full shrink-0 snap-start snap-always`,children:(0,z.jsx)(k6,{value:e})},t))})});return(0,z.jsxs)(z.Fragment,{children:[r(p),c.length>1&&(0,z.jsxs)(`div`,{className:`group/arrows pointer-events-none absolute inset-x-px top-px aspect-[4/3]`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":J(`previousPhoto`),className:g(j6,!n&&M6,`left-2`),onClick:()=>u(-1),children:(0,z.jsx)(Ti,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(`button`,{type:`button`,"aria-label":J(`nextPhoto`),className:g(j6,!n&&M6,`right-2`),onClick:()=>u(1),children:(0,z.jsx)(Di,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{className:`absolute inset-x-0 bottom-2 flex justify-center`,"aria-live":`polite`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:J(`photoOf`,o+1,c.length)}),(0,z.jsx)(`span`,{className:`flex items-center gap-1 rounded-full bg-background/70 px-1.5 py-1 leading-none`,"aria-hidden":!0,children:c.map((e,t)=>(0,z.jsx)(`span`,{className:g(`size-1.5 rounded-full`,t===o?`bg-foreground`:`bg-foreground/35`)},t))})]})]})]})},Ibe=({icon:e,children:t})=>{let n=km(e);return(0,z.jsxs)(`dd`,{className:`flex items-center gap-1 tabular-nums`,children:[n&&(0,z.jsx)(n,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t]})},N6=({model:e,view:t,display:n,row:r,swipe:i=!0,mark:a})=>{let{image:o,title:s,subtitle:c,amount:l,badge:u,meta:d,footer:f,flags:p}=vS(e,t,n),m=e=>t?.fields[e]?.label??q(e),h=n=>{let i=e.fields[n];if(!i)return``;let a=r.record[n];return r.labels[n]===void 0&&zx(i,t?.fields[n])&&typeof a==`string`&&a!==``?Rx(a):r.labels[n]??rS(i,a,t?.fields[n])},{fields:g,components:_}=hC(),v=h6(e),y=n.card===void 0?void 0:_?.[n.card],b=n=>{let i=e.fields[n],a=i&&gC(g,i,t?.fields[n]);return a?(0,z.jsx)(vC,{shown:a,part:`display`,field:i,value:r.record[n],fallback:h(n)}):h(n)},x=n=>{let i=e.fields[n],a=r.record[n];return!i||!zx(i,t?.fields[n])||gC(g,i,t?.fields[n])||typeof a!=`string`||a===``?b(n):(0,z.jsx)(yC,{source:a,inLink:!0})},S=n=>{let i=e.fields[n],a=t?.fields[n],o=r.record[n];return!i||a?.format!==`badge`||gC(g,i,a)||o==null||o===``?b(n):(0,z.jsx)(Q0,{value:o,hints:a,children:h(n)})},C=n=>{let i=e.fields[n];if(!i)return;if(r.labels[n]!==void 0||gC(g,i,t?.fields[n]))return(0,z.jsx)(`strong`,{className:`font-semibold text-foreground`,children:b(n)});let a=loe(i,r.record[n],t?.fields[n]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`strong`,{className:`font-semibold text-foreground`,children:a.amount}),a.suffix]})},w=y?void 0:n.photos,T=u===void 0?void 0:r.record[u],E=p.filter(e=>r.record[e]===!0),D=o===void 0?void 0:r.record[o],O=coe(r,l),k=yS(r,f),A=o!==void 0||w!==void 0,j=n.favorite,M=y?[]:kbe(t,n,r),N=e=>(0,z.jsxs)(z.Fragment,{children:[A&&e,(0,z.jsxs)(`span`,{className:`flex items-start justify-between gap-2 ${j&&!A?`pr-8`:``}`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:b(s)}),u!==void 0&&T!=null&&(0,z.jsx)(Q0,{value:T,hints:t?.fields[u],children:h(u)})]}),c!==void 0&&(0,z.jsx)(`span`,{className:t?.fields[c]?.markdown?`line-clamp-3 break-words text-muted-foreground`:t?.fields[c]?.multiline?`line-clamp-3 whitespace-pre-line break-words text-muted-foreground`:`truncate text-muted-foreground`,children:x(c)}),O!==void 0&&(0,z.jsx)(`span`,{className:`truncate tabular-nums text-muted-foreground`,children:C(O)}),d.length>0&&(0,z.jsx)(`dl`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-0.5 pt-1 text-xs text-muted-foreground`,children:yS(r,d).map(e=>(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[(0,z.jsx)(`dt`,{className:`sr-only`,children:m(e)}),(0,z.jsx)(Ibe,{icon:t?.fields[e]?.icon,children:S(e)})]},e))}),E.length>0&&(0,z.jsx)(`ul`,{className:`flex flex-wrap gap-1`,"aria-label":J(`features`),children:E.map(e=>(0,z.jsx)(`li`,{children:(0,z.jsx)(_d,{dot:!1,children:m(e)})},e))}),k.length>0&&(0,z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground ${d.length>0?``:`mt-auto`}`,children:k.map((e,t)=>(0,z.jsxs)(`span`,{children:[t>0&&(0,z.jsx)(`span`,{"aria-hidden":!0,children:` • `}),b(e)]},e))}),M.length>0&&(0,z.jsx)(Dbe,{dots:M})]}),P=t=>(0,z.jsxs)(jS,{to:{kind:`record`,resource:e.name,key:r.key},onClick:()=>v(r.record),className:`flex h-full flex-col gap-1.5 rounded-lg border border-border bg-background p-3 hover:border-border-strong hover:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,children:[a&&!A&&(0,z.jsx)(_d,{tone:`blue`,className:`self-start`,children:a}),y?(0,z.jsx)(Lg,{name:n.card,fallback:N(t),children:(0,z.jsx)(y,{row:r})}):N(t)]});return(0,z.jsxs)(`div`,{className:w?`group/card relative h-full`:j||a||M.length>0?`relative h-full`:`h-full`,children:[w?(0,z.jsx)(Fbe,{photos:r.photos??[],cover:D,swipe:i,children:P},r.key):P((0,z.jsx)(Abe,{value:D})),a&&A&&(0,z.jsx)(_d,{tone:`blue`,className:`pointer-events-none absolute top-2 left-2 shadow-sm`,children:a}),M.length>0&&(0,z.jsx)(Obe,{dots:M,Card:N6}),j&&(0,z.jsx)(ybe,{favorite:j,recordKey:r.key,target:Kx(e,r.record),className:A?void 0:`right-1.5 top-1.5`})]})},P6=268,F6=3,I6=(e,t,n)=>{let r=Math.floor(Math.max(0,e)/P6),i=Math.ceil((Math.max(0,e)+t)/P6);return{start:Math.max(0,r-F6),end:Math.min(n,i+F6)}},L6=e=>e*P6,Lbe=e=>{let t=(0,L.useRef)(null),[n,r]=(0,L.useState)({left:0,width:0});(0,L.useLayoutEffect)(()=>{let n=t.current;if(!n)return;let i=()=>r(t=>{let r={left:n.scrollLeft,width:n.clientWidth};return((t,n)=>{let[r,i]=[I6(t.left,t.width,e),I6(n.left,n.width,e)];return r.start===i.start&&r.end===i.end&&t.width===n.width&&t.left>0==n.left>0&&Math.abs(t.left-n.left)<1})(t,r)?t:r});i();let a=new ResizeObserver(i);return a.observe(n),n.addEventListener(`scroll`,i,{passive:!0}),()=>{a.disconnect(),n.removeEventListener(`scroll`,i)}},[e]);let i=Math.max(0,L6(e)-12),a=e=>t.current?.scrollBy({left:e*Math.max(L6(1),n.width-12),behavior:`smooth`});return{ref:t,...I6(n.left,n.width,e),back:n.left>0,on:n.left+n.width<i-1,page:a}},R6=a({en:{couldNotLoad:`Could not load`,noneMatch:e=>`No ${e} match.`,viewAll:`View all`,new:`New`,previous:e=>`Previous ${e}`,next:e=>`Next ${e}`,couldNotLoadYour:e=>`Could not load your ${e}`,noneYet:e=>`No ${e} yet.`},nl:{couldNotLoad:`Kon niet laden`,noneMatch:e=>`Geen ${e} gevonden.`,viewAll:`Alles bekijken`,new:`Nieuw`,previous:e=>`Terug in ${e}`,next:e=>`Verder in ${e}`,couldNotLoadYour:e=>`Kon je ${e} niet laden`,noneYet:e=>`Nog geen ${e}.`}}),z6=`absolute top-1/2 z-10 hidden size-8 -translate-y-1/2 items-center justify-center rounded-full border border-border-strong bg-background shadow-pop hover:bg-muted sm:flex`,B6=({cards:e})=>e>0?(0,z.jsx)(`li`,{"aria-hidden":!0,className:`shrink-0`,style:{width:L6(e)-12}}):null,Rbe=({model:e,view:t,display:n,source:r,label:i,isNew:a})=>{let{total:o}=r,s=Lbe(o),c=o3({total:o,rowAt:r.rowAt,loadRows:r.loadRows,revision:r.revision,latencyMs:0},s.start,Math.max(s.start,s.end-1)),l=Array.from({length:s.end-s.start},(e,t)=>s.start+t);return(0,z.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,z.jsxs)(`ul`,{ref:s.ref,"aria-label":i,className:`relative flex snap-x gap-3 overflow-x-auto overflow-y-hidden pb-1`,style:{scrollbarWidth:`thin`},children:[(0,z.jsx)(B6,{cards:s.start}),l.map(r=>{let i=c(r);if(!i)return(0,z.jsx)(`li`,{"aria-hidden":!0,className:`shrink-0`,style:{width:256},children:(0,z.jsx)(Yu,{className:`h-full min-h-24 rounded-lg`})},`skeleton-${r}`);let s=CS(e,i);return(0,z.jsx)(`li`,{"aria-posinset":r+1,"aria-setsize":o,className:`grid shrink-0 snap-start grid-cols-[minmax(0,1fr)]`,style:{width:256},children:(0,z.jsx)(N6,{model:e,view:t,display:n,row:s,swipe:!1,mark:a?.(s)?R6(`new`):void 0})},s.key)}),(0,z.jsx)(B6,{cards:o-s.end})]}),s.back&&(0,z.jsx)(`button`,{type:`button`,"aria-label":R6(`previous`,i.toLowerCase()),onClick:()=>s.page(-1),className:`${z6} -left-3`,children:(0,z.jsx)(Ti,{className:`size-4`,"aria-hidden":!0})}),s.on&&(0,z.jsx)(`button`,{type:`button`,"aria-label":R6(`next`,i.toLowerCase()),onClick:()=>s.page(1),className:`${z6} -right-3`,children:(0,z.jsx)(Di,{className:`size-4`,"aria-hidden":!0})})]})},zbe=Vn(),Bbe=(e,t)=>{if(!t)return e;let n=Xt(e);if(!n.ok)throw Error(`The filter cannot be read: ${n.errors.map(e=>e.message).join(`; `)}`);return Fn(n.ast?zbe.and(n.ast,t):t)},Vbe=(e,t)=>{let n=fS(e).filter(e=>e.kind===`cards`);return n.find(e=>e.name===t)??n[0]??{kind:`cards`,name:`cards`}},Hbe=()=>(0,z.jsx)(`div`,{className:`flex gap-3 overflow-hidden`,children:Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-24 w-64 shrink-0`},t))}),V6=({model:e,view:t,filter:n,sort:r=``,display:i,limit:a,chips:o=!0,empty:s,note:c,isNew:u,viewAll:d,scope:f,list:p})=>{let{resources:m,views:h}=G(),g=Nu(),_=Vbe(t,i),v=r||wS(e,t),y=S3({resources:m,views:h,model:e,columns:(0,L.useMemo)(()=>SS(e,t,[]),[e,t]),filter:(0,L.useMemo)(()=>Bbe(n,f),[n,f]),orderBy:v}),b=m6(e,n),x=(t?.names?.singular??q(e.name)).toLowerCase(),S=t?.names?.plural??q(e.name),C=y.source?.total,w=(0,L.useMemo)(()=>y.source&&{...y.source,total:Math.min(y.source.total,a??1/0)},[y.source,a]);return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[o&&b.length>0||C!==void 0||c?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[o&&b.length>0?(0,z.jsx)(w3,{chips:b}):(0,z.jsx)(`span`,{}),(0,z.jsxs)(`p`,{className:`flex flex-wrap gap-x-3 text-muted-foreground`,children:[c&&(0,z.jsx)(`span`,{children:c}),C!==void 0&&(0,z.jsx)(`span`,{className:`tabular-nums`,children:`${C.toLocaleString(l())} ${C===1?x:S.toLowerCase()}`})]})]}):null,y.isLoading?(0,z.jsx)(Hbe,{}):y.error?(0,z.jsx)(rC,{title:R6(`couldNotLoad`),error:y.error}):!w||w.total===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:s??R6(`noneMatch`,S.toLowerCase())}):(0,z.jsx)(Rbe,{model:e,view:t,display:_,source:w,label:S,isNew:u}),(0,z.jsxs)(jS,{to:u2(e,t,g,{filter:n,orderBy:v,display:_.name,savedSearch:d?.savedSearch,resource:p}),onClick:d?.onOpen,className:`flex items-center gap-1 self-end font-medium text-primary-text hover:underline`,children:[d?.label??(0,z.jsxs)(z.Fragment,{children:[R6(`viewAll`),` `,(0,z.jsx)(`span`,{className:`sr-only`,children:S.toLowerCase()})]}),(0,z.jsx)(Vr,{className:`size-3.5`,"aria-hidden":!0})]})]})},Ube=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=G(),o=DS(i,a,e.name),s=y6(e.name,t.listOf,!0),c=(t.names?.plural??q(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,z.jsx)(rC,{title:R6(`couldNotLoadYour`,c),error:s.error});if(!s.data)return(0,z.jsx)(Yu,{className:`h-24`});let l=_6(o.model,s.data);return l?(0,z.jsx)(V6,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:n??R6(`noneYet`,c)})},Wbe=e=>U.list(e,``,``,500,`saved-searches`),H6=(e,t)=>{let n=W(),{resources:r,views:i}=G(),a=r[e];return Kh({queryKey:Wbe(e),enabled:t&&a!==void 0,queryFn:async()=>{let t=[],r;do{let o=await n.list(e,{pageSize:500,orderBy:wS(a,i[e]),...r&&{pageToken:r}});t.push(...o.items),r=o.nextPageToken||void 0}while(r);return t}})},U6=({model:e,of:t,target:n,targetView:r,row:i,recordKey:a})=>{let o=W(),s=RT(),c=String(i[t.filter]??``),l=m6(n,c),u=t.name===void 0?void 0:i[t.name],d=typeof u==`string`&&u!==``?u:void 0,f=t.unseen,p=qh({mutationFn:t=>o.update(e.name,a,{[f.seenAt]:t},i.etag??`*`),onSettled:()=>s(e.name)}),m=Kh({...PT(o,n,f?lbe(c,f.field,i[f.seenAt]):``),enabled:f!==void 0}),h=(r?.names?.plural??q(n.name)).toLowerCase(),g={model:n,view:r,filter:c,sort:f?`${f.field} desc`:void 0,limit:t.limit,chips:d!==void 0,empty:Q(`noneMatch`,h),note:f&&m.data===0&&Q(`noNew`,h),isNew:f&&(e=>ube(e.record[f.field],i[f.seenAt])),viewAll:{label:Q(`viewAll`),savedSearch:a,...f&&{onOpen:()=>p.mutate(new Date().toISOString())}}};return{name:d,chips:l,title:d??Mye(l),body:g}},Gbe=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=sr(Kx(e,i)),{name:o,chips:s,title:c,body:l}=U6({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,z.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,z.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:(0,z.jsx)(jS,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,z.jsx)(T3,{chips:s})})}),(0,z.jsx)(V6,{...l})]})},Kbe=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=G(),a=t.searchesOf,o=r[a.resource],s=H6(e.name,!0),c=(t.names?.plural??q(e.name)).toLowerCase();return o?s.error?(0,z.jsx)(rC,{title:Q(`couldNotLoadYour`,c),error:s.error}):s.data?s.data.length===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:n??Q(`noneYet`,c)}):(0,z.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,z.jsx)(Gbe,{model:e,view:t,target:o,targetView:i[a.resource],row:n},sr(Kx(e,n))))}):(0,z.jsx)(Yu,{className:`h-40`}):null},qbe=({node:e,slots:t})=>{let{resource:n,filter:r=``,sort:i,limit:a,display:o,title:s,description:c,empty:l}=HT(e),{resources:u,views:d}=G(),f=u[n];if(!f)return null;let p=d[f.name];return(0,z.jsx)(GT,{title:s,description:c,actions:t.actions,children:p?.searchesOf?(0,z.jsx)(Kbe,{model:f,view:p,empty:l}):p?.listOf===void 0?(0,z.jsx)(V6,{model:f,view:p,filter:r,sort:i,limit:a,display:o,empty:l}):(0,z.jsx)(Ube,{model:f,view:p,limit:a,display:o,empty:l})})},W6=(e,t)=>{let{resources:n}=G(),r=W(),i=JSON.stringify(e),a=(0,L.useMemo)(()=>JSON.parse(i).map(yc),[i]),o=e=>!!(t&&Object.hasOwn(t.model.fields,e)),s=[...new Set(a.flatMap(e=>e.ok?e.paths:[]))],c=new Map(s.flatMap(e=>{let t=xc(e,o);return t===void 0?[]:[[e,t]]})),l=s.filter(e=>!c.has(e)),u=[...new Set(c.values())].flatMap(e=>n[e]?[n[e]]:[]),d=Yhe(t,l),f=Wh({queries:u.map(e=>PT(r,e))});return a.map(e=>{if(!e.ok)return!1;let t={};for(let n of e.paths){let e=c.get(n);if(e===void 0){let e=d[l.indexOf(n)];if(e.state===`loading`)return;e.state===`ready`&&(t[n]=e.value);continue}let r=u.findIndex(t=>t.name===e);if(r===-1)t[n]=0;else if(f[r].isPending)return;else t[n]=f[r].data??0}return bc(e,t)})},Jbe=({node:e,children:t})=>{let{when:n}=HT(e),[r]=W6([n],bT());return r?(0,z.jsx)(z.Fragment,{children:t}):null},G6=`text-2xl font-semibold tracking-tight tabular-nums`,Ybe=({model:e,filter:t})=>{let{views:n}=G(),r=FT(e,t);return r.isPending?(0,z.jsx)(Yu,{className:`h-8 w-16`}):r.error?(0,z.jsx)(`span`,{className:`text-danger-text`,children:Ig(`couldNotCount`)}):(0,z.jsx)(jS,{to:dE(n[e.name],e.name,t),className:`${G6} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:r.data.toLocaleString(l())})},Xbe=({field:e,format:t})=>{let n=r2(bT(),e);return n.state===`loading`?(0,z.jsx)(Yu,{className:`h-8 w-16`}):n.state===`missing`?null:(0,z.jsx)(`span`,{className:G6,children:(0,z.jsx)($0,{model:n.model,field:n.field,value:n.value,format:t})})},Zbe=({node:e})=>{let{label:t,value:n,resource:r,filter:i,field:a,format:o,description:s}=HT(e),{resources:c}=G(),l=r===void 0?void 0:c[r];return(0,z.jsxs)(GT,{className:`relative h-full`,bodyClassName:`flex flex-col`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground break-words`,children:t}),(0,z.jsxs)(`div`,{className:`mt-auto pt-1`,children:[n!==void 0&&(0,z.jsx)(`span`,{className:G6,children:n}),l&&(0,z.jsx)(Ybe,{model:l,filter:i}),a!==void 0&&(0,z.jsx)(Xbe,{field:a,format:o})]}),s&&(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s})]})},K6=(e,t)=>{let n=e.position;if(!n||!xT(t,`update`))return;let r=e.fields[n.field];return r&&!r.readOnly?n.field:void 0},q6=(e,t)=>e.position?.within===void 0?K6(e,t):void 0,Qbe=(e,t,n)=>t.position?.within!==void 0&&e.field===t.position.within&&!e.through&&!e.from&&!e.filter?K6(t,n):void 0,$be=(e,t,n,r)=>{if(t===void 0||e?.list?.drag?.rank!==!0||r!==``)return!1;let i=TS(n);return i.columnId===t&&i.direction===`asc`},J6=e=>e===null?`none`:`value:${e}`,Y6=e=>e.data.current?.sortable!==void 0,X6=e=>{let t=vae(e),n=t.find(e=>e.data?.droppableContainer&&Y6(e.data.droppableContainer));return n?[n]:t.length>0?t:cv(e)},exe=(e,{context:{collisionRect:t,droppableRects:n,droppableContainers:r,over:i}})=>{let a=e.code===`ArrowRight`?1:e.code===`ArrowLeft`?-1:0;if(a===0||!t)return;e.preventDefault();let o=r.getEnabled(),s=o.filter(e=>!Y6(e)).flatMap(e=>{let t=n.get(e.id);return t?[{id:e.id,rect:t}]:[]}).sort((e,t)=>e.rect.left-t.rect.left),c=t.left+t.width/2,l=i?.data.current?.sortable?.containerId??i?.id,u=l===void 0?s.findIndex(e=>e.rect.left<=c&&c<=e.rect.right):s.findIndex(e=>e.id===l),d=s[u+a];if(u===-1||!d)return;let f=Z6(o,n,d.id)[0];return{x:d.rect.left+(d.rect.width-t.width)/2,y:f?.rect.top??d.rect.top}},Z6=(e,t,n)=>e.filter(e=>e.data.current?.sortable?.containerId===n).flatMap(e=>{let n=t.get(e.id);return n?[{id:e.id,rect:n}]:[]}).sort((e,t)=>e.rect.top-t.rect.top),txe=(e,t)=>{let n=e.code===`ArrowDown`?1:e.code===`ArrowUp`?-1:0;if(n===0)return exe(e,t);let{droppableRects:r,droppableContainers:i,over:a}=t.context,o=a?.data.current?.sortable?.containerId??a?.id;if(o===void 0)return;let s=Z6(i.getEnabled(),r,o),c=s[(a?.id===o?s.length:s.findIndex(e=>e.id===a?.id))+n];if(c)return e.preventDefault(),{x:c.rect.left,y:c.rect.top}},Q6=(e,t,n,r)=>{let i=Jh({queryKey:[...n,`display`],enabled:r,initialPageParam:0,queryFn:({pageParam:e})=>t(e),getNextPageParam:(e,t)=>e.rows.length===40&&t.length*40<(t[0]?.total??0)?t.length:void 0}),a=i.data?.pages??[];return{resource:e.name,rows:a.flatMap(t=>t.rows.map(t=>CS(e,t))),total:a[0]?.total??0,loading:i.isPending,error:i.error,more:i.hasNextPage,loadMore:()=>void i.fetchNextPage()}},nxe=({model:e,by:t,value:n,fields:r,filter:i,orderBy:a})=>{let{resources:o,views:s}=G(),c=S3({resources:o,views:s,model:e,columns:r,filter:noe(i,t,n),orderBy:a});return Q6(e,c.page,c.key,!0)},rxe=(e,t)=>{if(!t)return e;let n=new Map(e.map(e=>[e.key,e])),r=new Set(t);return[...t.flatMap(e=>n.get(e)??[]),...e.filter(e=>!r.has(e.key))]},ixe=({model:e,view:t,display:n,column:r,fields:i,filter:a,orderBy:o,limit:s,moves:c,movable:u,placeable:d,dragged:f})=>{let p=nxe({model:e,by:n.by,value:r.value,fields:i,filter:a,orderBy:o}),m=uS(e,t,n),h=new Set(p.rows.map(e=>e.key)),_=new Map(c.map(e=>[e.row.key,e])),v=p.rows.filter(e=>_.has(e.key)&&_.get(e.key).to!==r.value),y=c.filter(e=>e.to===r.value&&!h.has(e.row.key)).map(e=>e.row),b=p.rows.filter(e=>!v.includes(e)).map(e=>_.has(e.key)?_.get(e.key).row:e),x=c.findLast(e=>e.to===r.value&&e.order),S=rxe([...y,...b],x?.order).slice(0,s),{setNodeRef:C,isOver:w}=Dy({id:J6(r.value),data:{column:r,rows:S}}),T=p.total-v.length+y.length;if(r.value===null&&!p.loading&&T===0&&!w)return null;let E=(t?.names?.plural??q(e.name)).toLowerCase(),D=t?.fields[n.by];return(0,z.jsxs)(`section`,{ref:C,"aria-label":`${r.label}, ${T}`,className:g(`flex w-72 shrink-0 snap-start flex-col gap-2 rounded-lg bg-surface p-2`,w&&`ring-2 ring-primary/30`),children:[(0,z.jsxs)(`header`,{className:`flex items-center justify-between gap-2 px-1 pt-0.5`,children:[(0,z.jsx)(`h2`,{className:`min-w-0 truncate text-body font-medium`,children:r.value===null?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:r.label}):(0,z.jsx)(Q0,{value:r.value,hints:D,children:r.label})}),!p.loading&&(0,z.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:T.toLocaleString(l())})]}),p.loading?Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-20`},t)):p.error?(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:p.error}):S.length===0?(0,z.jsx)(`p`,{className:`px-1 py-4 text-center text-xs text-muted-foreground`,children:J(`noPlural`,E)}):(0,z.jsx)(Xy,{id:J6(r.value),items:S.map(e=>e.key),strategy:Ky,children:(0,z.jsx)(`ul`,{className:`-mb-2 flex flex-col`,children:S.map(n=>(0,z.jsx)(axe,{model:e,view:t,card:m,row:n,column:r,rows:S,draggable:(u||d)&&ST(n.record,`update`),placeable:d,dragged:f},n.key))})}),s===void 0&&p.more&&(0,z.jsx)(V,{size:`sm`,variant:`ghost`,onClick:p.loadMore,children:J(`showMore`)})]})},axe=({model:e,view:t,card:n,row:r,column:i,rows:a,draggable:o,placeable:s,dragged:c})=>{let{setNodeRef:l,setActivatorNodeRef:u,listeners:d,isDragging:f,isOver:p,active:m,transform:h,transition:_}=ib({id:r.key,data:{row:r,column:i,rows:a},disabled:{draggable:!o,droppable:!s}}),v=p&&m?.data.current?.column?.value!==i.value;return(0,z.jsx)(`li`,{ref:e=>{l(e),u(e?.querySelector(`a`)??e)},...d,onDragStart:e=>e.preventDefault(),onClickCapture:e=>{c()&&(e.preventDefault(),e.stopPropagation())},style:{transform:h?`translate3d(${h.x}px, ${h.y}px, 0)`:void 0,transition:_},className:g(`relative pb-2`,o&&`cursor-grab touch-manipulation`,f&&`opacity-40`,v&&`before:absolute before:inset-x-0 before:-top-1 before:h-0.5 before:rounded-full before:bg-primary`),children:(0,z.jsx)(N6,{model:e,view:t,display:n,row:r,swipe:!1})})},$6=e=>e.kind===`and`?e.args.flatMap($6):[e],e8=e=>e.kind===`string`?String(e.value):void 0,oxe=(e,t)=>{if(e.kind===`compare`&&e.op===`=`&&e.field.path.join(`.`)===t){let t=e8(e.value);return t===void 0?void 0:[t]}if(e.kind===`in`&&e.field.path.join(`.`)===t){let t=e.values.map(e8);return t.every(e=>e!==void 0)?t:void 0}},sxe=(e,t,n)=>{let r=Xt(e);if(!r.ok||!r.ast)return n;let i=$6(r.ast).map(e=>oxe(e,t)).filter(e=>e!==void 0);return n.filter(e=>i.every(t=>e.value!==null&&t.includes(e.value)))},t8=(e,t)=>t!==null&&Object.hasOwn(e,t)?e[t]:void 0,n8=a({en:{done:`Done`,reorder:`Reorder`,couldNotLoad:`Could not load`,nothingYet:`Nothing here yet.`,couldNotChange:`Could not change the order`,orderChanged:`Order changed`,undo:`Undo`,couldNotUndo:`Could not undo`,movedToPlace:e=>`Moved to place ${e}`,notMoved:`Left in its place`,noRule:`No drop rule is registered as {}. Give it in dropRules in protobase.ui.tsx, or load the plugin that provides it.`},nl:{done:`Klaar`,reorder:`Volgorde wijzigen`,couldNotLoad:`Kon niet laden`,nothingYet:`Hier staat nog niets.`,couldNotChange:`Kon de volgorde niet wijzigen`,orderChanged:`Volgorde gewijzigd`,undo:`Ongedaan maken`,couldNotUndo:`Kon niet ongedaan maken`,movedToPlace:e=>`Verplaatst naar plaats ${e}`,notMoved:`Op zijn plaats gelaten`,noRule:`Er is geen sleepregel geregistreerd als {}. Geef die in dropRules in protobase.ui.tsx, of laad de plug-in die haar levert.`}}),r8=(e,t,n)=>t.flatMap(({before:t,record:r,etag:i})=>{let a=n.filter(e=>Object.hasOwn(t,e)&&t[e]!==r[e]);return a.length===0?[]:[{op:`update`,resource:e.name,key:Kx(e,r),data:Object.fromEntries(a.map(e=>[e,t[e]])),etag:i}]}),i8=async(e,t,n)=>{let r=[],i=``;do{let a=await e.search(t,{filter:n,pageSize:100,...i&&{pageToken:i}});r.push(...a.items),i=a.nextPageToken}while(i);return r},a8=(e,t)=>t===void 0?e:`(${e}) AND (${t})`,o8=async(e,t,n,r)=>{let i=t.position?.after;if(!i)return{after:[],before:[]};let a=t.primaryKey[0],o=Kx(t,r),s=e=>sr([e]),c=await i8(e,i.resource,a8(Fn(Hn.or(Hn.eq(i.field,o),Hn.eq(i.key,o))),i.filter)),l=(e,t)=>c.flatMap(n=>s(n[e])===s(o)&&s(n[t])!==s(o)?[n[t]]:[]),u=l(i.field,i.key),d=l(i.key,i.field),[f,p]=await Promise.all([i8(e,t.name,a8(Fn(Hn.in(a,[o,...u])),i.while)),d.length===0?[]:i8(e,t.name,Fn(Hn.in(a,d)))]),m=e=>{let r=sr(Kx(t,e));return{key:r,rank:e[t.position.field],title:Ux(t,n,e,r)}},h=f.some(e=>s(e[a])===s(o));return{after:f.filter(e=>s(e[a])!==s(o)).map(m),before:h?p.map(m):[]}},s8=e=>typeof e==`number`&&Number.isInteger(e),c8=(e,t,n)=>{let r=0;for(;r<t&&s8(e[r])&&(r===0||e[r]>e[r-1]);)r+=1;let i=e.length;for(;i-1>n&&s8(e[i-1])&&(i===e.length||e[i-1]<e[i]);)--i;let a=Math.min(t,r),o=a===0?1:e[a-1]+1,s=Math.max(n,i-1);for(;s+1<e.length&&e[s+1]<=o+(s-a);)s+=1;return{first:a,last:s,start:o}},cxe=(e,t,n)=>{let r=e.findIndex(e=>e.key===t.key);return r===-1?[...e.slice(0,n),t,...e.slice(n)]:zy(e,r,n)},l8=(e,t,n)=>{let r=e.findIndex(e=>e.key===t.key);return{order:cxe(e,t,n),first:r===-1?n:Math.min(r,n),last:r===-1?n:Math.max(r,n)}},u8=e=>typeof e.record.etag==`string`?e.record.etag:`*`,lxe=(e,t,n,r,i,a,o,s,c)=>{let l=(r.record[t]??null)!==i.value,u=c8(a.map(e=>e.record[n]),o,s),d=a.slice(u.first,u.last+1),f=e=>l&&e.key===r.key?`*`:u8(e),p=(t,r)=>({op:`reorder`,resource:e.name,field:n,keys:t.map(t=>Kx(e,t.record)),start:r,etags:Object.fromEntries(t.map(t=>[sr(Kx(e,t.record)),f(t)]))}),m=d.filter(e=>e.key!==r.key),h=c===void 0?[p(d,u.start)]:[p([r],c),...m.length>0?[p(m,u.start)]:[]];return l?[{op:`update`,resource:e.name,key:Kx(e,r.record),data:{[t]:i.value},etag:u8(r)},...h]:h},uxe=(e,t,n)=>{let r=new Map(t.map(t=>[sr(Kx(e,t.record)),t.record])),i=new Map;for(let t of n.results){let n=t.op===`reorder`?t.records:t.op===`update`?[t]:[];for(let{record:t,etag:r}of n)i.set(sr(Kx(e,t)),{record:t,etag:r})}return[...i].flatMap(([e,t])=>{let n=r.get(e);return n?[{before:n,...t}]:[]})},d8=a({en:{dependsOn:(e,t)=>`${e} depends on ${t}.`},nl:{dependsOn:(e,t)=>`${e} hangt af van ${t}.`}}),f8=e=>e!=null&&e!==``,dxe=({model:e,rank:t,rows:n,row:r,index:i,bounds:a,title:o})=>{let s=n.some(e=>e.key===r.key)?n.length-1:n.length,c;for(let l=i;l<=s;l++){let{order:i,first:u,last:d}=l8(n,r,l),f=i.map(e=>e.record[t]),p=c8(f,u,d),m=new Map(i.map((t,n)=>[sr(Kx(e,t.record)),n>=p.first&&n<=p.last?p.start+n-p.first:f[n]])),h=e=>m.has(e.key)?m.get(e.key):e.rank,g=Number(m.get(sr(Kx(e,r.record)))),_=a.after.filter(e=>f8(h(e))&&Number(h(e))>=g),v=a.before.find(e=>f8(h(e))&&Number(h(e))<=g),y=v?d8(`dependsOn`,v.title,o):_[0]&&d8(`dependsOn`,o,_[0].title);if(!y)return{place:{index:l},...c!==void 0&&{reason:c}};if(c??=y,l!==s||v)continue;let b=Math.max(..._.map(e=>Number(h(e))))+1;if(a.before.every(e=>!f8(h(e))||Number(h(e))>b))return{place:{index:l,bump:b},reason:c}}return{reason:c}},fxe=({model:e,view:t,by:n,rank:r,drop:i,labelOf:a,titleOf:o})=>{let s=W(),c=Hb(),l=RT(),[u,d]=(0,L.useState)([]),f=(0,L.useRef)(void 0),p=e=>d(t=>t.filter(t=>t.row.key!==e)),m=r?[n,r]:[n],h=qh({mutationFn:e=>e(),onError:e=>c.show({state:`error`,title:J(`couldNotUndo`),description:dS(e)}),onSettled:()=>l(e.name)}),g=async(t,r)=>{let a=i&&t8(i,r.value);if(!a)throw Error(`The column ${r.label} takes no cards`);let o=Kx(e,t.record),c=typeof t.record.etag==`string`?t.record.etag:`*`,l=await a({resource:e.name,record:t.record,recordKey:o,etag:c,to:r.value,client:s});return{landed:(await s.get(e.name,o)).record[n]??null,...l&&{undo:l}}},_=(t,n)=>({landed:n.value,undo:()=>s.batchWrite(r8(e,t,m))}),v=(e,t,r)=>{let i={...e,record:{...e.record,[n]:t.value}},a=r?.map(e=>e.key);d(n=>[...n.filter(t=>t.row.key!==e.key),{row:i,to:t.value,...a&&{order:a}}])},y=async(n,i,a)=>{if(!e.position?.after)return{index:a.index};let l=await o8(s,e,t,n.record),u=dxe({model:e,rank:r,rows:a.rows,row:n,index:a.index,bounds:l,title:o(n)}),d=!u.place||u.place.bump===void 0&&u.place.index===a.rows.findIndex(e=>e.key===n.key);if(u.reason!==void 0&&c.show({state:`warning`,title:d?n8(`notMoved`):n8(`movedToPlace`,u.place.index+1),description:u.reason}),!d)return u.place.index!==a.index&&v(n,i,l8(a.rows,n,u.place.index).order),u.place},b=async(t,i,a)=>{let o=await y(t,i,a);if(!o)return;let{order:c,first:l,last:u}=l8(a.rows,t,o.index);return _(uxe(e,c,await s.batchWrite(lxe(e,n,r,t,i,c,l,u,o.bump))),i)},x=qh({mutationFn:async({row:t,to:a,place:o})=>{if(o&&!r)throw Error(`A board places a card only by its rank`);let c=t.record[n]??null;if(i&&a.value!==c)return g(t,a);if(o)return b(t,a,o);let l=typeof t.record.etag==`string`?t.record.etag:`*`,u=await s.update(e.name,Kx(e,t.record),{[n]:a.value},l);return _([{before:t.record,record:u.record,etag:u.etag}],a)},onMutate:({row:e,to:t,place:n})=>v(e,t,n&&l8(n.rows,e,n.index).order),onSuccess:(e,{row:t,to:r})=>{if(!e)return;let{landed:i,undo:o}=e;f.current!==void 0&&c.dismiss(f.current),f.current=void 0;let s=t.record[n]??null,l=i===s?s===r.value?J(`orderChanged`):J(`stayedIn`,a(i)):J(`movedTo`,a(i));if(!o){c.show({state:`success`,title:l});return}let u=c.show({state:`success`,title:l,action:{label:J(`undo`),onClick:()=>{c.dismiss(u),f.current=void 0,h.mutate(o)}}});f.current=u},onError:(e,{row:t,to:r})=>{p(t.key);let i=(t.record[n]??null)===r.value?J(`couldNotReorder`):J(`couldNotMoveTo`,r.label);c.show({state:`error`,title:i,description:dS(e)})},onSettled:async(t,n,{row:r})=>{await l(e.name),p(r.key)}});return{moves:u,move:(e,t,n)=>x.mutate({row:e,to:t,...n&&{place:n}})}},p8=(e,t)=>{let n=e.data.current;if(!n?.column||!n.rows)return;if(n.sortable)return{column:n.column,rows:n.rows,index:n.sortable.index};let r=n.rows.some(e=>e.key===t.key);return{column:n.column,rows:n.rows,index:r?n.rows.length-1:n.rows.length}},m8=({model:e,view:t,display:n,fields:r,filter:i,orderBy:a,limit:o})=>{let s=toe(e,t,n),c=sxe(i,n.by,s),l=uS(e,t,n),u=cg(e.name),{boardDrops:d}=hC(),f=t?.list?.drag,p=typeof f?.board==`string`?f.board:void 0,m=p===void 0?void 0:d?.[p],h=t=>xT(u,`update`)&&(f?.board===!0?!e.fields[n.by]?.readOnly:m!==void 0&&t8(m,t)!==void 0),g=c.some(e=>h(e.value)),_=lS(e),v=f?.rank===!0&&_!==void 0&&q6(e,u)!==void 0,y=_?`${_} asc`:a,b=e=>s.find(t=>t.value===e)?.label??String(e),x=e=>String(e.labels[l.title]??e.record[l.title]??e.key),{moves:S,move:C}=fxe({model:e,view:t,by:n.by,rank:_,drop:m,labelOf:b,titleOf:x}),[w,T]=(0,L.useState)(),E=(0,L.useRef)(!1),D=ev($_($v,{activationConstraint:{distance:4}}),$_(ty,{activationConstraint:{delay:250,tolerance:5}}),$_(Gv,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:txe}));if(p!==void 0&&!m)return(0,z.jsx)(Fg,{children:gg(J(`noDrop`),p)});let O=e=>c.find(t=>J6(t.value)===e),k=e=>e.record[n.by]??null,A=(e,t)=>h(k(e))&&h(t.value),j=(e,t)=>{if(!t)return{over:J(`noColumn`)};let n=v?p8(t,e):void 0;if(!n)return{over:O(t.id)?.label??J(`noColumn`)};let r=n.rows.some(t=>t.key===e.key)?n.rows.length:n.rows.length+1;return{over:J(`placeOf`,n.column.label,n.index+1,r),place:J(`place`,n.column.label,n.index+1)}},M=(e,t)=>{let n=(v?p8(t,e)?.column:void 0)??O(t.id);return n!==void 0&&n.value!==k(e)&&!A(e,n)};return(0,z.jsxs)(Cy,{sensors:D,collisionDetection:X6,onDragStart:({active:e})=>{E.current=!0,T(e.data.current.row)},onDragEnd:({active:e,over:t})=>{T(void 0),setTimeout(()=>E.current=!1);let n=e.data.current.row;if(!t)return;let r=v?p8(t,n):void 0;if(!r){let e=O(t.id);e&&e.value!==k(n)&&A(n,e)&&C(n,e);return}let i=r.rows.findIndex(e=>e.key===n.key);if(i!==-1||A(n,r.column)){if(i===-1&&m)return C(n,r.column);i!==r.index&&C(n,r.column,{rows:r.rows,index:r.index})}},onDragCancel:()=>{T(void 0),setTimeout(()=>E.current=!1)},accessibility:{announcements:{onDragStart:({active:e})=>J(`pickedUp`,x(e.data.current.row)),onDragOver:({active:e,over:t})=>J(`isOver`,x(e.data.current.row),j(e.data.current.row,t).over),onDragEnd:({active:e,over:t})=>{let n=e.data.current.row;if(!t||M(n,t))return J(`putBack`,x(n));let r=j(n,t);return J(`wasMovedTo`,x(n),r.place??r.over)},onDragCancel:({active:e})=>J(`cancelled`,x(e.data.current.row))},screenReaderInstructions:{draggable:J(v?g?`boardAnywhere`:`boardWithin`:`boardAcross`)}},children:[(0,z.jsx)(`div`,{className:`relative min-w-0 flex-1 overflow-x-auto`,children:(0,z.jsx)(`div`,{className:`flex snap-x items-start gap-3 pb-2`,children:c.map(a=>(0,z.jsx)(ixe,{model:e,view:t,display:n,column:a,fields:r,filter:i,orderBy:y,limit:o,moves:S,movable:h(a.value),placeable:v,dragged:()=>E.current},J6(a.value)))})}),(0,z.jsx)(Ry,{children:w&&(0,z.jsx)(N6,{model:e,view:t,display:l,row:w,swipe:!1})})]})},h8=864e5,g8=e=>new Date(e).toISOString().slice(0,10),_8=e=>Date.parse(`${e}T00:00:00Z`),v8=(e,t)=>g8(_8(e)+t*h8),y8=e=>v8(e,-((new Date(_8(e)).getUTCDay()+6)%7)),b8=(e,t=0)=>{let n=new Date(_8(e));return g8(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1))},x8=({scale:e,day:t})=>({scale:e,day:e===`month`?b8(t):y8(t)}),S8=(e,t,n=If())=>x8(e??{scale:`month`,day:Hf(t,n)}),C8=(e,t,n=If())=>x8({scale:e,day:Hf(t,n)}),w8=(e,t)=>e.scale===`month`?{scale:`month`,day:b8(e.day,t)}:{scale:`week`,day:v8(y8(e.day),7*t)},T8=e=>{let t=y8(e.scale===`month`?b8(e.day):e.day),n=(_8(e.scale===`month`?v8(y8(v8(b8(e.day,1),-1)),6):v8(t,6))-_8(t))/h8+1;return Array.from({length:n},(e,n)=>v8(t,n))},pxe=e=>{let t=T8(e);return{from:t[0],to:v8(t.at(-1),1)}},E8=(e,t)=>t.fields[e.start]?.type===`timestamp`,mxe=(e,t,n,r=If())=>{let i=E8(e,t),a=e=>new Date(Wf(e,r)).toISOString().replace(`.000Z`,`Z`),o=e=>i?{kind:`timestamp`,value:a(e),span:{start:0,end:0}}:{kind:`string`,value:e,span:{start:0,end:0}},s=Hn.and(Hn.gte(e.start,o(n.from)),Hn.lt(e.start,o(n.to)));if(e.end===void 0)return Fn(s);let c=i?Hn.gt(e.end,o(n.from)):Hn.gte(e.end,o(n.from));return Fn(Hn.or(s,Hn.and(Hn.lt(e.start,o(n.from)),c)))},hxe=(e,t)=>e===``?t:`(${e}) AND (${t})`,D8=e=>{if(typeof e!=`string`)return;let t=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:e);return Number.isNaN(t)?void 0:t},O8=(e,t,n,r=If())=>{let i=D8(e[t.start]);if(i===void 0)return;let a=E8(t,n),o=e=>a?Hf(e,r):g8(e),s=o(i),c=t.end===void 0?void 0:D8(e[t.end]),l=c===void 0?s:o(a?c-1:c);return{first:s,last:l<s?s:l}},gxe=(e,t,n,r,i=If())=>{let a=O8(e,t,n,i);return a?r.filter(e=>e>=a.first&&e<=a.last):[]},k8=(e,t)=>e.toSorted((e,n)=>(D8(e.record[t.start])??0)-(D8(n.record[t.start])??0)),_xe=(e,t,n,r,i=If())=>{let a=new Map(r.map(e=>[e,[]]));for(let o of k8(e,t))for(let e of gxe(o.record,t,n,r,i))a.get(e).push(o);return a},vxe=(e,t,n,r,i,a=If())=>{let o=(_8(i)-_8(r))/h8,s=E8(t,n),c=e=>{let t=D8(e);if(t!==void 0)return s?new Date(Uf(t+Bf(t,a)+o*h8,a)).toISOString():v8(g8(t),o)},l=c(e[t.start]),u=t.end===void 0?void 0:c(e[t.end]);return{...l!==void 0&&{[t.start]:l},...u!==void 0&&{[t.end]:u}}},A8=({heading:e,unit:t,previous:n,today:r,next:i,scales:a,scalesLabel:o,linkTo:s,onView:l})=>{let u=(e,t,n,r,i)=>s?(0,z.jsx)(jS,{to:s(e),className:t,"aria-label":n,"aria-current":i?`page`:void 0,children:r}):(0,z.jsx)(`button`,{type:`button`,className:t,"aria-label":n,"aria-pressed":i,onClick:()=>l?.(e),children:r}),d=gp({variant:`secondary`,size:`sm`});return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium`,children:e}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u(n,d,J(`previousPeriod`,t),(0,z.jsx)(Ti,{className:`size-3.5`})),u(r,d,J(`today`),J(`today`)),u(i,d,J(`nextPeriod`,t),(0,z.jsx)(Di,{className:`size-3.5`}))]}),(0,z.jsx)(`span`,{role:`group`,"aria-label":o,className:c.group(),children:a.map(e=>(0,z.jsx)(L.Fragment,{children:u(e.view,c.option(e.current),e.label,e.label,e.current)},e.label))})]})]})},yxe=e=>{let t=T8(e),n=e=>Date.parse(`${e}T00:00:00Z`);return e.scale===`month`?rp(n(e.day)):cp(n(t[0]),n(t.at(-1)))},bxe=({view:e,now:t,linkTo:n,onView:r})=>{let i=e.scale===`month`&&Hf(t,If()).startsWith(e.day.slice(0,7)),a=n=>n===`week`&&i?C8(`week`,t):S8({scale:n,day:e.day},t),o=(t,n)=>({view:a(t),label:n,current:e.scale===t});return(0,z.jsx)(A8,{heading:yxe(e),unit:e.scale===`month`?`month`:`week`,previous:w8(e,-1),today:C8(e.scale,t),next:w8(e,1),scales:[o(`month`,J(`month`)),o(`week`,J(`week`))],scalesLabel:J(`calendarScale`),linkTo:n,onView:r})},xxe=`day:`,j8=e=>`${xxe}${e}`,Sxe=(e,t)=>`${e}@${t}`,Cxe=(e,{context:{active:t,collisionRect:n,droppableRects:r,over:i}})=>{let a={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[e.code],o=i?String(i.id).slice(4):t?.data.current?.day;if(a===void 0||!n||o===void 0)return;e.preventDefault();let s=r.get(j8(v8(o,a)));if(s)return{x:s.left+(s.width-n.width)/2,y:s.top+4}},wxe=({day:e,count:t,children:n,more:r,inMonth:i,today:a,week:o})=>{let{setNodeRef:s,isOver:c}=Dy({id:j8(e)}),l=Date.parse(`${e}T00:00:00Z`);return(0,z.jsxs)(`section`,{ref:s,"aria-label":`${sp(l)}, ${t}`,className:g(`flex min-w-0 flex-col gap-1 bg-background p-1`,o?`min-h-28 sm:min-h-64`:`min-h-24`,!i&&`bg-surface`,c&&`ring-2 ring-inset ring-primary/30`),children:[(0,z.jsxs)(`header`,{className:g(`flex items-center gap-1 px-0.5 text-xs`,i?`text-foreground`:`text-muted-foreground`),children:[o&&(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:op(l)}),(0,z.jsx)(`span`,{"aria-current":a?`date`:void 0,className:g(`inline-flex size-5 items-center justify-center rounded-full tabular-nums`,a&&`bg-primary font-medium text-primary-foreground`),children:Number(e.slice(8))})]}),n,r]})},M8=(e,t,n,r)=>{let i=n.title??Hx(e,t),a=e.fields[i],o=r.labels[i]??(a?rS(a,r.record[i],t?.fields[i]):``);return o===``?r.key:o},Txe=(e,t,n,r)=>{let i=n.record[t.start];if(e.fields[t.start]?.type!==`timestamp`||typeof i!=`string`)return;let a=Date.parse(i);return Hf(a,If())===r?lp(a):void 0},N8=({model:e,view:t,display:n,row:r,day:i,className:a})=>{let o=h6(e),s=Txe(e,n,r,i);return(0,z.jsxs)(jS,{to:{kind:`record`,resource:e.name,key:r.key},onClick:()=>o(r.record),className:g(`flex min-w-0 items-baseline gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-xs hover:border-border-strong hover:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,a),children:[s&&(0,z.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:s}),(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:M8(e,t,n,r)})]})},P8=({movable:e,dragged:t,...n})=>{let{setNodeRef:r,setActivatorNodeRef:i,listeners:a,isDragging:o}=Ty({id:Sxe(n.row.key,n.day),data:{row:n.row,day:n.day},disabled:!e});return(0,z.jsx)(`div`,{ref:e=>{r(e),i(e?.querySelector(`a`)??e)},...a,onDragStart:e=>e.preventDefault(),onClickCapture:e=>{t()&&(e.preventDefault(),e.stopPropagation())},className:g(`min-w-0`,e&&`cursor-grab touch-manipulation`,o&&`opacity-40`),children:(0,z.jsx)(N8,{...n})})},F8=({model:e,display:t,range:n,fields:r,filter:i})=>{let{resources:a,views:o}=G(),s=S3({resources:a,views:o,model:e,columns:r,filter:hxe(i,mxe(t,e,n)),orderBy:`${t.start} asc`}),c=Q6(e,s.page,s.key,!0),l=c.more&&!c.loading&&c.rows.length<500;(0,L.useEffect)(()=>{l&&c.loadMore()},[l,c.rows.length]);let u=c.rows.length>500||c.rows.length===500&&c.more;return{rows:c.rows.slice(0,500),capped:u,loading:c.loading,error:c.error}},I8=(e,t)=>{let n=new Map(t.map(e=>[e.key,e.patch]));return e.map(e=>n.has(e.key)?{...e,record:{...e.record,...n.get(e.key)}}:e)},L8=(e,t)=>{let n=W(),r=Hb(),i=RT(),[a,o]=(0,L.useState)([]),s=e=>o(t=>t.filter(t=>t.key!==e)),c=qh({mutationFn:({row:t,patch:r})=>{let i=typeof t.record.etag==`string`?t.record.etag:`*`;return n.update(e.name,Kx(e,t.record),r,i)},onMutate:({row:e,patch:t})=>o(n=>[...n.filter(t=>t.key!==e.key),{key:e.key,patch:t}]),onError:(e,{row:t,to:n})=>{s(t.key),r.show({state:`error`,title:J(`couldNotMoveTo`,$f(Date.parse(`${n}T00:00:00Z`))),description:dS(e)})},onSettled:async(t,n,{row:r})=>{await i(e.name),s(r.key)}});return{moves:a,move:(n,r,i)=>c.mutate({row:n,patch:vxe(n.record,t,e,r,i),to:i})}},Exe=3,R8=({model:e,view:t,display:n,fields:r,filter:i,at:a,linkTo:o,now:s=Date.now()})=>{let[c,l]=(0,L.useState)(),u=S8(o?a:c,s),d=T8(u),f=F8({model:e,display:n,range:pxe(u),fields:r,filter:i}),{moves:p,move:m}=L8(e,n),h=_xe(I8(f.rows,p),n,e,d),_=xT(cg(e.name),`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[v,y]=(0,L.useState)(),b=(0,L.useRef)(!1),x=ev($_($v,{activationConstraint:{distance:4}}),$_(ty,{activationConstraint:{delay:250,tolerance:5}}),$_(Gv,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:Cxe})),S=Hf(s,If()),C=u.scale===`week`,w=e=>$f(Date.parse(`${String(e).slice(j8(``).length)}T00:00:00Z`)),T=r=>M8(e,t,n,r.row),E={onDragStart:({active:e})=>J(`pickedUp`,T(e.data.current)),onDragOver:({active:e,over:t})=>J(`isOver`,T(e.data.current),t?w(t.id):J(`noDay`)),onDragEnd:({active:e,over:t})=>t?J(`wasMovedTo`,T(e.data.current),w(t.id)):J(`putBack`,T(e.data.current)),onDragCancel:({active:e})=>J(`cancelled`,T(e.data.current))},D=()=>{y(void 0),setTimeout(()=>b.current=!1)},O=({active:e})=>{b.current=!0,y(e.data.current)},k=({active:e,over:t})=>{D();let{row:n,day:r}=e.data.current,i=t?String(t.id).slice(j8(``).length):void 0;i&&i!==r&&m(n,r,i)},A=(e,t)=>{let n=S8({scale:`week`,day:e},s),r=J(`moreHidden`,t),i=`self-start rounded px-1 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-primary`;return o?(0,z.jsx)(jS,{to:o(n),className:i,children:r}):(0,z.jsx)(`button`,{type:`button`,className:i,onClick:()=>l(n),children:r})};return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,z.jsx)(bxe,{view:u,now:s,linkTo:o,onView:l}),f.error&&(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:f.error}),f.capped&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:J(`capped`,500,u.scale)}),(0,z.jsxs)(Cy,{sensors:x,collisionDetection:X6,onDragStart:O,onDragEnd:k,onDragCancel:D,accessibility:{announcements:E,screenReaderInstructions:{draggable:J(`calendarInstructions`)}},children:[(0,z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[!C&&(0,z.jsx)(`div`,{"aria-hidden":!0,className:`grid grid-cols-7 gap-px border-b border-border bg-border`,children:d.slice(0,7).map(e=>(0,z.jsx)(`span`,{className:`bg-surface px-1.5 py-1 text-xs font-medium text-muted-foreground`,children:op(Date.parse(`${e}T00:00:00Z`))},e))}),(0,z.jsx)(`div`,{className:g(`grid gap-px bg-border`,C?`grid-cols-1 sm:grid-cols-7`:`grid-cols-7`),children:d.map(r=>{let i=h.get(r),a=C?i:i.slice(0,Exe);return(0,z.jsx)(wxe,{day:r,count:i.length,inMonth:C||r.startsWith(u.day.slice(0,7)),today:r===S,week:C,more:a.length<i.length&&A(r,i.length-a.length),children:f.loading?(0,z.jsx)(Yu,{className:`h-4`}):a.map(i=>(0,z.jsx)(P8,{model:e,view:t,display:n,row:i,day:r,movable:_&&ST(i.record,`update`),dragged:()=>b.current},i.key))},r)})})]}),(0,z.jsx)(Ry,{children:v&&(0,z.jsx)(N8,{model:e,view:t,display:n,row:v.row,day:v.day})})]})]})},Dxe=864e5,z8=e=>Date.parse(`${e}T00:00:00Z`),B8=(e,t=0)=>{let n=new Date(z8(e));return new Date(Date.UTC(n.getUTCFullYear(),Math.floor(n.getUTCMonth()/3)*3+3*t,1)).toISOString().slice(0,10)},V8=({scale:e,day:t})=>({scale:e,day:e===`week`?y8(t):e===`month`?b8(t):B8(t)}),H8=(e,t,n=If())=>V8(e??{scale:`month`,day:Hf(t,n)}),U8=(e,t)=>{let{scale:n,day:r}=V8(e);return{scale:n,day:n===`week`?v8(r,7*t):n===`month`?b8(r,t):B8(r,t)}},W8=e=>{let t=V8(e).day,n=(z8(U8(e,1).day)-z8(t))/Dxe;return Array.from({length:n},(e,n)=>v8(t,n))},Oxe=e=>({from:V8(e).day,to:U8(e,1).day}),kxe=(e,t,n,r=If())=>{let i=Hf(n,r),a=W8(e);return V8({scale:t,day:i>=a[0]&&i<=a.at(-1)?i:a[0]})},Axe=e=>{let t=W8(e);return e.scale===`week`?cp(z8(t[0]),z8(t.at(-1))):e.scale===`month`?rp(z8(t[0])):ap(z8(t[0]),z8(b8(t.at(-1))))},jxe=e=>{let t=W8(e);if(e.scale===`week`)return t.map((e,t)=>({index:t,span:1,label:`${op(z8(e))} ${Number(e.slice(8))}`}));if(e.scale===`month`)return t.map((e,t)=>({index:t,span:1,label:String(Number(e.slice(8))),...t%7!=0&&{minor:!0}}));let n=t.flatMap((e,t)=>e.endsWith(`-01`)?[t]:[]);return n.map((e,r)=>({index:e,span:(n[r+1]??t.length)-e,label:ip(z8(t[e]))}))},Mxe=(e,t,n,r,i=If())=>{let a=O8(e,t,n,i),o=r[0],s=r.at(-1);if(!(!a||o===void 0||s===void 0||a.last<o||a.first>s))return{first:a.first<o?0:r.indexOf(a.first),last:a.last>s?r.length-1:r.indexOf(a.last),before:a.first<o,after:a.last>s,start:a.first}},Nxe=`none`,Pxe=(e,t,n,r)=>{let i=r.group,a=i===void 0?void 0:t.fields[i];if(i===void 0||!a)return[{key:``,rows:e}];let o=n?.fields[i],s=new Map;for(let t of e){let e=t.record[i],n=e==null||e===``,r=n?Nxe:`value:${String(e)}`,c=n?J(`noValue`,o?.label??q(i)):t.labels[i]??rS(a,e,o),l=s.get(r)??{value:n?void 0:e,lane:{key:r,label:c,rows:[]}};l.lane.rows.push(t),s.set(r,l)}let c=a.enumValues??[],l=(e,t)=>e.value===void 0||t.value===void 0?Number(e.value===void 0)-Number(t.value===void 0):a.type===`enum`?c.indexOf(String(e.value))-c.indexOf(String(t.value)):a.type===`relation`?e.lane.label.localeCompare(t.lane.label):typeof e.value==`number`&&typeof t.value==`number`?e.value-t.value:String(e.value).localeCompare(String(t.value),void 0,{numeric:!0});return[...s.values()].toSorted(l).map(({lane:e})=>e)},G8=`grid grid-cols-1 sm:grid-cols-[12rem_minmax(0,1fr)]`,K8=(e,t)=>`${e/t*100}%`,Fxe=({ticks:e,days:t,today:n,label:r,trackRef:i})=>(0,z.jsxs)(`div`,{className:g(G8,`border-b border-border bg-surface`),children:[(0,z.jsx)(`span`,{className:`hidden truncate px-2 py-1 text-xs font-medium text-muted-foreground sm:block`,children:r}),(0,z.jsx)(`div`,{ref:i,"aria-hidden":!0,className:`relative h-6`,children:e.map(e=>(0,z.jsx)(`span`,{className:g(`absolute inset-y-0 items-center truncate px-1 text-xs tabular-nums text-muted-foreground`,e.index>0?`border-l border-border`:`border-border sm:border-l`,e.minor?`hidden sm:flex`:`flex`,e.span===1&&t[e.index]===n&&`font-medium text-primary`),style:{left:K8(e.index,t.length),width:K8(e.span,t.length)},children:e.label},e.index))})]}),Ixe=({ticks:e,days:t,today:n})=>{let r=t.indexOf(n);return(0,z.jsxs)(`div`,{"aria-hidden":!0,className:g(G8,`pointer-events-none absolute inset-0`),children:[(0,z.jsx)(`span`,{className:`hidden sm:block`}),(0,z.jsxs)(`div`,{className:`relative`,children:[r>=0&&(0,z.jsx)(`span`,{className:`absolute inset-y-0 bg-primary/10`,style:{left:K8(r,t.length),width:K8(1,t.length)}}),e.map(e=>(0,z.jsx)(`span`,{className:g(`absolute inset-y-0 w-px bg-border`,(e.minor||e.index===0)&&`hidden sm:block`),style:{left:K8(e.index,t.length)}},e.index))]})]})},Lxe=({model:e,view:t,display:n,row:r,days:i,movable:a,dragged:o})=>{let s=Mxe(r.record,n,e,i);return(0,z.jsxs)(`div`,{className:g(G8,`relative border-b border-border last:border-b-0`),children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`truncate px-2 pt-1 text-body sm:py-1.5`,children:M8(e,t,n,r)}),(0,z.jsx)(`div`,{className:`relative h-7`,children:s&&(0,z.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2`,style:{left:K8(s.first,i.length),width:K8(s.last-s.first+1,i.length)},children:(0,z.jsx)(P8,{model:e,view:t,display:n,row:r,day:s.start,movable:a,dragged:o,className:g(s.before&&`rounded-l-none border-l-0`,s.after&&`rounded-r-none border-r-0`)})})})]})},Rxe=()=>[{scale:`week`,label:J(`week`)},{scale:`month`,label:J(`month`)},{scale:`quarter`,label:J(`quarter`)}],q8=({model:e,view:t,display:n,fields:r,filter:i,at:a,linkTo:o,now:s=Date.now()})=>{let[c,l]=(0,L.useState)(),u=H8(o?a:c,s),d=W8(u),f=jxe(u),p=F8({model:e,display:n,range:Oxe(u),fields:r,filter:i}),{moves:m,move:h}=L8(e,n),g=Pxe(k8(I8(p.rows,m),n),e,t,n),_=xT(cg(e.name),`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[v,y]=(0,L.useState)(),b=(0,L.useRef)(!1),x=(0,L.useRef)(0),S=(0,L.useRef)(null),C=()=>(S.current?.getBoundingClientRect().width??0)/d.length,w=e=>{let t=C();return t>0?Math.round(e/t):0},T=({transform:e})=>({...e,x:w(e.x)*C(),y:0}),E=ev($_($v,{activationConstraint:{distance:4}}),$_(ty,{activationConstraint:{delay:250,tolerance:5}}),$_(Gv,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:(e,{currentCoordinates:t})=>{let n=e.code===`ArrowLeft`?-1:+(e.code===`ArrowRight`);if(n!==0)return e.preventDefault(),{x:t.x+n*C(),y:t.y}}})),D=Hf(s,If()),O=r=>M8(e,t,n,r.row),k=e=>$f(Date.parse(`${v8(e.day,x.current)}T00:00:00Z`)),A={onDragStart:({active:e})=>J(`pickedUp`,O(e.data.current)),onDragMove:({active:e})=>J(`startsOn`,O(e.data.current),k(e.data.current)),onDragOver:()=>void 0,onDragEnd:({active:e})=>x.current===0?J(`putBack`,O(e.data.current)):J(`wasMovedTo`,O(e.data.current),k(e.data.current)),onDragCancel:({active:e})=>J(`cancelled`,O(e.data.current))},j=()=>{y(void 0),setTimeout(()=>b.current=!1)},M=({active:e})=>{b.current=!0,x.current=0,y(e.data.current)},N=({delta:e})=>x.current=w(e.x),P=({active:t,delta:r})=>{j(),x.current=w(r.x);let{row:i}=t.data.current,a=O8(i.record,n,e);a&&x.current!==0&&h(i,a.first,v8(a.first,x.current))},ee=n.group===void 0?t?.names?.plural??q(e.name):t?.fields[n.group]?.label??q(n.group),te=!p.loading&&!p.error&&p.rows.length===0;return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,z.jsx)(A8,{heading:Axe(u),unit:u.scale,previous:U8(u,-1),today:H8({scale:u.scale,day:D},s),next:U8(u,1),scales:Rxe().map(({scale:e,label:t})=>({view:kxe(u,e,s),label:t,current:u.scale===e})),scalesLabel:J(`timelineScale`),linkTo:o,onView:l}),p.error&&(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:p.error}),p.capped&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:J(`capped`,500,u.scale)}),(0,z.jsxs)(Cy,{sensors:E,modifiers:[T],onDragStart:M,onDragMove:N,onDragEnd:P,onDragCancel:j,accessibility:{announcements:A,screenReaderInstructions:{draggable:J(`timelineInstructions`)}},children:[(0,z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[(0,z.jsx)(Fxe,{ticks:f,days:d,today:D,label:ee,trackRef:S}),(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(Ixe,{ticks:f,days:d,today:D}),p.loading&&(0,z.jsxs)(`div`,{className:`relative flex flex-col gap-2 p-2`,children:[(0,z.jsx)(Yu,{className:`h-4`}),(0,z.jsx)(Yu,{className:`h-4`})]}),te&&(0,z.jsx)(`p`,{className:`relative px-2 py-3 text-xs text-muted-foreground`,children:J(`nothingIn`,u.scale)}),!p.loading&&g.map(r=>(0,z.jsxs)(`section`,{"aria-label":r.label,className:`relative border-b border-border last:border-b-0`,children:[r.label!==void 0&&(0,z.jsxs)(`h3`,{className:`flex items-center gap-1.5 border-b border-border bg-surface px-2 py-1 text-xs font-medium`,children:[r.label,(0,z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:r.rows.length})]}),r.rows.map(r=>(0,z.jsx)(Lxe,{model:e,view:t,display:n,row:r,days:d,movable:_&&ST(r.record,`update`),dragged:()=>b.current},r.key))]},r.key))]})]}),(0,z.jsx)(Ry,{children:v&&(0,z.jsx)(N8,{model:e,view:t,display:n,row:v.row,day:v.day})})]})]})},zxe=({list:e,empty:t,loading:n,children:r})=>(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.loading?n:e.error?(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:e.error}):e.rows.length===0?(0,z.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:t}):r}),Bxe=({list:e})=>(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[e.rows.length.toLocaleString(l()),` of `,e.total.toLocaleString(l())]}),e.more&&(0,z.jsx)(V,{size:`sm`,onClick:e.loadMore,children:J(`showMore`)})]}),J8=`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,Vxe=`relative flex snap-x snap-mandatory gap-3 overflow-x-auto pb-1`,Hxe=({model:e,view:t,display:n,list:r,row:i=!1,footer:a=!0})=>{let o=(t?.names?.plural??q(e.name)).toLowerCase();return(0,z.jsxs)(zxe,{list:r,empty:J(`noneMatch`,o),loading:(0,z.jsx)(`div`,{className:J8,children:Array.from({length:6},(e,t)=>(0,z.jsx)(Yu,{className:`h-24`},t))}),children:[(0,z.jsx)(`ul`,{className:i?Vxe:J8,"aria-label":t?.names?.plural??q(e.name),children:r.rows.map(r=>(0,z.jsx)(`li`,{className:g(i&&`w-64 shrink-0 snap-start`),children:(0,z.jsx)(N6,{model:e,view:t,display:n,row:r,swipe:!i})},r.key))}),a&&(0,z.jsx)(Bxe,{list:r})]})},Y8=(0,L.createContext)(void 0),Uxe=({value:e,children:t})=>(0,z.jsx)(Y8.Provider,{value:e,children:t}),Wxe=()=>{let e=(0,L.useContext)(Y8);if(!e)throw Error(`useListDisplay is used inside a list display, which the list page draws`);return e},Gxe=()=>(0,L.useContext)(Y8),X8=({display:e,list:t})=>{let{components:n}=hC(),r=n?.[e.component];return r?(0,z.jsx)(Uxe,{value:t,children:(0,z.jsx)(`div`,{className:`relative min-w-0 flex-1 overflow-x-auto`,children:(0,z.jsx)(Lg,{name:e.component,children:(0,z.jsx)(r,{...Jn(e.props??{})})})})}):(0,z.jsx)(Fg,{children:gg(J(`noComponent`),e.component)})},Z8=Vn(),Kxe={bounds:{south:-90,west:-180,north:90,east:180},zoom:0},qxe=22,Q8=e=>Math.floor(e*1e6)/1e6,$8=e=>Math.ceil(e*1e6)/1e6,e5=e=>((e+180)%360+360)%360-180,Jxe=(e,t)=>{let n=[Z8.gte(e.latitude,Q8(Math.max(t.south,-90))),Z8.lte(e.latitude,$8(Math.min(t.north,90)))];if(t.east-t.west>=360)return Z8.and(...n);let r=Z8.gte(e.longitude,Q8(e5(t.west))),i=Z8.lte(e.longitude,$8(e5(t.east)));return e5(t.west)<=e5(t.east)?Z8.and(...n,r,i):Z8.and(...n,Z8.or(r,i))},Yxe=(e,t,n)=>{let r=Fn(Jxe(t,n));return e.trim()===``?r:`(${e}) AND ${r}`},Xxe=e=>Math.min(Math.max(Math.floor(e),0),qxe),Zxe=(e,t)=>{let n=[...e.map(e=>({south:e.latitude,west:e.longitude,north:e.latitude,east:e.longitude})),...t.map(e=>e.bounds)];if(n.length!==0)return{south:Math.min(...n.map(e=>e.south)),west:Math.min(...n.map(e=>e.west)),north:Math.max(...n.map(e=>e.north)),east:Math.max(...n.map(e=>e.east))}},t5=e=>{if(typeof e==`number`)return e;if(typeof e==`string`&&e.trim()!==``)return Number(e)},n5=(e,t)=>{let n=t5(e[t.latitude]),r=t5(e[t.longitude]);if(n!==void 0&&r!==void 0&&Math.abs(n)<=90&&Math.abs(r)<=180)return{latitude:n,longitude:r}},Qxe=6371008.8,r5=64,i5=(e,t)=>t.approximate===void 0?t.exact!==void 0&&e[t.exact]===!1:e[t.approximate]===!0,a5=(e,t)=>{let n=t/Qxe,r=e.latitude*Math.PI/180,i=e.longitude*Math.PI/180;return{type:`Polygon`,coordinates:[Array.from({length:65},(e,t)=>{let a=t%r5/r5*2*Math.PI,o=Math.asin(Math.sin(r)*Math.cos(n)+Math.cos(r)*Math.sin(n)*Math.cos(a));return[(i+Math.atan2(Math.sin(a)*Math.sin(n)*Math.cos(r),Math.cos(n)-Math.sin(r)*Math.sin(o)))*180/Math.PI,o*180/Math.PI]})]}},$xe=e=>Array.isArray(e)&&e.length>=2&&typeof e[0]==`number`&&typeof e[1]==`number`&&Math.abs(e[0])<=180&&Math.abs(e[1])<=90,o5=(e,t)=>Array.isArray(e)&&e.length>=t&&e.every($xe),s5=e=>Array.isArray(e)&&e.length>0&&e.every(e=>o5(e,4)),eSe=e=>Array.isArray(e)&&e.length>0&&e.every(e=>o5(e,2)),tSe=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch(e){if(e instanceof SyntaxError)return;throw e}},nSe=e=>{let t=tSe(e);if(typeof t!=`object`||!t)return;let n=t.type===`Feature`?t.geometry:t;if(typeof n!=`object`||!n)return;let{type:r,coordinates:i}=n;if(r===`Polygon`&&s5(i)||r===`MultiPolygon`&&Array.isArray(i)&&i.length>0&&i.every(s5)||r===`LineString`&&o5(i,2)||r===`MultiLineString`&&eSe(i))return{type:r,coordinates:i}},rSe=(e,t,n)=>{if(!i5(e,t))return;let r=t.area===void 0?void 0:nSe(e[t.area]);if(r)return r;let i=t.radius===void 0?void 0:t5(e[t.radius]);return i!==void 0&&Number.isFinite(i)&&i>0?a5(n,i):t.defaultRadius===void 0?void 0:a5(n,t.defaultRadius)},c5=(e,t)=>e.flatMap(e=>{let n=n5(e.record,t);if(!n)return[];if(!i5(e.record,t))return[{key:e.key,...n}];let r=rSe(e.record,t,n);return[{key:e.key,...n,approximate:!0,...r&&{area:r}}]}),iSe=(e,t)=>{let n=[];for(let r of e){let e=n.find(e=>Math.hypot(e.at.x-r.x,e.at.y-r.y)<=t);e?e.keys.push(r.key):n.push({at:r,keys:[r.key]})}return n.map(e=>({keys:e.keys,at:e.at.key}))},aSe=(e,t)=>{if(!e)return;let n=new Set(t.map(e=>e.key)),r=e.keys.filter(e=>n.has(e));if(r.length===0)return;let i=r.indexOf(e.keys[e.index]);return{keys:r,index:Math.max(i,0)}},l5=(e,t)=>({keys:e.keys,index:((e.index+t)%e.keys.length+e.keys.length)%e.keys.length}),oSe=({model:e,view:t,display:n,fields:r,filter:i,orderBy:a,area:o})=>{let s=W(),{resources:c,views:l}=G(),u={latitude:n.latitude,longitude:n.longitude},d=o?Yxe(i,u,o.bounds):``,f=o?Xxe(o.zoom):0;return Kh({queryKey:U.map(e.name,`${u.latitude},${u.longitude}`,f,d,a),enabled:o!==void 0,placeholderData:lh,queryFn:async()=>{let n=await s.map(e.name,{...u,zoom:f,filter:d,orderBy:a,labels:Y0(c,l,e,r),photos:oS(t)});return{rows:X0(c,e,r,sS(e,n.items,n.photos),n.labels).map(t=>CS(e,t)),buckets:n.buckets,total:n.totalSize}}})},sSe=(0,L.lazy)(()=>m(()=>import(`./records-map-DE5BswCb.js`).then(e=>({default:e.RecordsMap})),__vite__mapDeps([5,1,2,6,7,8,3,4,9]))),cSe=250,u5=`flex size-8 items-center justify-center rounded-full border border-border bg-background hover:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,d5=({model:e,view:t,display:n,filter:r,orderBy:i,fields:a,at:o,onMove:s,footer:c=!0,flush:u=!1})=>{let d=G().maps,f=d?.style,[p,m]=(0,L.useState)(),[h,_]=(0,L.useState)(),v=V3(h,cSe),[y,b]=(0,L.useState)(o===void 0),x=oSe({model:e,view:t,display:n,fields:a,filter:r,orderBy:i,area:y?Kxe:v}),S=x.isPlaceholderData?void 0:x.data,C=x.data?.rows??[],w=x.data?.buckets??[],T=c5(C,n),E=y&&S?Zxe(c5(S.rows,n),S.buckets):void 0,D=bS(t,n),O=(t?.names?.plural??q(e.name)).toLowerCase(),k=(t?.names?.singular??q(e.name)).toLowerCase(),A=aSe(p,C),j=A&&C.find(e=>e.key===A.keys[A.index]),M=new Set(T.filter(e=>e.approximate).map(e=>e.key)),N=e=>{let t=e.filter(e=>M.has(e)).length;return e.length===1?J(t===1?`showOneApproximate`:`showOne`,k):t===0?J(`showMany`,e.length,O):t===e.length?J(`showManyApproximate`,e.length,O):J(`showManySomeApproximate`,e.length,O,t)},P=e=>J(`zoomIn`,e.toLocaleString(l()),e===1?k:O),ee=(0,L.useRef)(null),[te,ne]=(0,L.useState)(0);if((0,L.useLayoutEffect)(()=>ne(ee.current?.offsetHeight??0),[j?.key]),!f)return(0,z.jsx)(Fg,{children:J(`needsStyle`)});let re=S?.total===0;return(0,z.jsxs)(`div`,{className:g(`flex h-full min-h-[36rem] flex-1 flex-col sm:min-h-[28rem]`,u&&`max-md:-mx-5 max-md:-mb-4 max-md:min-h-0`),children:[(0,z.jsxs)(`div`,{className:g(`relative min-h-0 flex-1 overflow-hidden rounded-lg border border-border bg-muted`,u&&`max-md:rounded-none max-md:border-0`),children:[(0,z.jsx)(L.Suspense,{fallback:null,children:(0,z.jsx)(sSe,{style:f,layers:d?.layers,initial:o,points:T,buckets:w,fit:E,onFitted:()=>b(!1),onMove:(e,t)=>{_(e),s?.(t)},selected:A?.keys,covered:A?te:0,onSelect:e=>m({keys:e,index:0}),onClear:()=>m(void 0),markerLabel:N,bucketLabel:P})}),x.error&&(0,z.jsx)(`div`,{className:`absolute inset-x-3 top-3 z-10`,children:(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:x.error})}),re&&(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-10 flex justify-center`,children:(0,z.jsxs)(`p`,{className:`pointer-events-auto flex items-center gap-3 rounded-full border border-border bg-background px-4 py-1.5 text-muted-foreground shadow`,role:`status`,children:[J(y?`noneMatch`:`noneHere`,O),!y&&(0,z.jsx)(V,{size:`sm`,onClick:()=>b(!0),children:J(`showAll`)})]})}),A&&j&&(0,z.jsx)(`div`,{ref:ee,className:`pointer-events-none absolute inset-x-3 bottom-3 z-10 flex justify-center`,children:(0,z.jsxs)(`div`,{className:`pointer-events-auto flex w-full max-w-[16rem] flex-col gap-2 sm:max-w-xs`,role:`group`,"aria-label":J(`chosen`,k),children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[M.has(j.key)&&(0,z.jsxs)(`span`,{className:`mr-auto flex items-center gap-1 rounded-full border border-border bg-background px-2 py-1 text-xs`,children:[(0,z.jsx)(Uee,{className:`size-3.5`,"aria-hidden":!0}),J(`approximatePosition`)]}),A.keys.length>1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":J(`previous`),className:u5,onClick:()=>m(l5(A,-1)),children:(0,z.jsx)(Ti,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{className:`rounded-full border border-border bg-background px-2 py-1 text-xs tabular-nums`,"aria-live":`polite`,children:[A.index+1,` / `,A.keys.length]}),(0,z.jsx)(`button`,{type:`button`,"aria-label":J(`next`),className:u5,onClick:()=>m(l5(A,1)),children:(0,z.jsx)(Di,{className:`size-4`,"aria-hidden":!0})})]}),(0,z.jsx)(`button`,{type:`button`,"aria-label":J(`close`),className:u5,onClick:()=>m(void 0),children:(0,z.jsx)(ss,{className:`size-4`,"aria-hidden":!0})})]}),(0,z.jsx)(`div`,{className:`shadow-lg`,children:(0,z.jsx)(N6,{model:e,view:t,display:D,row:j})})]})})]}),c&&(0,z.jsx)(`p`,{className:`hidden py-3 text-xs text-muted-foreground md:block`,children:lSe(x.data,O)})]})},lSe=(e,t)=>{if(!e)return`\xA0`;let n=e.total.toLocaleString(l());return e.buckets.length===0&&e.rows.length<e.total?`${e.rows.length.toLocaleString(l())} of ${n} ${t} in view`:`${n} ${t} in view`},f5=({value:e,options:t,onChange:n,label:r})=>{let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null),s=(0,L.useRef)(null),c=(0,L.useRef)([]),l=t.findIndex(t=>t.value===e),u=t[l];(0,L.useEffect)(()=>{if(!i)return;c.current[Math.max(l,0)]?.focus();let e=e=>{e.target instanceof Node&&!o.current?.contains(e.target)&&a(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[i]);let d=()=>{a(!1),s.current?.focus()};return(0,z.jsxs)(`div`,{ref:o,className:`relative shrink-0`,children:[(0,z.jsxs)(`button`,{ref:s,type:`button`,"aria-label":u?`${r}: ${u.label}`:r,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>a(!i),className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border-strong bg-background px-2.5 text-body font-medium shadow-sm transition-colors hover:bg-muted pointer-coarse:h-11`,children:[u?.icon&&(0,z.jsx)(u.icon,{className:`size-3.5`}),u?.label??r,(0,z.jsx)(Ci,{className:`size-3.5 text-muted-foreground`})]}),i&&(0,z.jsx)(`ul`,{role:`menu`,"aria-label":r,onKeyDown:e=>{if(e.key===`Escape`)return d();if(e.key===`Tab`)return a(!1);let n=B3(e.key,c.current.indexOf(document.activeElement),t.length);n!==void 0&&(e.preventDefault(),c.current[n]?.focus())},className:`absolute right-0 top-full z-30 mt-1 min-w-40 rounded-md border bg-background py-1 text-body shadow-pop`,children:t.map((t,r)=>(0,z.jsx)(`li`,{role:`none`,children:(0,z.jsxs)(`button`,{ref:e=>{c.current[r]=e},type:`button`,role:`menuitemradio`,"aria-checked":t.value===e,onClick:()=>{d(),t.value!==e&&n(t.value)},className:g(`flex min-h-9 w-full items-center gap-2 whitespace-nowrap px-3 py-1.5 text-left hover:bg-muted focus:bg-muted focus:outline-none pointer-coarse:min-h-11`,t.value===e&&`font-medium`),children:[t.icon?(0,z.jsx)(t.icon,{className:`size-3.5`}):(0,z.jsx)(`span`,{className:`size-3.5`}),(0,z.jsx)(`span`,{className:`flex-1`,children:t.label}),t.value===e&&(0,z.jsx)(xi,{className:`size-3.5 text-primary-text`})]})},t.value))})]})},uSe={table:Bo,cards:_a,kanban:Fo,board:Kee,list:ate,calendar:gi,timeline:Bee,map:Pa},p5=({view:e,value:t,onChange:n,menu:r=!1,choices:i=_S(e)})=>{if(i.length<2)return null;let a=i.map(e=>({value:e.name,label:e.label,icon:e.icon===void 0?void 0:uSe[e.icon]}));return r?(0,z.jsx)(f5,{label:J(`display`),value:t,onChange:n,options:a}):(0,z.jsx)(f,{label:J(`display`),size:`md`,value:t,onChange:n,options:a})},dSe=[[`asc`,`ascending`],[`desc`,`descending`]],m5=({model:e,view:t,display:n,orderBy:r,onChange:i,className:a})=>{let o=TS(r),s=uoe(e,t,n),c=s.includes(o.columnId)?s:[o.columnId,...s],l=e=>t?.fields[e]?.label??q(e);return(0,z.jsx)(`select`,{"aria-label":J(`sort`),value:`${o.columnId} ${o.direction}`,onChange:e=>i(e.target.value),className:g(`h-8 rounded-md border border-border-strong bg-background px-2.5 shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20`,a),children:c.flatMap(e=>dSe.map(([t,n])=>(0,z.jsxs)(`option`,{value:`${e} ${t}`,children:[l(e),`, `,J(n)]},`${e} ${t}`)))})},h5=(e,t,n,r)=>e.map(e=>{let i=t.fields[e.id],a=i&&gC(r,i,n?.fields[e.id]);return a?{...e,render:t=>(0,z.jsx)(vC,{shown:a,part:`cell`,field:i,value:t[e.id],fallback:W4(e,e.value?e.value(t):t[e.id])})}:e}),g5=e=>e.includes(`.`),fSe=({model:e,row:t,column:n})=>{let r=r2(NT(e,CS(e,t).record),n);return r.state===`loading`?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`…`}):r.state===`missing`?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,z.jsx)($0,{model:r.model,field:r.field,value:r.value})},pSe=(e,t,{resources:n,views:r})=>{let i=Sc(n,e.name,t),a=i.ok?i.steps.at(-1):void 0,o=a?.field.name??t;return{id:t,header:r[a?.model.name??e.name]?.fields[o]?.label??q(o),kind:`text`,width:200,render:n=>(0,z.jsx)(fSe,{model:e,row:n,column:t})}},_5=(e,t,n,r)=>{let i=new Map(h5(tS(e,t,[],n.filter(e=>!g5(e))),e,t,r.fieldTypes).map(e=>[e.id,e]));return n.flatMap(t=>g5(t)?[pSe(e,t,r)]:i.get(t)??[])},v5=(e,t,n)=>{let r=Object.hasOwn(e.fields,t)?e.fields[t]:void 0;return r?.type===`relation`&&r.relation!==void 0&&n[r.relation.resource]?.primaryKey.length===1},mSe=(e,t,n)=>{if(e.open!==void 0)return e.open!==e.field&&v5(t,e.open,n)?e.open:void 0;let r=t.primaryKey.filter(r=>r!==e.field&&r!==t.tenant&&v5(t,r,n));return r.length===1?r[0]:void 0},y5=(e,t)=>{let n=e[t],r=typeof n==`object`&&n&&`id`in n?n.id:n;return typeof r==`string`||typeof r==`number`?r:void 0},b5=(e,t)=>(t?.names?.singular??q(e.name)).toLowerCase(),hSe=({model:e,view:t,opens:n,resources:r,views:i,canUpdate:a})=>{let o=t=>({kind:`record`,resource:e.name,key:Kx(e,t)}),s=n&&e.fields[n]?.relation?.resource,c=s?r[s]:void 0,l=e=>{let t=n&&c?y5(e,n):void 0;return c&&t!==void 0?{kind:`record`,resource:c.name,key:t}:void 0},u=e=>l(e)??o(e),d=b5(e,t);return{address:u,actions:t=>{let n={label:s2(`open`,d),link:e=>t(o(e))};if(!c)return[n];let r=e=>a&&ST(e,`update`);return[{label:s2(`open`,b5(c,i[c.name])),available:e=>l(e)!==void 0,link:e=>t(l(e))},{label:s2(`edit`,d),available:r,link:n=>t({kind:`record`,resource:e.name,key:Kx(e,n),edit:!0})},{...n,available:e=>!r(e)}]}}},gSe=({model:e,filter:t,orderBy:n,limit:r,fields:i})=>{let a=W(),{resources:o,views:s}=G();return Kh({queryKey:[...U.list(e.name,t,n,r,`embedded`),i.join(`,`)],placeholderData:lh,queryFn:async()=>{let c=Y0(o,s,e,i),l=oS(s[e.name]),u=await a.search(e.name,{filter:t||void 0,orderBy:n||void 0,pageSize:r,count:`exact`,labels:c,photos:l}),d=X0(o,e,i,sS(e,u.items,u.photos),u.labels).map((t,n)=>({...t,id:Gx(e,u.items[n])}));return u.nextPageToken===``?{rows:d,total:d.length,estimated:!1}:{rows:d,total:u.totalSize??u.totalSizeEstimate,estimated:u.totalSize===void 0}}})},x5=({view:e,value:t,onChange:n})=>(0,z.jsx)(p5,{view:e,value:t,onChange:n,menu:!Mu()}),_Se=()=>(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-4 w-full`},t))}),S5=({model:e,view:t,filter:n,sort:r,columns:i,limit:a,display:o,empty:s,row:c=!1,viewAll:l,link:u=!0,opens:d})=>{let{resources:f,views:p}=G(),m=xT(cg(e.name),`update`),{fields:h}=hC(),{go:g,href:_}=AS(),v=Nu(),[y,b]=(0,L.useState)(r||wS(e,t)),x=i??eS(e,t),S=(0,L.useMemo)(()=>_5(e,t,x,{resources:f,views:p,fieldTypes:h}),[e,t,x.join(`,`),f,p,h]),C=(0,L.useMemo)(()=>SS(e,t,S.map(e=>e.id)),[e,t,S]),w=gSe({model:e,filter:n,orderBy:y,limit:a,fields:C}),T=w.data?.rows,E=(0,L.useMemo)(()=>T&&{total:T.length,rowAt:e=>T[e]},[T]),D=gS(t,o),O=t?.names?.plural??q(e.name),k=u&&(0,z.jsxs)(jS,{to:u2(e,t,v,l?{filter:l.filter,orderBy:wS(e,t),display:o,savedSearch:l.savedSearch}:{filter:n,orderBy:y,display:o}),onClick:l?.onOpen,className:`flex items-center gap-1 self-end font-medium text-primary-text hover:underline`,children:[l?l.label:(0,z.jsxs)(z.Fragment,{children:[s2(`viewAll`),` `,(0,z.jsx)(`span`,{className:`sr-only`,children:O.toLowerCase()})]}),(0,z.jsx)(Vr,{className:`size-3.5`,"aria-hidden":!0})]});if(w.isPending)return(0,z.jsx)(_Se,{});if(w.error)return(0,z.jsx)(rC,{title:s2(`couldNotLoad`),error:w.error});if(!E||E.total===0){let e=(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:s??s2(`nothingYet`)});return l&&u?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,k]}):e}let A={resource:e.name,rows:w.data.rows.map(t=>CS(e,t)),total:w.data.total,loading:!1,error:null,more:!1,loadMore:()=>void 0},j=hSe({model:e,view:t,opens:d,resources:f,views:p,canUpdate:m}),M=e=>({href:_(e),onFollow:()=>g(e)}),N=c2(E.total,w.data.total,w.data.estimated);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[D?D.kind===`cards`?(0,z.jsx)(Hxe,{model:e,view:t,display:D,list:A,row:c||v,footer:!1}):D.kind===`map`?(0,z.jsx)(d5,{model:e,view:t,display:D,filter:n,orderBy:y,fields:C,footer:!1}):D.kind===`board`?(0,z.jsx)(m8,{model:e,view:t,display:D,fields:C,filter:n,orderBy:y,limit:a}):D.kind===`calendar`?(0,z.jsx)(R8,{model:e,view:t,display:D,fields:C,filter:n}):D.kind===`timeline`?(0,z.jsx)(q8,{model:e,view:t,display:D,fields:C,filter:n}):(0,z.jsx)(X8,{display:D,list:A}):(0,z.jsx)(_3,{fit:!0,columns:S,source:E,latencyMs:0,sort:TS(y),onSortChange:e=>b(ES(e)),onOpenRow:e=>g(j.address(e)),rowLink:e=>M(j.address(e)),rowActions:j.actions(M),rowNumbers:!1,selectable:!1}),N&&u?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:N}),k]}):k]})},C5=(e,t,n)=>{let r=Nu(),i=pge(t),[a,o]=(0,L.useState)(()=>mge(localStorage,i)),s=(0,L.useCallback)(e=>{o(e),hge(localStorage,i,e)},[i]);return[l2(e,r,{picked:a,preferred:n}),s]},vSe=({model:e,view:t,filter:n=``,sort:r=``,columns:i,limit:a=10,display:o,title:s,description:c,empty:l,actions:u})=>{let[d,f]=C5(t,`page:${e.name}:${s??``}:${n}`,o);return(0,z.jsx)(GT,{title:s,description:c,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(x5,{view:t,value:d,onChange:f}),u]}),className:`h-full`,children:(0,z.jsx)(S5,{model:e,view:t,filter:n,sort:r,columns:i,limit:a,display:d,empty:l})})},ySe=({node:e,slots:t})=>{let n=HT(e),{resources:r,views:i}=G(),a=r[n.resource];return a?(0,z.jsx)(vSe,{...n,model:a,view:i[a.name],actions:t.actions}):null},w5=a({en:{email:`Email`,invite:`Invite`,expired:`Expired`,until:e=>`Until ${e}`,sendAgain:`Send again`,revoke:`Revoke`,passLinkOn:`This app cannot send email, so pass this link on yourself. It works once, until the invitation expires: {}`},nl:{email:`E-mailadres`,invite:`Uitnodigen`,expired:`Verlopen`,until:e=>`Tot ${e}`,sendAgain:`Opnieuw sturen`,revoke:`Intrekken`,passLinkOn:`Deze app kan geen e-mail sturen, dus geef deze link zelf door. Die werkt één keer, tot de uitnodiging verloopt: {}`}}),T5=({link:e})=>e?(0,z.jsx)(`p`,{className:`mt-3 break-all rounded-md border bg-muted px-3 py-2 text-xs`,children:gg(w5(`passLinkOn`),(0,z.jsx)(`span`,{className:`font-mono`,children:e}))}):null,E5=({title:e,description:t,onInvite:n,beside:r,children:i,incomplete:a=!1})=>{let[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(),{busy:u,error:d,run:f}=Ag(),p=()=>f(async()=>{l((await n(o.trim())).link),s(``)});return(0,z.jsxs)(vp,{title:e,description:t,children:[(0,z.jsx)(yp,{message:d}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,z.jsx)(Wd,{"aria-label":w5(`email`),type:`email`,placeholder:`name@example.com`,value:o,onChange:e=>s(e.target.value),wrapperClassName:`flex-1`}),r,(0,z.jsx)(V,{type:`submit`,variant:`primary`,loading:u,disabled:!o.trim()||a,children:w5(`invite`)})]}),i]}),(0,z.jsx)(T5,{link:c})]})},D5=({email:e,gives:t,expiresAt:n,onResend:r,onRevoke:i})=>{let[a,o]=(0,L.useState)(),{busy:s,error:c,run:u}=Ag(),d=new Date(n).getTime()<Date.now();return(0,z.jsxs)(`li`,{className:`px-3 py-2.5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate font-medium`,children:e}),(0,z.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t,` · `,d?w5(`expired`):w5(`until`,new Date(n).toLocaleDateString(l()))]})]}),(0,z.jsx)(V,{size:`sm`,loading:s,onClick:()=>void u(async()=>o((await r()).link)),children:w5(`sendAgain`)}),(0,z.jsx)(V,{size:`sm`,variant:`danger`,loading:s,onClick:()=>void u(i),children:w5(`revoke`)})]}),(0,z.jsx)(yp,{message:c}),(0,z.jsx)(T5,{link:a})]})},O5=({roles:e,selected:t,grantable:n,disabled:r,onChange:i})=>(0,z.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,children:e.map(e=>{let a=t.includes(e.name),o=r||!n.has(e.name);return(0,z.jsxs)(`label`,{title:o&&!r?K(`cannotChangeRole`):void 0,className:g(`inline-flex items-center gap-1.5`,o&&`text-muted-foreground`),children:[(0,z.jsx)(xg,{checked:a,label:e.label,onChange:o?void 0:n=>i(n?[...t,e.name]:t.filter(t=>t!==e.name)),className:g(o&&`cursor-default opacity-60`)}),e.label]},e.name)})}),bSe=(e,t)=>t.map(t=>Dg(e,t)).join(`, `),k5=a({en:{inviteSomeone:`Invite someone`,inviteDescription:`They get an email with a link to make their account, with the roles you tick.`,notAcceptedYet:`Not accepted yet`,sendingAgain:`Sending again gives a new link, which replaces the earlier one.`,nobodyWaiting:`Nobody is waiting.`,addAnAccount:`Add an account`,addDescription:`Makes the account at once, with the address counted as verified. Without a password, the person signs in another way this app allows, such as an emailed code.`,email:`Email`,name:`Name`,password:`Password`,passwordOptional:e=>`Password (optional, ${e}+ characters)`,addAccount:`Add account`,couldNotReadRoles:`Could not read the roles`,people:`People`,peopleDescription:`Everyone with an account. Roles decide what each sees and does; someone blocked cannot sign in, and is signed out at once.`,findSomeone:`Find someone`,emailAddress:`Email address`,keepOneRole:`Keep at least one role.`,blocked:`Blocked`,unblock:`Unblock`,block:`Block`},nl:{inviteSomeone:`Iemand uitnodigen`,inviteDescription:`Die krijgt een e-mail met een link om een account te maken, met de rollen die je aanvinkt.`,notAcceptedYet:`Nog niet geaccepteerd`,sendingAgain:`Opnieuw sturen geeft een nieuwe link, die de vorige vervangt.`,nobodyWaiting:`Er wacht niemand.`,addAnAccount:`Een account toevoegen`,addDescription:`Maakt het account meteen, met het adres als gecontroleerd. Zonder wachtwoord logt de persoon in op een andere manier die deze app toestaat, zoals een gemailde code.`,email:`E-mailadres`,name:`Naam`,password:`Wachtwoord`,passwordOptional:e=>`Wachtwoord (optioneel, ${e}+ tekens)`,addAccount:`Account toevoegen`,couldNotReadRoles:`Kon de rollen niet lezen`,people:`Mensen`,peopleDescription:`Iedereen met een account. Rollen bepalen wat ieder ziet en doet; wie geblokkeerd is, kan niet inloggen en wordt meteen uitgelogd.`,findSomeone:`Iemand zoeken`,emailAddress:`E-mailadres`,keepOneRole:`Houd minstens één rol.`,blocked:`Geblokkeerd`,unblock:`Deblokkeren`,block:`Blokkeren`}}),xSe=({roles:e})=>{let{session:t}=xf(),[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)([]),o=(0,L.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,L.useEffect)(o,[o]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(E5,{title:k5(`inviteSomeone`),description:k5(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,z.jsx)(O5,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,z.jsx)(vp,{title:k5(`notAcceptedYet`),description:i.length>0?k5(`sendingAgain`):k5(`nobodyWaiting`),children:i.length>0&&(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,z.jsx)(D5,{email:n.email,gives:bSe(e,n.roles),expiresAt:n.expiresAt,onResend:async()=>{let e=await t.users.invite({email:n.email,roles:n.roles});return o(),e},onRevoke:async()=>{await t.users.revoke(n.id),o()}},n.id))})})]})},SSe=({roles:e,onCreated:t})=>{let{session:n}=xf(),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)([]),{busy:d,error:f,run:p}=Ag(),m=()=>p(async()=>{await n.users.create({email:r.trim(),name:a.trim(),roles:l,...s&&{password:s}}),i(``),o(``),c(``),u([]),t()}),h=!r.trim()||!a.trim()||l.length===0||s!==``&&s.length<12;return(0,z.jsxs)(vp,{title:k5(`addAnAccount`),description:k5(`addDescription`),children:[(0,z.jsx)(yp,{message:f}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,z.jsx)(Wd,{"aria-label":k5(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,z.jsx)(Wd,{"aria-label":k5(`name`),placeholder:k5(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,z.jsx)(Wd,{"aria-label":k5(`password`),type:`password`,autoComplete:`new-password`,placeholder:k5(`passwordOptional`,12),value:s,onChange:e=>c(e.target.value)}),(0,z.jsx)(O5,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,z.jsx)(`div`,{children:(0,z.jsx)(V,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:k5(`addAccount`)})})]})]})},CSe=a({en:{showMore:`Show more`},nl:{showMore:`Meer tonen`}}),A5=({title:e,description:t,searchLabel:n,placeholder:r,query:i,onQuery:a,list:o,error:s,renderRow:c})=>(0,z.jsxs)(vp,{title:e,description:t,children:[(0,z.jsx)(yp,{message:s}),(0,z.jsx)(Wd,{"aria-label":n,placeholder:r,value:i,onChange:e=>a(e.target.value),leading:(0,z.jsx)(_o,{className:`size-3.5`}),wrapperClassName:`mb-2`}),(0,z.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[o.found.length,` of `,o.total]}),o.found.length>0&&(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:o.found.map(c)}),o.found.length<o.total&&(0,z.jsx)(V,{className:`mt-3`,loading:o.loading,onClick:()=>void o.more(),children:CSe(`showMore`)})]}),j5=(e,t)=>{let[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)(0),[o,s]=(0,L.useState)(!1),c=(0,L.useRef)(t);return c.current=t,(0,L.useEffect)(()=>{let n=setTimeout(()=>{s(!0),e(t,0).then(e=>{c.current===t&&(r(e.items),a(e.total),s(!1))},()=>{c.current===t&&(r([]),a(0),s(!1))})},200);return()=>clearTimeout(n)},[e,t]),{found:n,total:i,more:async()=>{let i=t;s(!0);let o=await e(i,n.length).catch(()=>void 0);c.current===i&&(o&&(r(e=>[...e,...o.items]),a(o.total)),s(!1))},loading:o}},M5=({name:e,email:t,self:n,actions:r,children:i,error:a})=>(0,z.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`span`,{className:`block truncate font-medium`,children:[e,n&&` (you)`]}),(0,z.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t})]}),r]}),i,(0,z.jsx)(yp,{message:a})]}),wSe=({user:e,roles:t,self:n})=>{let{session:r}=xf(),[i,a]=(0,L.useState)(e),{busy:o,error:s,run:c,setError:l}=Ag(),u=e=>{if(e.length===0)return l(k5(`keepOneRole`));c(async()=>{await r.users.setRoles(i.id,e),a({...i,roles:e})})},d=e=>void c(async()=>{await(e?r.users.block(i.id):r.users.unblock(i.id)),a({...i,blocked:e})});return(0,z.jsx)(M5,{name:i.name,email:i.email,self:n,error:s,actions:(0,z.jsxs)(z.Fragment,{children:[i.blocked&&(0,z.jsx)(_d,{tone:`red`,children:k5(`blocked`)}),!n&&(i.blocked?(0,z.jsx)(V,{size:`sm`,loading:o,onClick:()=>d(!1),children:k5(`unblock`)}):(0,z.jsx)(V,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:k5(`block`)}))]}),children:(0,z.jsx)(O5,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},TSe=({roles:e,version:t})=>{let{session:n,state:r}=xf(),[i,a]=(0,L.useState)(``),o=j5((0,L.useCallback)((e,t)=>n.users.search(e,t).then(e=>({items:e.users,total:e.total})),[n,t]),i),s=r.kind===`signed-in`?r.user.id:void 0;return(0,z.jsx)(A5,{title:k5(`people`),description:k5(`peopleDescription`),searchLabel:k5(`findSomeone`),placeholder:k5(`emailAddress`),query:i,onQuery:a,list:o,renderRow:n=>(0,z.jsx)(wSe,{user:n,roles:e,self:n.id===s},`${t}/${n.id}`)})},ESe=()=>{let{session:e}=xf(),[t,n]=(0,L.useState)([]),[r,i]=(0,L.useState)();return(0,L.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof Oc?sf(e):k5(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},DSe={Page:cge,Grid:tge,Card:qT,Stat:Zbe,RecordCard:dge,Field:Xhe,Table:ySe,CardRow:YT,RecordRow:qbe,RecordCards:bge,Chart:Ghe,Progress:lge,ModalForm:sge,Action:WT,Show:Jbe,Link:nge,Users:()=>{let{roles:e,error:t}=ESe(),[n,r]=(0,L.useState)(0);return(0,z.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,z.jsx)(yp,{message:t}),(0,z.jsx)(TSe,{roles:e,version:n}),(0,z.jsx)(xSe,{roles:e}),(0,z.jsx)(SSe,{roles:e,onCreated:()=>r(e=>e+1)})]})}},N5=e=>typeof e==`string`||!e.custom&&e.type===`Link`,P5=e=>{let t=[];for(let n of e){let e=t.at(-1);N5(n)&&e&&N5(e[0])?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return N5(n)?(0,z.jsx)(`p`,{className:`leading-6`,children:e.map((e,t)=>typeof e==`string`?(0,z.jsx)(L.Fragment,{children:e},t):(0,z.jsx)(F5,{node:e},t))},t):(0,z.jsx)(F5,{node:n},t)})},OSe=e=>hc(e)||Array.isArray(e)&&e.length>0&&e.every(hc),kSe=e=>Object.fromEntries(Object.entries(e.props).flatMap(([e,t])=>OSe(t)?[[e,(0,z.jsx)(z.Fragment,{children:P5(Array.isArray(t)?t:[t])})]]:[])),F5=({node:e})=>{let{components:t}=hC();if(e.custom){let n=t?.[e.type];return n?(0,z.jsx)(Lg,{name:e.type,children:(0,z.jsx)(n,{...Jn(e.props),children:e.children.length>0?P5(e.children):void 0})}):(0,z.jsx)(Fg,{children:gg(Ig(`noComponent`),e.type)})}let n=DSe[e.type];return n?(0,z.jsx)(n,{node:e,slots:kSe(e),children:P5(e.children)}):(0,z.jsx)(Fg,{children:gg(Ig(`unknownBlock`),e.type)})},I5=({name:e})=>{let t=G().pages[e];return t?(0,z.jsx)(F5,{node:t.tree}):(0,z.jsx)(sg,{title:Ig(`notFound`),children:gg(Ig(`noPage`),e)})},L5=a({en:{details:`Details`,history:`History`,comments:`Comments`,summary:`Summary`,loading:`Loading`,fetching:`Fetching the record.`,noRecord:`This record does not exist, or you cannot see it.`,couldNotLoad:`Could not load the record`,someoneElse:`Someone else`,justNow:`just now`,saved:`Saved`,save:`Save`,cancel:`Cancel`,unsavedChanges:`Unsaved changes`,notSaved:`Not saved`,linesChanged:`The lines were changed by someone else`,linesReloaded:`The lines were reloaded. Your new order is kept: Save again to apply it.`,unsavedKept:`You have unsaved changes to this record.`,continueEditing:`Continue editing`,discard:`Discard`,unsavedRestored:`Your unsaved changes were restored.`,keep:`Keep`,savingSubject:e=>`Saving ${e}...`,subjectSaved:e=>`${e} saved`,changedBySomeoneElse:`Changed by someone else`,couldNotSave:`Could not save`,recordActions:`Record actions`,edit:`Edit`,delete:`Delete`,nothingYet:`Nothing here yet.`,couldNotLoadRelated:`Could not load`,relatedRecords:`Related records`,lines:`Lines`,linesHelp:`What the document bills for. Drag the handle, or use the menu, to change the order; Save applies it.`},nl:{details:`Details`,history:`Geschiedenis`,comments:`Opmerkingen`,summary:`Overzicht`,loading:`Laden`,fetching:`Het record wordt opgehaald.`,noRecord:`Dit record bestaat niet, of je mag het niet zien.`,couldNotLoad:`Kon het record niet laden`,someoneElse:`Iemand anders`,justNow:`zojuist`,saved:`Bewaard`,save:`Bewaren`,cancel:`Annuleren`,unsavedChanges:`Niet bewaarde wijzigingen`,notSaved:`Niet bewaard`,linesChanged:`De regels zijn door iemand anders gewijzigd`,linesReloaded:`De regels zijn opnieuw geladen. Je nieuwe volgorde is behouden: bewaar opnieuw om hem toe te passen.`,unsavedKept:`Je hebt niet bewaarde wijzigingen in dit record.`,continueEditing:`Verder bewerken`,discard:`Weggooien`,unsavedRestored:`Je niet bewaarde wijzigingen zijn teruggezet.`,keep:`Houden`,savingSubject:e=>`${e} bewaren...`,subjectSaved:e=>`${e} bewaard`,changedBySomeoneElse:`Gewijzigd door iemand anders`,couldNotSave:`Kon niet bewaren`,recordActions:`Recordacties`,edit:`Bewerken`,delete:`Verwijderen`,nothingYet:`Hier staat nog niets.`,couldNotLoadRelated:`Kon niet laden`,relatedRecords:`Gerelateerde records`,lines:`Regels`,linesHelp:`Waar het document voor factureert. Sleep de greep, of gebruik het menu, om de volgorde te wijzigen; Bewaren past hem toe.`}}),ASe=2e3,R5=(e,t)=>{let n=Hb(),[r,i]=(0,L.useState)(`idle`),[a,o]=(0,L.useState)(),s=(0,L.useRef)(void 0);return(0,L.useEffect)(()=>()=>clearTimeout(s.current),[]),{phase:r,message:a,run:async r=>{let a=e===`toast`?n.show({state:`loading`,title:L5(`savingSubject`,t)}):void 0;o(void 0),e===`button`&&i(`saving`);try{return await r(),a!==void 0&&n.update(a,{state:`success`,title:L5(`subjectSaved`,t)}),e===`button`&&(i(`saved`),s.current=setTimeout(()=>i(`idle`),ASe)),!0}catch(t){if(!Xs(t))throw t;let r=t.status===412?L5(`changedBySomeoneElse`):L5(`couldNotSave`),s=jC(t);return a!==void 0&&n.update(a,{state:`error`,title:r,description:s}),e===`button`&&(i(`idle`),o(`${r}: ${s}`)),!1}}}},z5=({title:e,eyebrow:t,submit:n,saving:r,disabled:i,error:a,errorTitle:o=YS(`notSaved`),onSubmit:s,onCancel:c,children:l,ref:u})=>{let d=(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c&&(0,z.jsx)(V,{className:`max-sm:min-h-11`,onClick:c,children:YS(`cancel`)}),(0,z.jsx)(V,{variant:`primary`,type:`submit`,className:`max-sm:min-h-11 max-sm:flex-1`,loading:r,disabled:i,children:n})]}),f=a!==void 0&&(0,z.jsx)(`div`,{className:`mt-4`,children:(0,z.jsx)(rC,{title:o,error:a})}),p=(0,z.jsx)(`div`,{className:`divide-y divide-border`,children:l}),m=e=>{e.preventDefault(),s()};return e===void 0?(0,z.jsxs)(`form`,{ref:u,className:`max-w-[760px]`,onSubmit:m,children:[f,p,(0,z.jsx)(`footer`,{className:`border-t pt-6 sm:flex sm:justify-end`,children:d})]}):(0,z.jsx)(`form`,{ref:u,className:`flex-1`,onSubmit:m,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-[760px] px-4 py-6 md:px-10 md:py-8`,children:[(0,z.jsxs)(`header`,{className:`flex flex-col gap-4 border-b pb-6 sm:flex-row sm:items-end sm:justify-between sm:gap-6`,children:[(0,z.jsxs)(`div`,{children:[t&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),(0,z.jsx)(`h1`,{className:`mt-1 text-2xl font-semibold tracking-tight`,children:e})]}),d]}),f,p]})})},jSe=({noun:e,collection:t,sections:n,saving:r,message:i,onSubmit:a,onCancel:o,ref:s})=>(0,z.jsx)(z5,{ref:s,title:YS(`title`,e),eyebrow:t,submit:YS(`submit`,e),saving:r,error:i?Error(i):void 0,errorTitle:YS(`notCreated`),onSubmit:a,onCancel:o,children:n.map(e=>(0,z.jsx)(qb,{title:e.title,help:e.help,children:(0,z.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:e.fields.map(e=>(0,z.jsx)(Gb,{name:e.name,label:e.label,required:e.required,help:e.help,error:e.error,wide:e.wide,children:e.editor},e.name))})},e.title))}),MSe=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),NSe=({resource:e,values:t})=>{let n=G(),r=n.resources[e],i=cg(e);return r?xT(i,`create`)?(0,z.jsx)(PSe,{resource:e,values:t}):(0,z.jsx)(sg,{title:YS(`notAllowed`),children:YS(`cannotCreate`,n.views[e]?.names?.plural.toLowerCase()??e)}):(0,z.jsx)(sg,{title:H(`notFound`),children:H(`noResource`,e)})},PSe=({resource:e,values:t})=>{let n=G(),r=n.resources[e],i=n.views[e],a=W(),o=Km(),{go:s}=AS(),c=i?.names?.singular??q(e),l=R5(i?.saveFeedback??`toast`,YS(`subject`,c)),u=woe(r,i),[d,f]=(0,L.useState)(()=>eC(r,u,t)),[p,m]=(0,L.useState)({}),[h,g]=(0,L.useState)(0),_=MC(h);(0,L.useEffect)(()=>{for(let[e,i]of Object.entries(t??{})){let t=n.resources[r.fields[e]?.relation?.resource??``];t&&q0(o,a,t,[i],n.views[t.name]).then(t=>{let n=t.get(i);n&&f(t=>XS(t[e])&&t[e].key===i?{...t,[e]:{key:i,label:n}}:t)})}},[t,n,r,a,o]);let v=(e,t)=>{m(t=>MSe(t,e)),f(n=>({...n,[e]:t}))},y=()=>l.run(async()=>{let t;try{t=await a.create(e,QS(r,n.resources,d))}catch(e){let t=AC(e);throw m(t),Object.keys(t).length>0&&g(e=>e+1),e}for(let t of[`page`,`list`,`first-page`,`map`,`facets`,`series`])o.invalidateQueries({queryKey:[t,e]});s({kind:`record`,resource:e,key:Kx(r,t.record)},{replace:!0})}),b=u.map(e=>({title:e.title,help:e.help,fields:e.fields.map(e=>{let t=r.fields[e],a=d[e],o=t.relation?n.resources[t.relation.resource]:void 0,s=i?.fields[e]?.label??q(e),c=p[e];return{name:e,label:s,help:i?.fields[e]?.help,required:$S(t),error:c&&kC(t,s,c),wide:!!(i?.fields[e]?.multiline||i?.fields[e]?.markdown),editor:(0,z.jsx)(SC,{field:t,hints:i?.fields[e],value:XS(a)?a.key:a??(t.type!==`boolean`&&``),stored:void 0,relationLabel:XS(a)?a.label:void 0,placeholder:tC(t)?YS(`setByDatabase`):void 0,relationPicker:o?{target:o,view:n.views[o.name]}:void 0,invalid:!!p[e],resource:r.name,onChange:t=>v(e,t)})}})}));return(0,z.jsx)(jSe,{ref:_,noun:c,collection:i?.names?.plural??q(e),sections:b,saving:l.phase===`saving`,message:l.message,onSubmit:()=>void y(),onCancel:()=>s({kind:`list`,resource:e})})},FSe=({resource:e,values:t})=>{let n=G(),r=n.views[e];return r?.create?n.pages[r.create.page]?(0,z.jsx)(I5,{name:r.create.page}):(0,z.jsx)(sg,{title:YS(`notAllowed`),children:YS(`cannotCreate`,r.names?.plural.toLowerCase()??q(e))}):(0,z.jsx)(NSe,{resource:e,values:t},new URLSearchParams(t).toString())},ISe=(e,t)=>{let n=new Map(t.map(e=>[e.value,e.count]));return e.map(([e,t])=>({value:e,label:t,...n.get(e)!==void 0&&{count:n.get(e)}}))},LSe=(e,t)=>[...new Set(t.filter(t=>!e.includes(t)))],RSe=Vn(),zSe=(e,t)=>{let n=W(),[r,i]=(0,L.useState)({}),a=e=>!!e?.search?.length&&e.primaryKey.length===1,o=Wh({queries:e.map(({id:e,target:i})=>{let o=(r[e]??``).trim();return{queryKey:[`reference-search`,e,i?.name??``,o],enabled:a(i)&&o!==``,placeholderData:lh,queryFn:async()=>{let e=i.primaryKey[0],r=Vx(i,t[i.name]);return(await n.list(i.name,{filter:Fn(RSe.search(o)),fields:[e,r],pageSize:20})).items.map(t=>[String(t[e]),String(t[r])])}}})});return e.map(({id:e,target:t},n)=>{if(!a(t))return{};let s=t=>i(n=>({...n,[e]:t}));return(r[e]??``).trim()===``?{onSearch:s}:{onSearch:s,matches:o[n]?.data??[]}})},BSe=24,VSe=({model:e,resources:t,views:n,view:r,state:i,extras:a})=>{let o=W(),s=Km(),c=l6(r,e),l=e=>r?.fields[e]?.label??q(e),u=n=>{let r=e.fields[n];return r?.type===`relation`&&r.relation?t[r.relation.resource]:void 0},d=c.facets.flatMap(e=>(e.flags?e.options.map(e=>e.value):[e.id]).map(t=>({group:e.id,field:t}))),f=Wh({queries:d.map(({group:t,field:r})=>{let s=t6(c,{...i,facets:{...i.facets,[t]:[]}},a),l=u(r),d=l?.primaryKey.length===1?Vx(l,n[l.name]):void 0;return{queryKey:U.facets(e.name,r,s),queryFn:()=>o.facets(e.name,r,{filter:s,limit:50,...d&&{label:d}})}})}),p=(e,t)=>f[d.findIndex(n=>n.group===e&&n.field===t)]?.data,m=Wh({queries:c.facets.map(t=>{let r=u(t.id),a=LSe((p(t.id,t.id)??[]).flatMap(e=>e.value===null?[]:[String(e.value)]),i.facets[t.id]??[]);return{queryKey:U.labels(`facet:${e.name}.${t.id}`,a.join(`,`)),enabled:!!r&&a.length>0,queryFn:async()=>[...await q0(s,o,r,a,n[r.name])]}})}),h=zSe(c.facets.map(e=>({id:e.id,target:e.combobox?u(e.id):void 0})),n),g=c.ranges??[],_=Wh({queries:g.map(t=>{let n=t6(c,N3(i,t.id,void 0),a),s=u6(r,t.id)?BSe:1;return{queryKey:U.histogram(e.name,t.id,s,n),queryFn:()=>o.histogram(e.name,t.id,{filter:n,buckets:s})}})});return{facets:c.facets.map((t,n)=>{if(t.flags){let e=t.options.map(({value:e})=>({value:e,label:l(e),count:p(t.id,e)?.find(e=>String(e.value)===`true`)?.count??0}));return{...t,options:e}}let i=e.fields[t.id],a=(p(t.id,t.id)??[]).flatMap(e=>e.label===void 0?[]:[[String(e.value),e.label]]),o=new Map([...a,...m[n]?.data??[]]),s=(p(t.id,t.id)??[]).flatMap(e=>e.value===null?[]:[{value:String(e.value),label:i?.type===`enum`?ps(String(e.value),r?.fields[t.id]?.valueLabels):o.get(String(e.value))??String(e.value),count:e.count}]),c=h[n];return{...t,label:l(t.id),options:c.matches?ISe(c.matches,s):s,...o.size>0&&{labels:Object.fromEntries(o)},...c.onSearch&&{onSearch:c.onSearch}}}),ranges:g.flatMap((e,t)=>{let n=_[t]?.data;return!n||n.min===null||n.max===null?[]:[{...e,label:l(e.id),min:Math.floor(n.min),max:Math.ceil(n.max),step:Math.max(1,Math.round((n.max-n.min)/100)),histogram:u6(r,e.id)?n.buckets.map(e=>e.count):[],format:d6(r,e.id)}]}),...c.dateField&&{datePresets:c.datePresets??!0,dateField:c.dateField,dateKind:c.dateKind,...c.dateSecondary&&{dateSecondary:!0}},toggles:c.toggles?.map(e=>({...e,label:l(e.id)}))}},B5=a({en:{confirmTitle:e=>`Delete ${e}?`,confirmDescription:(e,t)=>`This ${e.toLowerCase()} will be removed. This cannot be undone.`,cancel:`Cancel`,delete:`Delete`,changedTitle:e=>`${e} was changed since you opened it`,changedDescription:`Someone saved this record in the meantime. Review what changed before you delete it.`,reviewChanges:`Review changes`,deleteAnyway:`Delete anyway`,noVisibleChanges:`No visible fields differ; the record was saved again with the same values.`,bulkConfirmTitle:(e,t)=>`Delete ${e} ${e===1?t.replace(/s$/,``):t.toLowerCase()}?`,bulkConfirmDescription:`This cannot be undone. Each record is deleted only if it has not changed since the list loaded; anything that changed is reported and kept.`,deleteCount:e=>`Delete ${e}`,deleting:`Deleting`,progress:(e,t)=>`${e} of ${t} done`,working:`Working`,deleted:e=>`Deleted ${e}`,deletedOf:(e,t)=>`Deleted ${e} of ${t}`,kept:e=>`${e} could not be deleted and were kept.`,done:`Done`,deletedToast:e=>`${e} deleted`,undo:`Undo`,restored:e=>`${e} restored`,alreadyBack:e=>`${e} is already back`,couldNotRestore:e=>`Could not restore ${e}`,couldNotDelete:e=>`Could not delete ${e}`,changedSinceLoaded:`Changed since the list loaded, so it was kept.`,stillPointAt:(e,t)=>`${e} still point at this ${t.toLowerCase()}.`,show:e=>`Show ${e.toLowerCase()}`},nl:{confirmTitle:e=>`${e} verwijderen?`,confirmDescription:(e,t)=>`${t} wordt verwijderd. Dit kan niet ongedaan worden gemaakt.`,cancel:`Annuleren`,delete:`Verwijderen`,changedTitle:e=>`${e} is gewijzigd sinds je het opende`,changedDescription:`Iemand heeft dit record intussen bewaard. Bekijk wat er veranderde voordat je het verwijdert.`,reviewChanges:`Wijzigingen bekijken`,deleteAnyway:`Toch verwijderen`,noVisibleChanges:`Geen zichtbaar veld verschilt; het record is opnieuw bewaard met dezelfde waarden.`,bulkConfirmTitle:(e,t)=>e===1?`Eén record verwijderen?`:`${e} ${t.toLowerCase()} verwijderen?`,bulkConfirmDescription:`Dit kan niet ongedaan worden gemaakt. Elk record wordt alleen verwijderd als het niet is gewijzigd sinds de lijst laadde; wat wel is gewijzigd, wordt gemeld en behouden.`,deleteCount:e=>`${e} verwijderen`,deleting:`Verwijderen`,progress:(e,t)=>`${e} van ${t} klaar`,working:`Bezig`,deleted:e=>`${e} verwijderd`,deletedOf:(e,t)=>`${e} van ${t} verwijderd`,kept:e=>`${e} kon${e===1?``:`den`} niet worden verwijderd en ${e===1?`is`:`zijn`} behouden.`,done:`Klaar`,deletedToast:e=>`${e} verwijderd`,undo:`Ongedaan maken`,restored:e=>`${e} teruggezet`,alreadyBack:e=>`${e} is al terug`,couldNotRestore:e=>`Kon ${e} niet terugzetten`,couldNotDelete:e=>`Kon ${e} niet verwijderen`,changedSinceLoaded:`Gewijzigd sinds de lijst laadde, dus behouden.`,stillPointAt:(e,t)=>`${e} verwijzen hier nog naar.`,show:e=>`${e} tonen`}}),HSe=Vn(),USe=({blockingPlural:e,noun:t})=>B5(`stillPointAt`,e,t),WSe=({blockedBy:e,resources:t,views:n,noun:r,key:i})=>{let{resource:a,field:o}=e;if(!t[a])return;let s=n[a]?.names?.plural??q(a),c=USe({blockingPlural:s,noun:r});if(!o||i===void 0)return{text:c};let l={kind:`list`,resource:a,filter:Fn(HSe.eq(o,i))};return{text:c,link:{label:B5(`show`,s),to:l}}},GSe=({title:e,noun:t,busy:n,onConfirm:r,onCancel:i})=>(0,z.jsx)(_p,{title:B5(`confirmTitle`,e),description:B5(`confirmDescription`,t,e),onClose:i,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:i,children:B5(`cancel`)}),(0,z.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:r,children:B5(`delete`)})]})}),KSe=({title:e,changes:t,busy:n,onReview:r,onDeleteAnyway:i,onCancel:a})=>(0,z.jsx)(_p,{title:B5(`changedTitle`,e),description:B5(`changedDescription`),onClose:a,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:r,children:B5(`reviewChanges`)}),(0,z.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:i,children:B5(`deleteAnyway`)})]}),children:t.length===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:B5(`noVisibleChanges`)}):(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:t.map(e=>(0,z.jsxs)(`li`,{className:`grid grid-cols-[96px_1fr] gap-3 px-3 py-2`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,z.jsx)(`span`,{className:`font-medium`,children:e.after})]})]},e.field))})}),V5=e=>{if(e.stage===`confirm`)return(0,z.jsx)(_p,{title:B5(`bulkConfirmTitle`,e.count,e.plural),description:B5(`bulkConfirmDescription`),onClose:e.onCancel,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:e.onCancel,children:B5(`cancel`)}),(0,z.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,onClick:e.onConfirm,children:B5(`deleteCount`,e.count)})]})});if(e.stage===`running`)return(0,z.jsx)(_p,{title:B5(`deleting`),description:B5(`progress`,e.done,e.total),onClose:()=>void 0,actions:(0,z.jsx)(V,{loading:!0,disabled:!0,children:B5(`working`)})});let t=e.total-e.failures.length;return(0,z.jsx)(_p,{title:e.failures.length===0?B5(`deleted`,t):B5(`deletedOf`,t,e.total),description:e.failures.length===0?void 0:B5(`kept`,e.failures.length),onClose:e.onClose,actions:(0,z.jsx)(V,{variant:`primary`,onClick:e.onClose,children:B5(`done`)}),children:e.failures.length>0&&(0,z.jsx)(`ul`,{className:`max-h-48 divide-y overflow-y-auto rounded-md border`,children:e.failures.map(e=>(0,z.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,z.jsx)(`span`,{className:`block text-xs text-danger-text`,children:e.message})]},e.title))})})},qSe=new Set([`updated_at`,`updatedAt`]),JSe=(e,t,n,r)=>Object.values(e.fields).flatMap(e=>{if(qSe.has(e.name)||JSON.stringify(n[e.name]??null)===JSON.stringify(r[e.name]??null))return[];let i=t?.fields[e.name];return[{field:e.name,label:i?.label??q(e.name),before:rS(e,n[e.name],i),after:rS(e,r[e.name],i)}]}),YSe=4,H5=({model:e,view:t,onDeleted:n,onReview:r,restore:i})=>{let a=W(),o=Km(),s=Hb(),[c,l]=(0,L.useState)(),[u,d]=(0,L.useState)(!1),f=t?.names?.singular??q(e.name),p=t?.names?.plural??q(e.name),{resources:m,views:h}=G(),{href:g,open:_}=AS(),v=(t,n)=>t.blockedBy&&WSe({blockedBy:t.blockedBy,resources:m,views:h,noun:f,...e.primaryKey.length===1&&{key:n.key}}),y=()=>{for(let t of[`page`,`list`,`first-page`,`map`])o.invalidateQueries({queryKey:[t,e.name]});for(let t of[`facets`,`series`,`histogram`])o.invalidateQueries({queryKey:[t,e.name]})},b=async(t,n)=>{let r=n??(await a.get(e.name,t.key)).etag;try{await a.remove(e.name,t.key,{etag:r})}catch(e){if(!(e instanceof Ys))throw e;return e}},x=t=>{y(),l(void 0),n?.(t),s.show({state:`success`,title:B5(`deletedToast`,t.title),...e.softDelete&&i&&{action:{label:B5(`undo`),onClick:()=>{i(t).then(()=>{y(),s.show({state:`success`,title:B5(`restored`,t.title)})},e=>{if(!Xs(e))throw e;y(),s.show({state:e.status===409?`success`:`error`,title:e.status===409?B5(`alreadyBack`,t.title):B5(`couldNotRestore`,t.title),description:e.status===409?void 0:e.message})})}}}})},S=async(n,r)=>{d(!0);try{if(!await b(n,r))return x(n);let i=(await a.get(e.name,n.key)).record;l({kind:`conflict`,target:n,fresh:i,changes:JSe(e,t,n.snapshot,i)})}catch(e){if(!Xs(e))throw e;l(void 0);let t=v(e,n);s.show({state:`error`,title:B5(`couldNotDelete`,n.title),description:t?.text??e.message,...t?.link&&{action:{label:t.link.label,href:g(t.link.to),onNavigate:_}}})}finally{d(!1)}},C=async e=>{try{return await b(e,e.etag)?{title:e.title,message:B5(`changedSinceLoaded`)}:void 0}catch(t){if(!Xs(t))throw t;return{title:e.title,message:v(t,e)?.text??t.message}}},w=async e=>{let t=[],n=0;l({kind:`bulk-running`,done:n,total:e.length});let r=[...e];await Promise.all(Array.from({length:Math.min(YSe,e.length)},async()=>{for(let i=r.shift();i;i=r.shift()){let r=await C(i);r&&t.push(r),n+=1,l({kind:`bulk-running`,done:n,total:e.length})}})),y(),l({kind:`bulk-done`,total:e.length,failures:t})},T=()=>l(void 0);return{dialogs:c&&(0,z.jsxs)(z.Fragment,{children:[c.kind===`confirm`&&(0,z.jsx)(GSe,{title:c.target.title,noun:f,busy:u,onCancel:T,onConfirm:()=>void S(c.target,c.target.etag)}),c.kind===`conflict`&&(0,z.jsx)(KSe,{title:c.target.title,changes:c.changes,busy:u,onCancel:T,onReview:()=>{T(),r?.(c.target,c.fresh)},onDeleteAnyway:()=>void S(c.target,`*`)}),c.kind===`bulk-confirm`&&(0,z.jsx)(V5,{stage:`confirm`,count:c.targets.length,plural:p,onCancel:T,onConfirm:()=>void w(c.targets)}),c.kind===`bulk-running`&&(0,z.jsx)(V5,{stage:`running`,done:c.done,total:c.total}),c.kind===`bulk-done`&&(0,z.jsx)(V5,{stage:`done`,total:c.total,failures:c.failures,onClose:T})]}),start:t=>e.softDelete?S(t,t.etag):l({kind:`confirm`,target:t}),startBulk:e=>l({kind:`bulk-confirm`,targets:e})}},U5=e=>{let t=W();return e.softDelete?async n=>void await t.undelete(e.name,n.key):void 0},W5=(e,t,n)=>e?.create?Object.hasOwn(t,e.create.page):xT(n,`create`),$=a({en:{import:`Import`,importPlural:e=>`Import ${e.toLowerCase()}`,couldNotReadFile:`Could not read the file`,couldNotCheck:`Could not check the rows`,cancel:`Cancel`,next:`Next`,checkRows:`Check rows`,back:`Back`,checking:`Checking`,importRows:(e,t)=>`Import ${e} ${t===1?`row`:`rows`}`,cancelImport:`Cancel import`,done:`Done`,file:`File`,fileHint:`An Excel workbook (.xlsx) or a CSV file saved as UTF-8. Its first row names the columns.`,reading:e=>`Reading ${e}…`,theFile:`the file`,sheet:`Sheet`,create:`Create`,update:`Update`,upsert:`Create or update`,createHint:`Each row creates a record.`,updateHint:`Each row updates the record its value finds; a row that finds none is not imported.`,upsertHint:`Each row updates the record its value finds, or creates one when it finds none.`,doNotImport:`Do not import`,rows:`Rows`,whatEachRowDoes:`What each row does`,findBy:`Find records by`,chooseField:`Choose a field`,findByHint:`A field no two records share, such as the key or an email.`,foundInColumn:`Found in column`,chooseColumn:`Choose a column`,numbers:`Numbers`,dates:`Dates`,dayFirst:`Day first (31/12/2026)`,monthFirst:`Month first (12/31/2026)`,datesHint:`Dates written as 2026-12-31 read the same either way. Times without a zone are your own time.`,requiredMarked:`New records need the fields marked *.`,columns:`Columns`,emptyInFirstRows:`Empty in the first rows`,field:`Field`,fieldFor:e=>`Field for ${e}`,foundBy:`Found by`,pluralFoundBy:e=>`${e} found by`,noColumnFills:e=>`No column fills ${e}, which new records need.`,rowsNotImported:`Rows not imported`,rowProblems:e=>`Row ${e}:`,andMore:e=>`And ${e} more rows, all in the file.`,checkingRows:e=>`Checking rows… ${e} read`,check:`Check`,toCreate:`To create`,toUpdate:`To update`,withProblems:`With problems`,firstRows:`First rows`,row:`Row`,problemRows:`Rows with problems, which are skipped`,download:`Download`,batches:e=>`Rows are saved in batches of ${e}. Cancelling, or an error, keeps the batches already saved; a row the server refuses is listed and the others are saved.`,stopping:`Stopping after this batch…`,saving:`Saving rows…`,rowsSaved:`Rows saved`,stopped:`The import stopped. The rows counted below were saved.`,cancelled:`Cancelled. The rows counted below were saved.`,summary:`Import summary`,created:`Created`,updated:`Updated`,skipped:`Skipped`,failed:`Failed`,notWrittenHint:`Skipped rows had problems in the file; the server refused the failed ones. The file holds each with the reason, to fix and import again.`,notImportedFile:e=>`${e} - not imported.csv`,line:`Line`,problems:`Problems`,notNumber:e=>`${e} is not a number`,notWholeNumber:e=>`${e} is not a whole number`,tooLarge:e=>`${e} is too large`,notBoolean:e=>`${e} is not true or false (true, false, yes, no, 1 or 0)`,notDate:(e,t)=>`${e} is not a date (2026-04-03 or ${t?`day/month/year`:`month/day/year`})`,hasTime:e=>`${e} has a time of day; the field holds a date`,severalValues:(e,t)=>`${e} matches more than one value: ${t}`,notOneOf:(e,t)=>`${e} is not one of ${t}`,notText:e=>`${e} is true or false, not text`,emptyRequired:`is empty, and it is required`,noneHas:(e,t)=>`no ${e.toLowerCase()} has ${t}`,severalHave:(e,t,n)=>`${e} ${t.toLowerCase()} have ${n}`,notOneRecord:e=>`Not one record: ${e}`,nothingToUpdate:e=>`Nothing to update: ${e}`,fileNotUtf8:`The file is not UTF-8 text. Save it as "CSV UTF-8" and choose it again.`,noSheets:`The workbook has no sheets`,missingSheetPart:`The workbook names a sheet it does not hold`,notZip:`The file is not an Excel workbook (.xlsx): it is no ZIP archive`,zip64:`The workbook is too large to read: it is a ZIP64 archive`,compression:(e,t)=>`The workbook's part ${e} is compressed in a way that cannot be read (method ${t})`,notWorkbook:e=>`The file is not an Excel workbook (.xlsx): it has no ${e}`,noSheetCalled:e=>`The workbook has no sheet called ${e}`,unreadable:`The file could not be read`,column:e=>`Column ${e}`},nl:{import:`Importeren`,importPlural:e=>`${e} importeren`,couldNotReadFile:`Kon het bestand niet lezen`,couldNotCheck:`Kon de rijen niet controleren`,cancel:`Annuleren`,next:`Volgende`,checkRows:`Rijen controleren`,back:`Terug`,checking:`Controleren`,importRows:(e,t)=>`${e} ${t===1?`rij`:`rijen`} importeren`,cancelImport:`Import annuleren`,done:`Klaar`,file:`Bestand`,fileHint:`Een Excel-werkmap (.xlsx) of een CSV-bestand bewaard als UTF-8. De eerste rij noemt de kolommen.`,reading:e=>`${e} lezen…`,theFile:`het bestand`,sheet:`Werkblad`,create:`Maken`,update:`Bijwerken`,upsert:`Maken of bijwerken`,createHint:`Elke rij maakt een record.`,updateHint:`Elke rij werkt het record bij dat haar waarde vindt; een rij die er geen vindt, wordt niet geïmporteerd.`,upsertHint:`Elke rij werkt het record bij dat haar waarde vindt, of maakt er een als ze er geen vindt.`,doNotImport:`Niet importeren`,rows:`Rijen`,whatEachRowDoes:`Wat elke rij doet`,findBy:`Records vinden op`,chooseField:`Kies een veld`,findByHint:`Een veld dat geen twee records delen, zoals de sleutel of een e-mailadres.`,foundInColumn:`Gevonden in kolom`,chooseColumn:`Kies een kolom`,numbers:`Getallen`,dates:`Datums`,dayFirst:`Dag eerst (31/12/2026)`,monthFirst:`Maand eerst (12/31/2026)`,datesHint:`Datums geschreven als 2026-12-31 lezen hoe dan ook hetzelfde. Tijden zonder zone zijn in je eigen tijd.`,requiredMarked:`Nieuwe records hebben de velden met * nodig.`,columns:`Kolommen`,emptyInFirstRows:`Leeg in de eerste rijen`,field:`Veld`,fieldFor:e=>`Veld voor ${e}`,foundBy:`Gevonden op`,pluralFoundBy:e=>`${e} gevonden op`,noColumnFills:e=>`Geen kolom vult ${e}, wat nieuwe records nodig hebben.`,rowsNotImported:`Niet geïmporteerde rijen`,rowProblems:e=>`Rij ${e}:`,andMore:e=>`En nog ${e} rijen, allemaal in het bestand.`,checkingRows:e=>`Rijen controleren… ${e} gelezen`,check:`Controle`,toCreate:`Te maken`,toUpdate:`Bij te werken`,withProblems:`Met problemen`,firstRows:`Eerste rijen`,row:`Rij`,problemRows:`Rijen met problemen, die worden overgeslagen`,download:`Downloaden`,batches:e=>`Rijen worden bewaard in groepen van ${e}. Annuleren, of een fout, houdt de groepen die al bewaard zijn; een rij die de server weigert, wordt vermeld en de andere worden bewaard.`,stopping:`Stoppen na deze groep…`,saving:`Rijen bewaren…`,rowsSaved:`Bewaarde rijen`,stopped:`De import is gestopt. De rijen die hieronder zijn geteld, zijn bewaard.`,cancelled:`Geannuleerd. De rijen die hieronder zijn geteld, zijn bewaard.`,summary:`Samenvatting van de import`,created:`Gemaakt`,updated:`Bijgewerkt`,skipped:`Overgeslagen`,failed:`Mislukt`,notWrittenHint:`Overgeslagen rijen hadden problemen in het bestand; de mislukte weigerde de server. Het bestand bevat elke rij met de reden, om te verbeteren en opnieuw te importeren.`,notImportedFile:e=>`${e} - niet geïmporteerd.csv`,line:`Regel`,problems:`Problemen`,notNumber:e=>`${e} is geen getal`,notWholeNumber:e=>`${e} is geen geheel getal`,tooLarge:e=>`${e} is te groot`,notBoolean:e=>`${e} is niet waar of onwaar (true, false, yes, no, 1 of 0)`,notDate:(e,t)=>`${e} is geen datum (2026-04-03 of ${t?`dag/maand/jaar`:`maand/dag/jaar`})`,hasTime:e=>`${e} heeft een tijd van de dag; het veld bevat een datum`,severalValues:(e,t)=>`${e} past bij meer dan één waarde: ${t}`,notOneOf:(e,t)=>`${e} is niet een van ${t}`,notText:e=>`${e} is waar of onwaar, geen tekst`,emptyRequired:`is leeg, en is verplicht`,noneHas:(e,t)=>`geen ${e.toLowerCase()} heeft ${t}`,severalHave:(e,t,n)=>`${e} ${t.toLowerCase()} hebben ${n}`,notOneRecord:e=>`Niet één record: ${e}`,nothingToUpdate:e=>`Niets om bij te werken: ${e}`,fileNotUtf8:`Het bestand is geen UTF-8-tekst. Bewaar het als "CSV UTF-8" en kies het opnieuw.`,noSheets:`De werkmap heeft geen werkbladen`,missingSheetPart:`De werkmap noemt een werkblad dat er niet in zit`,notZip:`Het bestand is geen Excel-werkmap (.xlsx): het is geen ZIP-archief`,zip64:`De werkmap is te groot om te lezen: het is een ZIP64-archief`,compression:(e,t)=>`Het deel ${e} van de werkmap is gecomprimeerd op een manier die niet kan worden gelezen (methode ${t})`,notWorkbook:e=>`Het bestand is geen Excel-werkmap (.xlsx): het heeft geen ${e}`,noSheetCalled:e=>`De werkmap heeft geen werkblad met de naam ${e}`,unreadable:`Het bestand kon niet worden gelezen`,column:e=>`Kolom ${e}`}}),G5=e=>typeof e==`object`&&!!e,K5=e=>e===null||typeof e==`string`&&e.trim()===``,q5=e=>e===null?``:G5(e)?e.date.replace(`T`,` `):typeof e==`boolean`?e?`TRUE`:`FALSE`:String(e),J5=e=>e<26?String.fromCharCode(65+e):J5(Math.floor(e/26)-1)+J5(e%26),Y5=(e,t)=>e[t]?.trim()?e[t]:$(`column`,J5(t)),XSe=e=>/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,ZSe=(e,t)=>{let n=[...t].sort((e,t)=>e.line-t.line).map(t=>[...e.map((e,n)=>q5(t.cells[n]??null)),String(t.line),t.problems.join(`; `)]);return`${[[...e,$(`line`),$(`problems`)],...n].map(e=>e.map(XSe).join(`,`)).join(`\r
|
|
68
68
|
`)}\r\n`},X5=({label:e,counts:t})=>(0,z.jsx)(`dl`,{"aria-label":e,className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:t.map(([e,t])=>(0,z.jsxs)(`div`,{className:`rounded-lg border px-3 py-2`,children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,z.jsx)(`dd`,{className:`text-lg font-semibold tabular-nums`,children:t.toLocaleString(l())})]},e))}),Z5=(e,t)=>e?.fields[t]?.label??q(t),QSe=new Set([`text`,`integer`,`bigint`,`decimal`,`boolean`,`date`,`timestamp`,`uuid`,`enum`,`relation`,`currency`,`country`]),Q5=(e,t)=>{let n=e.relation?t[e.relation.resource]:void 0;return n?.primaryKey.length===1?n:void 0},$Se=(e,t)=>Object.values(e.fields).filter(n=>n.readOnly||n.name===e.tenant||!QSe.has(n.type)?!1:n.type!==`relation`||Q5(n,t)!==void 0),eCe=new Set([`text`,`integer`,`bigint`,`uuid`,`date`,`currency`,`country`,`enum`]),$5=e=>{let t=e.primaryKey.length===1?[e.fields[e.primaryKey[0]]]:[],n=Object.values(e.fields).filter(t=>t.filterable&&!t.sensitive&&eCe.has(t.type)&&!e.primaryKey.includes(t.name));return[...t,...n]},e7=(e,t)=>Q5(e,t),t7=e=>!e.nullable&&!e.default,n7=e=>e.toLowerCase().replace(/[\s_-]+/g,``),r7=(e,t,n)=>{let r=new Set;return e.flatMap((e,i)=>{let a=n7(e);if(a===``)return[];let o=t.find(e=>!r.has(e.name)&&(n7(Z5(n,e.name))===a||n7(e.name)===a));return o?(r.add(o.name),[{column:i,field:o.name}]):[]})},i7=(e,t,n)=>{if(e===`update`)return[];let r=new Set(n.map(e=>e.field));return t.filter(e=>t7(e)&&!r.has(e.name))},a7=e=>({ok:!0,value:e}),o7=e=>({ok:!1,problem:e}),s7=e=>`“${q5(e)}”`,c7=(e,t)=>{if(typeof e==`number`)return String(e);if(typeof e==`string`)return RS(e,t.decimal)},tCe=(e,t,n)=>{let r=c7(t,n);if(r===void 0)return o7($(`notNumber`,s7(t)));let[i,a=``]=r.split(`.`);if(/[1-9]/.test(a)||/e/i.test(r))return o7($(`notWholeNumber`,s7(t)));if(e.type===`bigint`)return a7(String(BigInt(i)));let o=Number(i);return Number.isSafeInteger(o)?a7(o):o7($(`tooLarge`,s7(t)))},nCe=(e,t)=>{let n=c7(e,t);return n===void 0?o7($(`notNumber`,s7(e))):a7(n)},rCe=new Set([`true`,`yes`,`1`]),iCe=new Set([`false`,`no`,`0`]),aCe=e=>{if(typeof e==`boolean`)return a7(e);let t=typeof e==`string`||typeof e==`number`?String(e).trim().toLowerCase():``;return rCe.has(t)?a7(!0):iCe.has(t)?a7(!1):o7($(`notBoolean`,s7(e)))},l7=e=>String(e).padStart(2,`0`),oCe=(e,t,n)=>{let r=new Date(Date.UTC(e,t-1,n));if(r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n)return`${e}-${l7(t)}-${l7(n)}`},u7=`(\\d{1,2}):(\\d{2})(?::(\\d{2})(?:\\.\\d+)?)?`,sCe=(e,t)=>{let n=RegExp(`^(\\d{4})[-/](\\d{1,2})[-/](\\d{1,2})(?:[T ]${u7}(Z|[+-]\\d{2}:?\\d{2})?)?$`).exec(e.trim()),r=RegExp(`^(\\d{1,2})[./-](\\d{1,2})[./-](\\d{4})(?: ${u7})?$`).exec(e.trim());if(!n&&!r)return;let[i,a,o]=n?[n[1],n[2],n[3]].map(Number):t===`dmy`?[r[3],r[2],r[1]].map(Number):[r[3],r[1],r[2]].map(Number),s=oCe(i,a,o);if(!s)return;let[c,l,u=`0`]=n?n.slice(4,7):r.slice(4,7);if(c===void 0)return{date:s};if(!(Number(c)>23||Number(l)>59||Number(u)>59))return{date:s,time:`${l7(Number(c))}:${l}:${l7(Number(u))}`,zone:n?.[7]}},d7=(e,t)=>{if(G5(e)){let[t,n]=e.date.split(`T`);return{date:t,time:n}}return typeof e==`string`?sCe(e,t.dateOrder):void 0},f7=(e,t)=>o7($(`notDate`,s7(e),t.dateOrder===`dmy`)),cCe=(e,t)=>{let n=d7(e,t);return n?n.time&&n.time!==`00:00:00`?o7($(`hasTime`,s7(e))):a7(n.date):f7(e,t)},lCe=(e,t)=>{let n=d7(e,t);if(!n)return f7(e,t);if(n.zone)return a7(new Date(`${n.date}T${n.time}${n.zone===`Z`?`Z`:n.zone.replace(/^([+-]\d{2})(\d{2})$/,`$1:$2`)}`).toISOString());let[r,i,a]=n.date.split(`-`).map(Number),[o,s,c]=(n.time??`00:00:00`).split(`:`).map(Number);return a7(new Date(r,i-1,a,o,s,c).toISOString())},p7=e=>e.trim().toLowerCase().replace(/\s+/g,` `),uCe=(e,t,n)=>{let r=e.enumValues??[],i=p7(q5(n)),a=r.filter(e=>p7(e)===i||p7(ps(e,t?.valueLabels))===i);return a.length===1?a7(a[0]):a.length>1?o7($(`severalValues`,s7(n),a.map(e=>ps(e,t?.valueLabels)).join(`, `))):o7($(`notOneOf`,s7(n),r.map(e=>ps(e,t?.valueLabels)).join(`, `)))},dCe=e=>typeof e==`boolean`?o7($(`notText`,s7(e))):a7(q5(e)),m7=(e,t,n,r)=>{if(K5(n))return e.nullable?a7(null):o7($(`emptyRequired`));switch(e.type){case`integer`:case`bigint`:return tCe(e,n,r);case`decimal`:return nCe(n,r);case`boolean`:return aCe(n);case`date`:return cCe(n,r);case`timestamp`:return lCe(n,r);case`enum`:return uCe(e,t,n);case`text`:case`uuid`:case`currency`:case`country`:return dCe(n);default:throw Error(`Not implemented: importing ${e.type} fields, which importableFields leaves out`)}},fCe=(e,t)=>e[t]?.names?.singular??q(t),pCe=(e,t)=>e[t]?.names?.plural??q(t),mCe=(e,t,n)=>{let{model:r,resources:i,views:a}=n,o=a[r.name],s={},c={},l=[],u=[];for(let{column:n,field:d,matchBy:f}of t.columns){let p=r.fields[d],m=e.cells[n]??null,h=Z5(o,d),g=e7(p,i);if(g&&!K5(m)){let e=f??g.primaryKey[0],n=m7(g.fields[e],a[g.name]?.fields[e],m,t.options);n.ok?u.push({field:d,finding:{model:g,field:e,value:n.value}}):l.push(`${h}: ${n.problem}`),s[d]=q5(m);continue}let _=m7(p,o?.fields[d],m,t.options);_.ok?c[d]=s[d]=_.value:l.push(`${h}: ${_.problem}`)}let d;if(t.match&&t.mode!==`create`){let n=r.fields[t.match.field],i=m7({...n,nullable:!1},o?.fields[n.name],e.cells[t.match.column]??null,t.options);i.ok?d={model:r,field:n.name,value:i.value}:l.push(`${Z5(o,n.name)}: ${i.problem}`)}return{values:s,data:c,problems:l,relations:u,match:d}},h7=(e,t)=>{let n=e.lookups.keysOf(t.model.name,t.field,t.value),r=`${Z5(e.views[t.model.name],t.field).toLowerCase()} “${String(t.value)}”`;return n.length===1?{key:n[0]}:n.length===0?{none:$(`noneHas`,fCe(e.views,t.model.name),r)}:{several:$(`severalHave`,n.length,pCe(e.views,t.model.name),r)}},hCe=e=>e.cells.every(K5),g7=async(e,t,n)=>{let{model:r,views:i}=n,a=e.filter(e=>!hCe(e)).map(e=>({row:e,...mCe(e,t,n)})),o=new Map;for(let e of a.flatMap(e=>[...e.relations.map(e=>e.finding),...e.match?[e.match]:[]])){let t=`${e.model.name}.${e.field}`;o.has(t)||o.set(t,{model:e.model,field:e.field,values:[]}),o.get(t).values.push(e.value)}for(let{model:e,field:t,values:r}of o.values())await n.lookups.load(e,t,r);return a.map(({row:e,values:a,data:o,problems:s,relations:c,match:l})=>{let u={...o};for(let{field:e,finding:t}of c){let a=h7(n,t);`key`in a?u[e]=a.key:s.push(`${Z5(i[r.name],e)}: ${a.none??a.several}`)}let d=l&&h7(n,l);d?.several&&s.push($(`notOneRecord`,d.several)),d?.none&&t.mode===`update`&&s.push($(`nothingToUpdate`,d.none));let f={line:e.line,cells:e.cells,values:a,problems:s};return s.length>0?f:d&&`key`in d?{...f,op:{op:`update`,resource:r.name,key:d.key,etag:`*`,data:u}}:{...f,op:{op:`create`,resource:r.name,data:u}}})},gCe=5,_Ce=5,vCe=async(e,t)=>{let n=e.rows(t),{value:r=[]}=await n.next();await n.return(void 0);let[i,...a]=r;return{headers:(i?.cells??[]).map(q5),sample:a.slice(0,gCe)}};async function*_7(e,t){let n=!0;for await(let r of e.rows(t))yield n?r.slice(1):r,n=!1}var yCe=async(e,t,n,r,i,a)=>{let o={rows:0,creates:0,updates:0,problems:[],preview:[]};for await(let s of _7(e,t)){a?.throwIfAborted();for(let e of await g7(s,n,r))o.rows++,o.preview.length<_Ce&&o.preview.push(e),e.op?.op===`create`?o.creates++:e.op?.op===`update`?o.updates++:o.problems.push({line:e.line,cells:e.cells,problems:e.problems});i(o.rows)}return o},bCe=(e,t)=>{if(!Xs(e))return[e.message];let n=e.errors.filter(e=>e.field);return n.length===0?[e.message]:n.map(e=>`${Z5(t.views[t.model.name],e.field)}: ${e.message}`)},xCe=async(e,t,n,r,{client:i,onProgress:a,cancelled:o})=>{let s={created:0,updated:0,skipped:0,failed:0,notWritten:[]},c=async e=>{let t=[...e];for(;t.length>0;){let e=t.map(e=>e.op);try{let{results:t}=await i.batchWrite(e);for(let e of t)e.op===`create`?s.created++:e.op===`update`&&s.updated++;return}catch(e){let n=Xs(e)?e.operation:void 0;if(n===void 0||!t[n])throw e;let[i]=t.splice(n,1);s.failed++,s.notWritten.push({line:i.line,cells:i.cells,problems:bCe(e,r)})}}},l=[],u=async e=>{for(;l.length>=100||e&&l.length>0;){if(o())return!1;await c(l.splice(0,100)),a({...s})}return!0};for await(let i of _7(e,t)){for(let e of await g7(i,n,r))e.op?l.push(e):(s.skipped++,s.notWritten.push({line:e.line,cells:e.cells,problems:e.problems}));if(!await u(!1))return{...s,cancelled:!0}}return await u(!0)?{...s,cancelled:!1}:{...s,cancelled:!0}},v7=50,y7=(e,t,n)=>Ep(ZSe(t,n),$(`notImportedFile`,(e??`import`).replace(/\.[^.]+$/,``)),`text/csv`),b7=({rows:e})=>(0,z.jsxs)(`ul`,{"aria-label":$(`rowsNotImported`),className:`flex flex-col gap-1 text-body`,children:[e.slice(0,v7).map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`font-medium`,children:$(`rowProblems`,e.line)}),` `,e.problems.join(`; `)]},e.line)),e.length>v7&&(0,z.jsx)(`li`,{className:`text-muted-foreground`,children:$(`andMore`,(e.length-v7).toLocaleString(l()))})]}),SCe=({rows:e})=>(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,z.jsx)(qd,{className:`size-3.5`}),$(`checkingRows`,e.toLocaleString(l()))]}),CCe=({check:e,model:t,resources:n,views:r,columns:i,headers:a,fileName:o})=>{let s=r[t.name],c=i.map(e=>t.fields[e.field]);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsx)(X5,{label:$(`check`),counts:[[$(`rows`),e.rows],[$(`toCreate`),e.creates],[$(`toUpdate`),e.updates],[$(`withProblems`),e.problems.length]]}),e.preview.length>0&&(0,z.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,z.jsxs)(`table`,{"aria-label":$(`firstRows`),className:`w-full text-left text-body`,children:[(0,z.jsx)(`thead`,{className:`bg-muted text-muted-foreground`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{className:`px-2 py-1.5 font-medium`,children:$(`row`)}),c.map(e=>(0,z.jsx)(`th`,{className:`whitespace-nowrap px-2 py-1.5 font-medium`,children:Z5(s,e.name)},e.name))]})}),(0,z.jsx)(`tbody`,{className:`divide-y`,children:e.preview.map(e=>(0,z.jsxs)(`tr`,{className:e.problems.length>0?`bg-danger-soft`:void 0,children:[(0,z.jsx)(`td`,{className:`px-2 py-1.5 tabular-nums text-muted-foreground`,children:e.line}),c.map(t=>(0,z.jsx)(`td`,{className:`max-w-48 truncate px-2 py-1.5`,children:e7(t,n)?String(e.values[t.name]??`—`):t.name in e.values?rS(t,e.values[t.name],s?.fields[t.name]):``},t.name))]},e.line))})]})}),e.problems.length>0&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:$(`problemRows`)}),(0,z.jsxs)(V,{size:`sm`,onClick:()=>y7(o,a,e.problems),children:[(0,z.jsx)(Ui,{className:`size-3.5`}),$(`download`)]})]}),(0,z.jsx)(b7,{rows:e.problems})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:$(`batches`,100)})]})},x7=({label:e,name:t,value:n,options:r,onChange:i,help:a,className:o})=>{let s=(0,L.useId)();return(0,z.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1.5`,o),children:[(0,z.jsx)(`label`,{htmlFor:s,className:`font-medium`,children:e}),(0,z.jsx)(`select`,{id:s,"aria-label":t,value:n,onChange:e=>i(e.target.value),className:`h-8 w-full min-w-0 rounded-md border border-border-strong bg-background px-2 shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 max-sm:min-h-11`,children:r.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),a&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a})]})},wCe=({file:e,sheets:t,sheet:n,reading:r,onChoose:i,onSheet:a})=>{let o=(0,L.useId)();return(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`label`,{htmlFor:o,className:`font-medium`,children:$(`file`)}),(0,z.jsx)(`input`,{id:o,type:`file`,accept:`.xlsx,.csv,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,disabled:r,onChange:e=>{let t=e.target.files?.[0];t&&i(t)},className:`file:mr-3 file:h-8 file:rounded-md file:border file:border-border-strong file:bg-background file:px-3 file:font-medium file:text-foreground max-sm:file:min-h-11`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:$(`fileHint`)})]}),r&&(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,z.jsx)(qd,{className:`size-3.5`}),$(`reading`,e?.name??$(`theFile`))]}),!r&&t.length>1&&(0,z.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,z.jsx)(ete,{className:`mb-2 size-4 shrink-0 text-muted-foreground`}),(0,z.jsx)(x7,{className:`flex-1`,label:$(`sheet`),value:n??``,options:t.map(e=>({value:e,label:e})),onChange:a})]})]})},TCe=()=>[{value:`create`,label:$(`create`)},{value:`update`,label:$(`update`)},{value:`upsert`,label:$(`upsert`)}],ECe={create:`createHint`,update:`updateHint`,upsert:`upsertHint`},S7=``,DCe=({flow:e,model:t,resources:n,views:r,canUpdate:i})=>{let a=r[t.name],o=e.head?.headers??[],s=e.head?.sample??[],c=i7(e.mode,e.fields,e.columns),l=[{value:S7,label:$(`doNotImport`)},...e.fields.map(e=>({value:e.name,label:`${Z5(a,e.name)}${t7(e)?` *`:``}`}))],u=o.map((e,t)=>({value:String(t),label:Y5(o,t)})),d=$5(t);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[i&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:$(`rows`)}),(0,z.jsx)(`div`,{children:(0,z.jsx)(f,{label:$(`whatEachRowDoes`),size:`md`,value:e.mode,options:TCe(),onChange:e.setMode})}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:$(ECe[e.mode])})]}),e.mode!==`create`&&(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(x7,{label:$(`findBy`),value:e.match?.field??S7,options:[{value:S7,label:$(`chooseField`)},...d.map(e=>({value:e.name,label:Z5(a,e.name)}))],onChange:t=>e.setMatch(t?{field:t,column:e.match?.column??0}:void 0),help:$(`findByHint`)}),(0,z.jsx)(x7,{label:$(`foundInColumn`),value:e.match?String(e.match.column):S7,options:[{value:S7,label:$(`chooseColumn`)},...u],onChange:t=>e.setMatch(t&&e.match?{...e.match,column:Number(t)}:e.match)})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(x7,{label:$(`numbers`),value:e.options.decimal,options:[{value:`.`,label:`1,234.56`},{value:`,`,label:`1.234,56`}],onChange:t=>e.setOptions({...e.options,decimal:t})}),(0,z.jsx)(x7,{label:$(`dates`),value:e.options.dateOrder,options:[{value:`dmy`,label:$(`dayFirst`)},{value:`mdy`,label:$(`monthFirst`)}],onChange:t=>e.setOptions({...e.options,dateOrder:t}),help:$(`datesHint`)})]}),e.mode!==`update`&&(0,z.jsx)(`p`,{className:`-mb-3 text-xs text-muted-foreground`,children:$(`requiredMarked`)}),(0,z.jsx)(`section`,{"aria-label":$(`columns`),className:`flex flex-col divide-y divide-border border-y`,children:o.map((i,c)=>{let u=e.columns.find(e=>e.column===c),d=u?t.fields[u.field]:void 0,f=d?e7(d,n):void 0,p=s.map(e=>q5(e.cells[c]??null)).filter(e=>e!==``).slice(0,3),m=Y5(o,c);return(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 py-3 sm:grid-cols-2 sm:gap-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`truncate font-medium`,children:m}),(0,z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:p.length>0?p.join(`, `):$(`emptyInFirstRows`)})]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,z.jsx)(x7,{label:$(`field`),name:$(`fieldFor`,m),value:u?.field??S7,options:l,onChange:t=>e.mapColumn(c,t||void 0)}),f&&(0,z.jsx)(x7,{label:$(`foundBy`),name:$(`pluralFoundBy`,r[f.name]?.names?.plural??Z5(a,d.name)),value:u.matchBy??f.primaryKey[0],options:$5(f).map(e=>({value:e.name,label:Z5(r[f.name],e.name)})),onChange:t=>e.matchColumnBy(c,t)})]})]},c)})}),c.length>0&&(0,z.jsxs)(`p`,{role:`alert`,className:`flex gap-2 rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-warning-text`,children:[(0,z.jsx)(Jo,{className:`mt-0.5 size-4 shrink-0`}),(0,z.jsx)(`span`,{children:$(`noColumnFills`,c.map(e=>Z5(a,e.name)).join(`, `))})]})]})},C7=e=>e.toLocaleString(l()),OCe=({progress:e,total:t,cancelling:n})=>{let r=e.created+e.updated+e.failed;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:$(n?`stopping`:`saving`)}),(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[C7(r),` / `,C7(t)]})]}),(0,z.jsx)(`div`,{role:`progressbar`,"aria-label":$(`rowsSaved`),"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":t,className:`h-2 overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${t>0?Math.min(100,r/t*100):0}%`}})})]})},kCe=({result:e,stopped:t,headers:n,fileName:r})=>(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t!==void 0&&(0,z.jsx)(rC,{title:$(`stopped`),error:t}),e.cancelled&&(0,z.jsx)(`p`,{role:`status`,children:$(`cancelled`)}),(0,z.jsx)(X5,{label:$(`summary`),counts:[[$(`created`),e.created],[$(`updated`),e.updated],[$(`skipped`),e.skipped],[$(`failed`),e.failed]]}),e.notWritten.length>0&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:$(`rowsNotImported`)}),(0,z.jsxs)(V,{size:`sm`,onClick:()=>y7(r,n,e.notWritten),children:[(0,z.jsx)(Ui,{className:`size-3.5`}),$(`download`)]})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:$(`notWrittenHint`)}),(0,z.jsx)(b7,{rows:[...e.notWritten].sort((e,t)=>e.line-t.line)})]})]}),ACe=e=>{let t=IS(e),n=new Intl.DateTimeFormat(e).formatToParts(new Date(2026,3,3)).map(e=>e.type);return{decimal:t,dateOrder:n.indexOf(`month`)<n.indexOf(`day`)?`mdy`:`dmy`}},jCe=Vn(),w7=100,T7=e=>String(e),MCe=e=>{let t=new Map,n=(e,n)=>{let r=`${e}.${n}`;return t.has(r)||t.set(r,new Map),t.get(r)};return{load:async(t,r,i)=>{let a=n(t.name,r),o=[...new Map(i.filter(e=>!a.has(T7(e))).map(e=>[T7(e),e])).values()],s=t.primaryKey[0];for(let n=0;n<o.length;n+=w7){let i=o.slice(n,n+w7);for(let e of i)a.set(T7(e),[]);let c=Fn(jCe.in(r,i)),l;do{let n=await e(t.name).list(t.name,{filter:c,fields:[...new Set([s,r])],pageSize:1e3,pageToken:l});for(let e of n.items)a.get(T7(e[r]))?.push(e[s]);l=n.nextPageToken||void 0}while(l)}},keysOf:(e,t,r)=>n(e,t).get(T7(r))??[]}},NCe=500,E7=()=>{let e=new Worker(new URL(`/assets/parse-worker-UhbwEjS0.js`,``+import.meta.url),{type:`module`}),t=[],n;return e.onmessage=e=>{if(n){let t=n;n=void 0,t(e.data)}else t.push(e.data)},e.onerror=e=>{e.preventDefault();let r={type:`error`,message:$(`unreadable`)};n?n(r):t.push(r)},{send:t=>e.postMessage(t),receive:()=>t.length>0?Promise.resolve(t.shift()):new Promise(e=>n=e),stop:()=>e.terminate()}},PCe=e=>({sheets:async()=>{let t=E7();try{t.send({type:`sheets`,file:e,locale:p()});let n=await t.receive();if(n.type===`error`)throw Error(n.message);if(n.type!==`sheets`)throw Error(`The parse worker answered ${n.type} to a request for sheets`);return n.sheets}finally{t.stop()}},rows:async function*(t){let n=E7();try{for(n.send({type:`read`,file:e,sheet:t,chunk:NCe,locale:p()});;){let e=await n.receive();if(e.type===`error`)throw Error(e.message);if(e.type===`end`)return;if(e.type!==`rows`)throw Error(`The parse worker answered ${e.type} to a read`);yield e.rows,n.send({type:`next`})}}finally{n.stop()}}}),D7={created:0,updated:0,skipped:0,failed:0,notWritten:[]},FCe=({model:e,resources:t,views:n,sourceFor:r=PCe})=>{let i=Sre(),a=Km(),o=n[e.name],s=(0,L.useMemo)(()=>$Se(e,t),[e,t]),[c,l]=(0,L.useState)({kind:`file`,reading:!1}),[u,d]=(0,L.useState)(),[f,p]=(0,L.useState)(),[m,h]=(0,L.useState)(),[g,_]=(0,L.useState)(),[v,y]=(0,L.useState)(`create`),[b,x]=(0,L.useState)([]),[S,C]=(0,L.useState)(),[w,T]=(0,L.useState)(()=>ACe()),E=(0,L.useRef)(!1),D=(0,L.useRef)(void 0),O=e=>t=>{d(t),l(e)},k=e=>{d(void 0),l({kind:`file`,reading:!0});let t=r(e);t.sheets().then(n=>{if(p({file:e,source:t,sheets:n}),h(n[0]),n.length<=1)return A(t,n[0]);l({kind:`file`,reading:!1})}).catch(O({kind:`file`,reading:!1}))},A=async(t,n)=>{l({kind:`file`,reading:!0});let r=await vCe(t,n);_(r),x(r7(r.headers,s,o));let i=$5(e)[0],a=i?r7(r.headers,[i],o)[0]:void 0;C(i&&a?{field:i.name,column:a.column}:void 0),l({kind:`map`})},j=()=>{f&&(d(void 0),A(f.source,m).catch(O({kind:`file`,reading:!1})))},M=(e,t)=>x(n=>{let r=n.filter(n=>n.column!==e&&n.field!==t);return t?[...r,{column:e,field:t}].sort((e,t)=>e.column-t.column):r}),N=(e,t)=>x(n=>n.map(n=>n.column===e?{...n,matchBy:t}:n)),P=()=>({mode:v,columns:b,match:v===`create`?void 0:S,options:w}),ee=()=>({model:e,resources:t,views:n,lookups:MCe(i)});return{step:c,error:u,file:f?.file,sheets:f?.sheets??[],sheet:m,setSheet:h,head:g,fields:s,mode:v,setMode:y,columns:b,mapColumn:M,matchColumnBy:N,match:S,setMatch:C,options:w,setOptions:T,choose:k,openSheet:j,check:()=>{if(!f)return;d(void 0);let e=new AbortController;D.current=e,l({kind:`checking`,rows:0}),yCe(f.source,m,P(),ee(),e=>l({kind:`checking`,rows:e}),e.signal).then(t=>{e.signal.aborted||l({kind:`checked`,check:t})}).catch(t=>{e.signal.aborted||O({kind:`map`})(t)})},back:()=>{D.current?.abort(),d(void 0),l({kind:`map`})},start:t=>{if(!f)return;d(void 0),E.current=!1,l({kind:`importing`,progress:D7,total:t,cancelling:!1});let n=D7;xCe(f.source,m,P(),ee(),{client:i(e.name),onProgress:e=>{n=e,l({kind:`importing`,progress:e,total:t,cancelling:E.current})},cancelled:()=>E.current}).then(e=>l({kind:`done`,result:e})).catch(e=>l({kind:`done`,result:{...n,cancelled:!1},stopped:e})).finally(()=>{for(let t of[`page`,`list`,`first-page`,`map`,`facets`,`series`])a.invalidateQueries({queryKey:[t,e.name]})})},cancel:()=>{E.current=!0,l(e=>e.kind===`importing`?{...e,cancelling:!0}:e)},stop:()=>D.current?.abort()}},ICe=e=>e.step.kind===`file`?$(`couldNotReadFile`):$(`couldNotCheck`),LCe=e=>e.columns.length===0?!1:e.mode===`create`?i7(`create`,e.fields,e.columns).length===0:e.match!==void 0,RCe=({model:e,resources:t,views:n,canUpdate:r,onClose:i,sourceFor:a})=>{let o=FCe({model:e,resources:t,views:n,sourceFor:a}),s=n[e.name]?.names?.plural??q(e.name),{step:c}=o,u=o.head?.headers??[],d=()=>{c.kind!==`importing`&&(o.stop(),i())},f=(0,z.jsx)(V,{onClick:d,children:$(`cancel`)});return(0,z.jsx)(Mm,{open:!0,wide:!0,title:$(`importPlural`,s),description:o.file&&c.kind!==`file`?o.file.name:void 0,onClose:d,actions:(()=>{switch(c.kind){case`file`:return(0,z.jsxs)(z.Fragment,{children:[f,o.sheets.length>1&&(0,z.jsx)(V,{variant:`primary`,loading:c.reading,onClick:o.openSheet,children:$(`next`)})]});case`map`:return(0,z.jsxs)(z.Fragment,{children:[f,(0,z.jsx)(V,{variant:`primary`,disabled:!LCe(o),onClick:o.check,children:$(`checkRows`)})]});case`checking`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:o.back,children:$(`back`)}),(0,z.jsx)(V,{variant:`primary`,loading:!0,children:$(`checking`)})]});case`checked`:{let e=c.check.creates+c.check.updates;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:o.back,children:$(`back`)}),(0,z.jsx)(V,{variant:`primary`,disabled:e===0,onClick:()=>o.start(e),children:$(`importRows`,e.toLocaleString(l()),e)})]})}case`importing`:return(0,z.jsx)(V,{variant:`danger`,disabled:c.cancelling,onClick:o.cancel,children:$(`cancelImport`)});case`done`:return(0,z.jsx)(V,{variant:`primary`,onClick:i,children:$(`done`)})}})(),children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.error!==void 0&&(0,z.jsx)(rC,{title:ICe(o),error:o.error}),(()=>{switch(c.kind){case`file`:return(0,z.jsx)(wCe,{file:o.file,sheets:o.sheets,sheet:o.sheet,reading:c.reading,onChoose:o.choose,onSheet:o.setSheet});case`map`:return(0,z.jsx)(DCe,{flow:o,model:e,resources:t,views:n,canUpdate:r});case`checking`:return(0,z.jsx)(SCe,{rows:c.rows});case`checked`:return(0,z.jsx)(CCe,{check:c.check,model:e,resources:t,views:n,columns:o.columns,headers:u,fileName:o.file?.name});case`importing`:return(0,z.jsx)(OCe,{progress:c.progress,total:c.total,cancelling:c.cancelling});case`done`:return(0,z.jsx)(kCe,{result:c.result,stopped:c.stopped,headers:u,fileName:o.file?.name})}})()]})})},zCe=({model:e})=>{let{resources:t,views:n}=G(),r=cg(e.name),[i,a]=(0,L.useState)(!1);return n[e.name]?.import===!1||!xT(r,`create`)?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(V,{onClick:()=>a(!0),"aria-haspopup":`dialog`,children:[(0,z.jsx)(Qo,{className:`size-3.5`}),$(`import`)]}),i&&(0,z.jsx)(RCe,{model:e,resources:t,views:n,canUpdate:xT(r,`update`),onClose:()=>a(!1)})]})},O7=a({en:{excel:`Excel (.xlsx)`,csv:`CSV`,asShown:`As shown`,rawValues:`Raw values`,shownHint:`Labels, dates and numbers as the list shows them.`,rawHint:`Values as they are stored, such as keys and codes.`,counting:`Counting rows…`,moreThan:`more than 10,000 rows`,columns:`Columns`,moveUp:e=>`Move ${e} up`,moveDown:e=>`Move ${e} down`,selectedRows:(e,t)=>`${e} selected ${t===1?`row`:`rows`}`,rowsInList:`Rows in the list`,selected:e=>`Selected (${e})`,exportPlural:e=>`Export ${e.toLowerCase()}`,cancel:`Cancel`,export:`Export`,format:`Format`,rows:`Rows`,listHint:`With the list’s filters, search and sort.`,values:`Values`,exports:e=>`Exports ${e}.`,overLimit:e=>` A file holds at most ${e} rows; the rest are left out.`,exporting:e=>`Exporting ${e.toLowerCase()}`,rowsExported:`Rows exported`,doneOf:(e,t)=>`${e} of ${t} rows`,done:e=>`${e} rows`,exported:(e,t)=>`Exported ${e} ${t.toLowerCase()}`,truncated:(e,t)=>`${e}: the first ${t} rows, as many as a file holds.`,couldNotExport:e=>`Could not export ${e.toLowerCase()}`,cancelled:`The export was cancelled`,couldNotBuild:e=>`The export could not be built: ${e}`,workbook:`Excel workbook`,csvFile:`CSV file`},nl:{excel:`Excel (.xlsx)`,csv:`CSV`,asShown:`Zoals getoond`,rawValues:`Ruwe waarden`,shownHint:`Labels, datums en getallen zoals de lijst ze toont.`,rawHint:`Waarden zoals ze zijn opgeslagen, zoals sleutels en codes.`,counting:`Rijen tellen…`,moreThan:`meer dan 10.000 rijen`,columns:`Kolommen`,moveUp:e=>`${e} omhoog`,moveDown:e=>`${e} omlaag`,selectedRows:(e,t)=>`${e} geselecteerde ${t===1?`rij`:`rijen`}`,rowsInList:`Rijen in de lijst`,selected:e=>`Geselecteerd (${e})`,exportPlural:e=>`${e} exporteren`,cancel:`Annuleren`,export:`Exporteren`,format:`Formaat`,rows:`Rijen`,listHint:`Met de filters, zoekopdracht en sortering van de lijst.`,values:`Waarden`,exports:e=>`Exporteert ${e}.`,overLimit:e=>` Een bestand bevat hoogstens ${e} rijen; de rest blijft weg.`,exporting:e=>`${e} exporteren`,rowsExported:`Geëxporteerde rijen`,doneOf:(e,t)=>`${e} van ${t} rijen`,done:e=>`${e} rijen`,exported:(e,t)=>`${e} ${t.toLowerCase()} geëxporteerd`,truncated:(e,t)=>`${e}: de eerste ${t} rijen, zoveel als een bestand bevat.`,couldNotExport:e=>`Kon ${e.toLowerCase()} niet exporteren`,cancelled:`De export is geannuleerd`,couldNotBuild:e=>`De export kon niet worden gemaakt: ${e}`,workbook:`Excel-werkmap`,csvFile:`CSV-bestand`}}),BCe=()=>new DOMException(O7(`cancelled`),`AbortError`),VCe=async({client:e,resource:t,filters:n,orderBy:r,plan:i,labels:a,limit:o,port:s,sink:c,signal:l,onProgress:u})=>{let d=i.columns.map(e=>e.name),f=0;try{await c.write(await s.send({kind:`start`,plan:i,locale:p()}));for(let[i,p]of n.entries()){let m=``;do{let h=await e.search(t,{filter:p,orderBy:r,pageSize:500,pageToken:m,fields:d,labels:a});if(l.aborted)throw BCe();let g=h.items.slice(0,o-f);if(await c.write(await s.send({kind:`page`,records:g,labels:h.labels??{}})),f+=g.length,u(f),m=h.nextPageToken,f>=o)return await k7(s,c),{rows:f,truncated:g.length<h.items.length||m!==``||i+1<n.length}}while(m!==``)}return await k7(s,c),{rows:f,truncated:!1}}catch(e){throw await c.abort(),e}finally{s.close()}},k7=async(e,t)=>{await t.write(await e.send({kind:`finish`})),await t.close()},HCe=1048575,A7=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
69
69
|
`,j7=`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,M7=`http://schemas.openxmlformats.org/package/2006/relationships`;`${A7}`,`${A7}${M7}${j7}`,`${A7}${M7}${j7}${j7}`,new TextEncoder;var UCe=Vn(),N7=e=>e?.export!==!1,P7=e=>Object.values(e.fields).flatMap(e=>e.sensitive?[]:[e.name]),WCe=(e,t)=>{let n=new Set(P7(e));return eS(e,t).filter(e=>n.has(e))},F7=(e,t,n)=>Object.fromEntries(tS(e,t,[],n).map(e=>[e.id,e.header])),GCe=(e,t,n)=>{let r=F7(e,t,n);return n.flatMap(n=>{let i=e.fields[n];return i?[{name:n,header:r[n],field:i,hints:t?.fields[n]??{}}]:[]})},I7=(e,t)=>{let n=e?.export?e.export.maxRows??1/0:1/0;return Math.min(n,t===`xlsx`?HCe:1/0)},L7=e=>e.primaryKey.length===1,KCe=(e,t)=>{let[n]=e.primaryKey;if(!n||e.primaryKey.length!==1)throw Error(`Not implemented: selected rows are exported by a single-field key`);let r=[];for(let e=0;e<t.length;e+=500)r.push(Fn(UCe.in(n,t.slice(e,e+500))));return r},qCe=()=>{let e=new Worker(new URL(`/assets/export-worker-ClACk00b.js`,``+import.meta.url),{type:`module`,name:`protobase-export`}),t=[];return e.onmessage=e=>t.shift()?.resolve(e.data.bytes),e.onerror=e=>{e.preventDefault();let n=Error(O7(`couldNotBuild`,e.message));for(let e of t.splice(0))e.reject(n)},{send:n=>new Promise((r,i)=>{t.push({resolve:r,reject:i}),e.postMessage(n)}),close:()=>e.terminate()}},JCe=()=>[{value:`xlsx`,label:O7(`excel`)},{value:`csv`,label:O7(`csv`)}],YCe=()=>[{value:`shown`,label:O7(`asShown`)},{value:`raw`,label:O7(`rawValues`)}],XCe={shown:`shownHint`,raw:`rawHint`},ZCe=e=>e.kind===`counting`?O7(`counting`):e.kind===`exact`||e.rows>1e4?Ff(e.rows):O7(`moreThan`),R7=e=>{if(e.kind!==`counting`)return e.kind===`exact`?e.rows:Math.max(e.rows,10001)},z7=({label:e,help:t,children:n})=>(0,z.jsxs)(`div`,{className:`flex flex-col items-start gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-body font-medium`,children:e}),n,t&&(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]}),B7=(e,t,n)=>{let r=e.indexOf(t),i=[...e];return i.splice(r,1),i.splice(r+n,0,t),i},QCe=({fields:e,columns:t,onChange:n})=>{let r=Object.fromEntries(e.map(e=>[e.name,e.label])),i=[...t,...e.map(e=>e.name).filter(e=>!t.includes(e))];return(0,z.jsx)(`ul`,{className:`divide-y self-stretch rounded-md border`,"aria-label":O7(`columns`),children:i.map(e=>{let i=t.includes(e),a=t.indexOf(e);return(0,z.jsxs)(`li`,{className:`flex min-h-10 items-center gap-2 px-3 py-1`,children:[(0,z.jsxs)(`label`,{className:`flex min-w-0 flex-1 cursor-pointer items-center gap-2.5`,children:[(0,z.jsx)(xg,{checked:i,label:r[e],onChange:r=>n(r?[...t,e]:t.filter(t=>t!==e))}),(0,z.jsx)(`span`,{className:i?`truncate`:`truncate text-muted-foreground`,children:r[e]})]}),i&&(0,z.jsxs)(`span`,{className:`flex shrink-0 gap-1`,children:[(0,z.jsx)(V,{size:`sm`,variant:`ghost`,className:`min-h-8 px-2`,"aria-label":O7(`moveUp`,r[e]),disabled:a===0,onClick:()=>n(B7(t,e,-1)),children:(0,z.jsx)(qr,{className:`size-3.5`})}),(0,z.jsx)(V,{size:`sm`,variant:`ghost`,className:`min-h-8 px-2`,"aria-label":O7(`moveDown`,r[e]),disabled:a===t.length-1,onClick:()=>n(B7(t,e,1)),children:(0,z.jsx)(Lr,{className:`size-3.5`})})]})]},e)})})},$Ce=({plural:e,view:t,fields:n,initialColumns:r,count:i,selected:a,open:o,onExport:s,onClose:c})=>{let[l,u]=(0,L.useState)(`xlsx`),[d,p]=(0,L.useState)(a?`selected`:`list`),[m,h]=(0,L.useState)(r),[g,_]=(0,L.useState)(`shown`),v=I7(t,l),y=d===`selected`?O7(`selectedRows`,Mf(a??0),a??0):ZCe(i),b=(d===`selected`?a??0:R7(i)??0)>v,x=[{value:`list`,label:O7(`rowsInList`)},{value:`selected`,label:O7(`selected`,Mf(a??0))}];return(0,z.jsx)(Mm,{title:O7(`exportPlural`,e),open:o,onClose:c,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:c,children:O7(`cancel`)}),(0,z.jsx)(V,{variant:`primary`,disabled:m.length===0,onClick:()=>s({format:l,scope:d,columns:m,mode:g}),children:O7(`export`)})]}),children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-4 text-body`,children:[(0,z.jsx)(z7,{label:O7(`format`),children:(0,z.jsx)(f,{size:`md`,label:O7(`format`),value:l,options:JCe(),onChange:u})}),a!==void 0&&a>0&&(0,z.jsx)(z7,{label:O7(`rows`),help:d===`list`?O7(`listHint`):void 0,children:(0,z.jsx)(f,{size:`md`,label:O7(`rows`),value:d,options:x,onChange:p})}),(0,z.jsx)(z7,{label:O7(`values`),help:O7(XCe[g]),children:(0,z.jsx)(f,{size:`md`,label:O7(`values`),value:g,options:YCe(),onChange:_})}),(0,z.jsx)(z7,{label:O7(`columns`),children:(0,z.jsx)(QCe,{fields:n,columns:m,onChange:h})}),(0,z.jsxs)(`p`,{role:`status`,className:`text-muted-foreground`,children:[O7(`exports`,y),b&&O7(`overLimit`,Mf(v))]})]})})},ewe=({plural:e,done:t,total:n,onCancel:r})=>{let i=n?Math.min(1,t/n):void 0;return(0,z.jsx)(Mm,{title:O7(`exporting`,e),open:!0,onClose:r,actions:(0,z.jsx)(V,{onClick:r,children:O7(`cancel`)}),children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 text-body`,children:[(0,z.jsx)(`div`,{role:`progressbar`,"aria-label":O7(`rowsExported`),"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":t,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${(i??0)*100}%`}})}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:n?O7(`doneOf`,Mf(t),Mf(n)):O7(`done`,Mf(t))})]})})},V7={xlsx:{mime:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,extension:`.xlsx`,description:`workbook`},csv:{mime:`text/csv`,extension:`.csv`,description:`csvFile`}},twe=/[\\/:*?"<>|\u0000-\u001f]/g,nwe=(e,t,n=new Date)=>{let r=[n.getFullYear(),String(n.getMonth()+1).padStart(2,`0`),String(n.getDate()).padStart(2,`0`)].join(`-`);return`${e.replace(twe,` `).trim()} ${r}${V7[t].extension}`},rwe=8e6,iwe=(e,t)=>{let n=new Blob([],{type:V7[t].mime}),r=[],i=0,a=()=>{n=new Blob([n,...r],{type:V7[t].mime}),r=[],i=0};return{write:async e=>{e.length!==0&&(r.push(e),i+=e.length,i>=rwe&&a())},close:async()=>{a();let t=URL.createObjectURL(n),r=document.createElement(`a`);r.href=t,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(t),6e4)},abort:async()=>{r=[],n=new Blob([])}}},H7=()=>globalThis.showSaveFilePicker,awe=()=>typeof H7()==`function`,owe=async(e,t)=>{let n=H7();if(!n)throw Error(`This browser cannot save a file as it is built`);let r=V7[t],i;try{i=await n({suggestedName:e,types:[{description:O7(r.description),accept:{[r.mime]:[r.extension]}}]})}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;throw e}let a=await i.createWritable();return{write:async e=>{e.length>0&&await a.write(e)},close:()=>a.close(),abort:()=>a.abort()}},swe=(e,t)=>awe()?owe(e,t):Promise.resolve(iwe(e,t)),cwe=(e,t)=>{let n=t[e.primaryKey[0]];return typeof n==`object`&&n&&`id`in n?n.id:n},lwe=({model:e,view:t,resources:n,views:r,plural:i,filter:a,orderBy:o,createPort:s=qCe,createSink:c=swe})=>{let l=W(),u=Hb(),[d,f]=(0,L.useState)({kind:`closed`}),p=(0,L.useRef)(void 0),m=Kh({queryKey:U.exportCount(e.name,a),enabled:d.kind===`settings`,queryFn:async()=>{let t=await l.list(e.name,{filter:a||void 0,pageSize:1,count:`exact`,fields:e.primaryKey});return t.totalSize===void 0?{kind:`estimate`,rows:t.totalSizeEstimate}:{kind:`exact`,rows:t.totalSize}}}).data??{kind:`counting`},h=(t=[])=>f({kind:`settings`,selected:L7(e)?t.map(t=>cwe(e,t)):[]}),g=async(d,h)=>{let g=nwe(i,d.format),_=await c(g,d.format);if(!_)return;let v=I7(t,d.format),y=d.scope===`selected`?h.length:R7(m),b=y===void 0?void 0:Math.min(y,v),x=new AbortController;p.current=x,f({kind:`running`,done:0,total:b});try{let c=await VCe({client:l,resource:e.name,filters:d.scope===`selected`?KCe(e,h):[a],orderBy:o,plan:{format:d.format,mode:d.mode,name:i,columns:GCe(e,t,d.columns)},labels:d.mode===`shown`?Y0(n,r,e,d.columns):{},limit:v,port:s(),sink:_,signal:x.signal,onProgress:e=>x.signal.aborted||f({kind:`running`,done:e,total:b})});u.show({state:`success`,title:O7(`exported`,Mf(c.rows),i),description:c.truncated?O7(`truncated`,g,Mf(c.rows)):g})}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;if(!Xs(e))throw e;u.show({state:`error`,title:O7(`couldNotExport`,i),description:e.message})}finally{p.current=void 0,f(e=>e.kind===`running`?{kind:`closed`}:e)}},_=()=>{p.current?.abort(),f({kind:`closed`})},v=P7(e),y=F7(e,t,v);return{open:h,dialogs:d.kind===`settings`?(0,z.jsx)($Ce,{plural:i,view:t,fields:v.map(e=>({name:e,label:y[e]})),initialColumns:WCe(e,t),count:m,selected:d.selected.length>0?d.selected.length:void 0,open:!0,onExport:e=>void g(e,d.selected),onClose:()=>f({kind:`closed`})}):d.kind===`running`?(0,z.jsx)(ewe,{plural:i,done:d.done,total:d.total,onCancel:_}):null}},U7=a({en:{noList:e=>`There is no list called ${e}.`,searchPlural:e=>`Search ${e.toLowerCase()}`,search:`Search`,sort:`Sort`,filters:`Filters`,filtersCount:e=>`Filters (${e})`,newRecord:e=>`New ${e.toLowerCase()}`,export:`Export`,openRecord:e=>`Open ${e.toLowerCase()}`,delete:`Delete`,exportCount:e=>`Export ${e}`,deleteCount:e=>`Delete ${e}`,actionCount:(e,t)=>`${e} (${t})`,dragToSort:`Drag a row by its handle to move it. Every move is saved as you drop it.`,unreadableFilter:`The filter in the address could not be read`,couldNotLoadRows:`Could not load rows`,created:e=>`${e} created`,noMatchSearch:(e,t)=>`No ${e.toLowerCase()} match “${t}”.`,noMatchFilters:e=>`No ${e.toLowerCase()} match these filters.`,noMatch:e=>`No ${e.toLowerCase()} match.`,noneYet:e=>`No ${e.toLowerCase()} yet.`,clearSearch:`Clear search`,clearFilters:`Clear filters`},nl:{noList:e=>`Er is geen lijst met de naam ${e}.`,searchPlural:e=>`Zoeken in ${e.toLowerCase()}`,search:`Zoeken`,sort:`Sorteren`,filters:`Filters`,filtersCount:e=>`Filters (${e})`,newRecord:e=>`${e} toevoegen`,export:`Exporteren`,openRecord:e=>`${e} openen`,delete:`Verwijderen`,exportCount:e=>`${e} exporteren`,deleteCount:e=>`${e} verwijderen`,actionCount:(e,t)=>`${e} (${t})`,dragToSort:`Sleep een rij aan de greep om hem te verplaatsen. Elke verplaatsing wordt bewaard zodra je loslaat.`,unreadableFilter:`Het filter in het adres kon niet worden gelezen`,couldNotLoadRows:`Kon de rijen niet laden`,created:e=>`${e} aangemaakt`,noMatchSearch:(e,t)=>`Geen ${e.toLowerCase()} gevonden voor “${t}”.`,noMatchFilters:e=>`Geen ${e.toLowerCase()} gevonden met deze filters.`,noMatch:e=>`Geen ${e.toLowerCase()} gevonden.`,noneYet:e=>`Nog geen ${e.toLowerCase()}.`,clearSearch:`Zoekopdracht wissen`,clearFilters:`Filters wissen`}}),uwe=({state:e,onClearSearch:t,onClearFilters:n,create:r})=>(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-8 text-center text-muted-foreground`,children:[(0,z.jsx)(`p`,{children:e.message}),(e.clearSearch||e.clearFilters||e.create&&r)&&(0,z.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[e.clearSearch&&(0,z.jsx)(V,{onClick:t,children:U7(`clearSearch`)}),e.clearFilters&&(0,z.jsx)(V,{onClick:n,children:U7(`clearFilters`)}),e.create&&r]})]}),dwe=({plural:e,search:t,filtered:n,scoped:r,canCreate:i})=>t?{message:U7(`noMatchSearch`,e,t),clearSearch:!0,clearFilters:n,create:!1}:n?{message:U7(`noMatchFilters`,e),clearSearch:!1,clearFilters:!0,create:!1}:r?{message:U7(`noMatch`,e),clearSearch:!1,clearFilters:!1,create:!1}:{message:U7(`noneYet`,e),clearSearch:!1,clearFilters:!1,create:i},fwe=(e,t)=>{},pwe=({windowMs:e=1e3,comebacks:t=2,onHold:n=fwe}={})=>{let r,i=[],a;return(o,s)=>{if(a?.among.has(o))return a.value;if(a&&(a=void 0,i=[]),o===r||(r=o,i=i.filter(t=>s-t.at<=e),i.push({value:o,at:s,comeback:i.some(e=>e.value===o)}),i.filter(e=>e.comeback).length<t))return o;let c=new Set(i.slice(-2*t).map(e=>e.value));return a={value:Math.min(...c),among:c},n(a.value,[...c]),a.value}},mwe=e=>Math.max(1,Math.floor((e+12)/252)),hwe=(e,t)=>Math.max(0,(e-(t-1)*12)/t),gwe=(e,t,n,r)=>({start:e*n,end:Math.max(0,Math.min(r,(t+1)*n)-1)}),_we=(e,t,n)=>{let r=e/t.rowHeight;return t.columns===n.columns?r*n.rowHeight:Math.floor(Math.floor(r)*t.columns/n.columns)*n.rowHeight},vwe=(e,t)=>{let n=e/t.rowHeight;return Math.floor(n)*t.columns+n%1},ywe=(e,t)=>Math.floor(Math.floor(e)/t)+e%1,bwe=8,xwe=(e,t,n)=>{let r=e.get(t);if(r!==void 0&&r>=n)return e;let i=new Map(e);i.delete(t),i.set(t,n);for(let e of i.keys()){if(i.size<=bwe)break;i.delete(e)}return i},Swe=({source:e,label:t,initialIndex:n,onScrollIndex:r,minHeight:i,children:a})=>{let{total:o}=e,[s]=(0,L.useState)(n),[c,l]=(0,L.useState)(0),u=mwe(c),d=hwe(c,u),[f,p]=(0,L.useState)(()=>new Map),m=Math.ceil(Math.max(i(d),f.get(d)??0)),h=m+12,g={columns:u,rowHeight:h},_=(0,L.useRef)({layout:g,top:0}),v=_.current.top>0&&(_.current.layout.columns!==u||_.current.layout.rowHeight!==h),y=e=>v?_we(_.current.top,_.current.layout,g):e,b=d>0&&f.has(d),x=m3({total:Math.ceil(o/u),rowHeight:h,initialIndex:ywe(s,u),settle:y,ready:b,onScroll:e=>r(vwe(e,g))});(0,L.useLayoutEffect)(()=>{v&&x.scrollTo(x.top),_.current={layout:g,top:x.top}});let S=gwe(x.first,x.last,u,o),C=o3({total:o,rowAt:e.rowAt,loadRows:e.loadRows,revision:e.revision,latencyMs:0},S.start,S.end),[w]=(0,L.useState)(()=>pwe());(0,L.useLayoutEffect)(()=>{let e=x.ref.current;if(!e)return;let t=()=>l(w(e.clientWidth,performance.now())),n=new ResizeObserver(t);return n.observe(e),t(),()=>n.disconnect()},[w]);let T=(0,L.useRef)(d);T.current=d;let[E]=(0,L.useState)(()=>new ResizeObserver(e=>{let t=Math.max(...e.map(e=>e.borderBoxSize[0]?.blockSize??e.contentRect.height)),n=T.current;p(e=>xwe(e,n,t))}));(0,L.useLayoutEffect)(()=>()=>E.disconnect(),[E]);let D=(0,L.useCallback)(e=>{if(e)return E.observe(e),()=>E.unobserve(e)},[E]);return(0,z.jsx)(`ul`,{ref:x.ref,className:`relative min-w-0 flex-auto`,"aria-label":t,style:{height:x.geometry.contentHeight},children:x.rows.flatMap(({index:e,offset:t})=>Array.from({length:u},(n,r)=>{let i=e*u+r;if(i>=o)return[];let s=C(i),c={top:t,left:r*(d+12),width:d,minHeight:m};return s?(0,z.jsx)(`li`,{ref:D,"aria-posinset":i+1,"aria-setsize":o,className:`absolute grid grid-cols-[minmax(0,1fr)]`,style:c,children:a(s)},s.id):(0,z.jsx)(`li`,{"aria-hidden":!0,className:`absolute grid grid-cols-[minmax(0,1fr)]`,style:c,children:(0,z.jsx)(Yu,{className:`h-full rounded-lg`})},`skeleton-${i}`)}))})},Cwe=`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,wwe=e=>e*.75,Twe=44,Ewe=({model:e,view:t,display:n,list:r,empty:i})=>{let a=t?.names?.plural??q(e.name),o=n.card===void 0&&(n.image!==void 0||n.photos!==void 0);return r.isLoading?(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden ${Cwe}`,children:Array.from({length:6},(e,t)=>(0,z.jsx)(Yu,{className:`h-24`},t))}):r.error?(0,z.jsx)(rC,{title:J(`couldNotLoadRows`),error:r.error}):!r.source||r.source.total===0?i??(0,z.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:J(`noneMatch`,a.toLowerCase())}):(0,z.jsx)(Swe,{source:r.source,label:a,initialIndex:r.initialIndex,onScrollIndex:r.onScrollIndex,minHeight:e=>(o?wwe(e):0)+Twe,children:r=>(0,z.jsx)(N6,{model:e,view:t,display:n,row:CS(e,r)})})},W7=`protobase:list-places`,Dwe=50,G7=(e,t)=>`${e} ${t}`,Owe=e=>{if(typeof e!=`object`||!e)return!1;let{entry:t,url:n,place:r}=e;return typeof t==`string`&&typeof n==`string`&&typeof r==`number`&&Number.isFinite(r)&&r>=0},kwe=e=>u(()=>{let t=e.getItem(W7);if(t===null)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(Owe):[]},[]),Awe=e=>{let t=new Map(kwe(e).map(e=>[G7(e.entry,e.url),e]));return{placeOf:(e,n)=>{let r=t.get(G7(e,n));return r?r.place:[...t.values()].findLast(e=>e.url===n)?.place??0},save:(e,n,r)=>{let i=G7(e,n);t.delete(i),t.set(i,{entry:e,url:n,place:r});for(let e of[...t.keys()].slice(0,Math.max(0,t.size-Dwe)))t.delete(e)},persist:()=>u(()=>e.setItem(W7,JSON.stringify([...t.values()])),void 0)}},jwe={getItem:()=>null,setItem:()=>{}},Mwe,Nwe=()=>Mwe??=Awe(u(()=>window.sessionStorage,void 0)??jwe),Pwe=()=>{let{entry:e,path:t,params:n}=Pm(),r=`${t}?${n.toString()}`,i=Nwe();(0,L.useEffect)(()=>{let e=()=>i.persist(),t=()=>document.visibilityState===`hidden`&&i.persist();return window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t),i.persist()}},[i]);let a=(0,L.useCallback)(t=>i.save(e,r,t),[i,e,r]);return{initialIndex:i.placeOf(e,r),remember:a}},K7=e=>e.reduce((e,t)=>e+t.count,0),Fwe=e=>{let t=Math.floor(e.length/2),n=K7(e.slice(0,t)),r=K7(e.slice(e.length-t));return n===0?0:(r-n)/n*100},Iwe=({active:e,payload:t,noun:n})=>{let r=t?.[0]?.payload;return!e||!r?null:(0,z.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:$f(r.at)}),(0,z.jsxs)(`div`,{className:`font-semibold tabular-nums`,children:[Mf(r.count),` `,n]})]})},q7=a({en:{day:`Day`,week:`Week`},nl:{day:`Dag`,week:`Week`}}),J7={fontSize:11,fill:`var(--muted-foreground)`},Lwe=({title:e=`Orders created`,noun:t=`orders`,defaultGranularity:n=`day`,data:r,granularity:i,onGranularityChange:a,periodLabel:o,className:s})=>{let[c,l]=(0,L.useState)(n),u=i??c,d=a??l,p=r??Sb(u),m=ju(`(min-width: 640px)`),h=Fwe(p);return(0,z.jsxs)(`section`,{className:g(`rounded-lg border bg-background px-4 pb-2 pt-3`,s),children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,z.jsx)(`h2`,{className:`font-semibold`,children:e}),(0,z.jsx)(`span`,{className:`font-semibold tabular-nums`,children:Mf(K7(p))}),(0,z.jsxs)(`span`,{className:g(`text-xs font-medium tabular-nums`,h>=0?`text-success-text`:`text-danger-text`),children:[h>=0?`+`:`−`,Math.abs(h).toFixed(1),`%`]}),(0,z.jsx)(`span`,{className:`hidden text-xs text-muted-foreground sm:inline`,children:o??`last ${u===`day`?`30 days`:`12 weeks`}`})]}),(0,z.jsx)(f,{value:u,onChange:d,options:[{value:`day`,label:q7(`day`)},{value:`week`,label:q7(`week`)}]})]}),(0,z.jsx)(`div`,{className:`mt-2 h-24`,children:(0,z.jsx)(WM,{width:`100%`,height:`100%`,children:(0,z.jsxs)(j0,{data:p,margin:{top:4,right:0,bottom:0,left:0},barCategoryGap:u===`day`?`22%`:`30%`,children:[(0,z.jsx)(B$,{vertical:!1,stroke:`var(--border)`}),(0,z.jsx)(O1,{dataKey:`at`,padding:{left:4,right:m?4:18},tickFormatter:ep,tick:J7,axisLine:!1,tickLine:!1,interval:u===`day`?m?4:9:m?1:3,height:18}),(0,z.jsx)(N1,{width:m?36:28,tick:J7,axisLine:!1,tickLine:!1,tickCount:3}),(0,z.jsx)(rJ,{cursor:{fill:`var(--muted)`},content:(0,z.jsx)(Iwe,{noun:t}),isAnimationActive:!1}),(0,z.jsx)(b1,{dataKey:`count`,fill:`var(--primary)`,radius:[2,2,0,0],isAnimationActive:!1})]})})})]})},Rwe={"7d":`last 7 days`,"30d":`last 30 days`,"90d":`last 90 days`,"1y":`last year`,all:`all time`},zwe=({resource:e,chart:t,title:n,noun:r,filter:i})=>{let[a,o]=(0,L.useState)(t.granularity===`week`?`week`:`day`),s=a===`week`?`90d`:t.range,c=ZT(e,{field:t.field,range:s,granularity:a,filter:i,timeZone:If()}).data?.points.map(e=>({at:Date.parse(`${e.bucket}Z`),count:e.count}))??[];return(0,z.jsx)(Lwe,{title:n,noun:r,data:c,granularity:a,onGranularityChange:o,periodLabel:a===`week`?`last 12 weeks`:Rwe[s]})},Y7=(e,t,n)=>{let r=e.sum??e.average;if(r===void 0)return n;let i=t?.fields[r]?.label??q(r);return e.sum===void 0?H(`average`,i):`${i}`},Bwe=({model:e,view:t,chart:n,plural:r,filter:i})=>{let a=t?.fields[n.groupBy]?.label??q(n.groupBy);return(0,z.jsxs)(`section`,{className:`rounded-lg border bg-background px-4 pb-3 pt-3`,"aria-label":`${Y7(n,t,r)} by ${a.toLowerCase()}`,children:[(0,z.jsxs)(`h2`,{className:`mb-2 font-semibold`,children:[Y7(n,t,r),` by `,a.toLowerCase()]}),(0,z.jsx)(K0,{model:e,view:t,groupBy:n.groupBy,type:n.type,sum:n.sum,average:n.average,limit:n.limit,filter:i})]})},Vwe=({value:e,onCommit:t,placeholder:n,className:r})=>{let[i,a]=(0,L.useState)(e);return(0,L.useEffect)(()=>a(e),[e]),(0,L.useEffect)(()=>{if(i===e)return;let n=setTimeout(()=>t(i),350);return()=>clearTimeout(n)},[i,e,t]),(0,z.jsx)(Wd,{wrapperClassName:g(`min-w-0 flex-1 sm:w-72 sm:flex-initial`,r),leading:(0,z.jsx)(_o,{className:`size-4`}),placeholder:n,"aria-label":U7(`search`),value:i,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&t(i)})},X7=e=>new Set((e.userMenu?.items??[]).flatMap(e=>e.kind===`resource`?[e.resource]:e.kind===`page`?[e.page]:[])),Hwe=(e,t,n)=>(e.userMenu?.items??[]).map((r,i)=>{if(r.kind===`link`)return{id:`link-${i}`,label:r.label,icon:Zw(r.icon,Yi),href:r.href,external:!0};if(r.kind===`page`){let i=e.pages[r.page];return{id:r.page,label:r.label??i?.title??q(r.page),icon:Zw(r.icon??i?.icon,ha),href:Cs({kind:`page`,page:r.page},t),active:r.page===n}}return{id:r.resource,label:r.label??e.views[r.resource]?.names?.plural??q(r.resource),icon:Zw(r.icon,Yw(r.resource)),href:Cs({kind:`list`,resource:r.resource},t),active:r.resource===n}}),Z7=(e,t)=>t===void 0?e:`${e}/${t}`,Q7={sales:`sales`,crm:`crm`,catalog:`catalog`,inventory:`inventory`,core:`admin`,hr:`hr`},$7=(e,t=``,n={})=>{let r=new Map,i=new Map,a=X7(e);for(let n of Object.values(e.pages)){if(n.nav?.hidden||a.has(n.name))continue;let e=n.nav?.group??H(`pages`),o=r.get(e)??{label:e,items:[]};o.items.push({id:n.name,label:n.title,icon:Zw(n.icon,ha),href:Cs({kind:`page`,page:n.name},t)}),r.set(e,o),i.set(n.name,n.nav?.order??2**53-1)}for(let o of Object.values(e.resources)){let s=e.views[o.name];if(!s||a.has(o.name))continue;let c=o.table.schema??`public`,l=s.nav?.group??(Q7[c]?H(Q7[c]):q(c)),u=(e,t,n)=>{let a=r.get(e)??{label:e,items:[]};a.items.push(t),r.set(e,a),i.set(t.id,n??2**53-1)};s.nav?.hidden||u(l,{id:Z7(o.name),label:s.names?.plural??q(o.name),icon:Yw(o.name),href:Cs({kind:`list`,resource:o.name},t),...n[o.name]&&{recent:n[o.name]}},s.nav?.order);for(let e of s.lists??[])e.nav?.hidden||u(e.nav?.group??l,{id:Z7(o.name,e.name),label:e.names.plural,icon:Yw(o.name),href:Cs({kind:`list`,resource:o.name,list:e.name},t)},e.nav?.order)}for(let n of Object.values(e.signIn??{})){if(n.nav?.hidden||a.has(n.resource))continue;let e=n.nav?.group??H(`account`),o=r.get(e)??{label:e,items:[]};o.items.push({id:n.resource,label:n.names?.plural??q(n.resource),icon:Yw(n.resource),href:Cs({kind:`list`,resource:n.resource},t)}),r.set(e,o),i.set(n.resource,n.nav?.order??2**53-1)}for(let n of e.sources??[]){if(n.state!==`error`)continue;let e=r.get(n.source.label)??{label:n.source.label,items:[]};for(let r of n.source.resources)e.items.push({id:r,label:q(r),icon:Yw(r),href:Cs({kind:`list`,resource:r},t),problem:H(`cannotReach`,n.source.label)});r.set(n.source.label,e)}return[...r.values()].map(e=>({...e,items:[...e.items].sort((e,t)=>(i.get(e.id)??0)-(i.get(t.id)??0))}))},Uwe=(e,t,n,r,i)=>{let a=n?.list?.relatedColumns??[];if(a.length===0)return e;let o=new Map(e.map(e=>[e.id,e]));return eS(t,n).flatMap(e=>{let t=o.get(e);if(t)return[t];let n=a.find(t=>t.name===e),s=n&&r[n.resource];if(!n||!s)return[];let c=n.label??q(n.name);return[{id:n.name,header:c,kind:`text`,width:160,minWidth:vx(c,!1),sortable:!1,render:e=>(0,z.jsx)(D6,{column:n,records:e[n.name]??[],target:s,view:i[s.name],Card:N6})}]})},Wwe=({model:e,view:t,target:n,children:r})=>{let i=y6(e.name,t.listOf,!0),a=t.names?.plural??q(e.name),o=e=>(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[(0,z.jsx)(ef,{title:a,subtitle:t.help}),e]});if(i.error)return o((0,z.jsx)(rC,{title:b6(`couldNotLoadYour`,a.toLowerCase()),error:i.error}));if(!i.data)return o((0,z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,children:Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-24`},t))}));let s=_6(n,i.data);return s?r(s):o((0,z.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:b6(`noneYet`,a.toLowerCase())}))},e9=({title:e,chips:t,label:n,required:r,initial:i=``,busy:a,onSave:o,onClose:s})=>{let c=(0,L.useId)(),[l,u]=(0,L.useState)(i),d=`${c}-form`;return(0,z.jsx)(Mm,{open:!0,title:e,onClose:s,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:s,children:Q(`cancel`)}),(0,z.jsx)(V,{type:`submit`,form:d,variant:`primary`,loading:a,children:Q(`save`)})]}),children:(0,z.jsxs)(`form`,{id:d,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o(l.trim()===``?null:l.trim())},children:[t.length>0&&(0,z.jsx)(w3,{chips:t}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,z.jsx)(`label`,{htmlFor:c,className:`font-medium`,children:n}),!r&&(0,z.jsx)(`span`,{id:`${c}-hint`,className:`text-xs text-muted-foreground`,children:Q(`optional`)})]}),(0,z.jsx)(Wd,{id:c,value:l,required:r,pattern:r?`.*\\S.*`:void 0,"aria-describedby":r?void 0:`${c}-hint`,autoFocus:!0,autoComplete:`off`,onChange:e=>u(e.target.value)})]})]})})},t9=Vn(),Gwe={start:0,end:0},n9=(e,t)=>t9.and(t,{kind:`present`,field:e.field,span:Gwe}),r9=e=>{switch(e.kind){case`and`:case`or`:return{...e,args:e.args.map(r9)};case`not`:return i9(e.arg);case`search`:case`present`:case`isNull`:return e;default:return n9(e,e)}},i9=e=>{switch(e.kind){case`and`:return t9.or(...e.args.map(i9));case`or`:return t9.and(...e.args.map(i9));case`not`:return r9(e.arg);case`search`:case`present`:case`isNull`:return t9.not(e);default:return n9(e,t9.not(e))}},a9=e=>{let t=Xt(e);if(!t.ok)throw Error(`The filter cannot be read: ${t.errors.map(e=>e.message).join(`; `)}`);return t.ast},o9=(e,t)=>{let n=a9(e);if(!n)return null;let r=a9(t),i=t9.not(r9(n));return Fn(r?t9.and(r,i):i)},Kwe=(e,t)=>o9(t,e),s9=e=>e.key.startsWith(`extra:`)?`extra:${e.label}`:e.key,qwe=(e,t)=>{let n=new Map(e.map(e=>[s9(e),e])),r=new Map(t.map(e=>[s9(e),e])),i=e.filter(e=>!r.has(s9(e))).map(e=>({kind:`removed`,label:e.label})),a=t.flatMap(e=>{let t=n.get(s9(e));return t&&t.label!==e.label?[{kind:`changed`,label:e.label,before:t.label}]:[]}),o=t.filter(e=>!n.has(s9(e))).map(e=>({kind:`added`,label:e.label}));return[...i,...a,...o]},Jwe=(e,t,n,r)=>{let i=e-t;if(i===0)return Q(`asMany`,r);let a=Math.abs(i)===1?n:r;return i>0?Q(`more`,i,a):Q(`fewer`,-i,a)},c9=12,l9={added:{word:`added`,className:`text-success-text`},removed:{word:`removed`,className:`text-danger-text`},changed:{word:`changed`,className:`text-primary-text`}},Ywe=({changes:e})=>(0,z.jsx)(`ul`,{"aria-label":Q(`filterChanges`),className:`divide-y rounded-md border`,children:e.map(e=>(0,z.jsxs)(`li`,{className:`grid grid-cols-[72px_1fr] gap-3 px-3 py-2`,children:[(0,z.jsx)(`span`,{className:`font-medium ${l9[e.kind].className}`,children:Q(l9[e.kind].word)}),e.kind===`changed`?(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,z.jsx)(`span`,{className:`font-medium`,children:e.label})]}):(0,z.jsx)(`span`,{className:e.kind===`removed`?`text-muted-foreground line-through`:`font-medium`,children:e.label})]},`${e.kind}:${e.label}`))}),u9=(e,t)=>{let n=Kh({...PT(W(),e,t??``),enabled:t!==null});return t===null?0:n.data},Xwe=(e,t,n)=>`${e} ${e===1?t:n}`,d9=({model:e,view:t,title:n,filter:r,total:i,plural:a})=>{let o=t?.list?.displays?.find(e=>e.kind===`cards`);return(0,z.jsxs)(`section`,{"aria-label":n,className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`h3`,{className:`font-semibold`,children:[n,` `,(0,z.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,i??`…`,`)`]})]}),i!==void 0&&i>c9&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q(`firstOf`,c9,i)}),r===null||i===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:Q(`noPlural`,a)}):(0,z.jsx)(S5,{model:e,view:t,filter:r,sort:wS(e,t),limit:c9,display:o?.name??`table`,row:!0,link:!1,empty:`No ${a}.`})]})},Zwe=({model:e,view:t,title:n,before:r,after:i,saveNewLabel:a,updating:o,creating:s,onUpdate:c,onSaveNew:l,onCancel:u})=>{let d=qwe(m6(e,r),m6(e,i)),f=(0,L.useMemo)(()=>o9(r,i),[r,i]),p=(0,L.useMemo)(()=>Kwe(r,i),[r,i]),m=u9(e,f),h=u9(e,p),g=(t?.names?.singular??q(e.name)).toLowerCase(),_=(t?.names?.plural??q(e.name)).toLowerCase(),v=m!==void 0&&h!==void 0;return(0,z.jsx)(Mm,{open:!0,wide:!0,title:n,onClose:u,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:u,children:Q(`cancel`)}),(0,z.jsx)(V,{loading:s,disabled:o,onClick:l,children:a}),(0,z.jsx)(V,{variant:`primary`,loading:o,disabled:s,onClick:c,children:Q(`update`)})]}),children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d.length>0&&(0,z.jsx)(Ywe,{changes:d}),v?(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:Jwe(m,h,g,_)}),(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`: `,Q(`addedRemoved`,Xwe(m,g,_),h)]})]}):(0,z.jsx)(Yu,{className:`h-4 w-48`}),(0,z.jsx)(d9,{model:e,view:t,title:Q(`added`),filter:f,total:m,plural:_}),(0,z.jsx)(d9,{model:e,view:t,title:Q(`removed`),filter:p,total:h,plural:_})]})})},Qwe=()=>{let{address:e,set:t}=AS();return{key:e?.kind===`list`?e.savedSearch:void 0,open:e=>t({savedSearch:e})}},f9=e=>e instanceof Error?e.message:Q(`somethingWrong`),$we=(e,t)=>{let n=G(),r=W(),i=Hb(),a=RT(),{href:o,open:s}=AS(),c=Qwe(),{resource:l}=e,u=n.resources[l],d=n.views[l]?.searchesOf,f=n.permissions[l],p=u!==void 0&&d!==void 0&&f!==void 0&&xT(f,`create`)&&xT(f,`delete`),m=n.signIn?.[l]?.signIn,h=H6(l,p),g=e=>sr(Kx(u,e)),_=d&&h.data?.find(e=>e[d.filter]===t),v=_||c.key===void 0||!f||!xT(f,`update`)?void 0:h.data?.find(e=>g(e)===c.key),y=n.views[l]?.names,b=y?.plural??`saved searches`,x=d?.name===void 0?void 0:u?.fields[d.name],S=qh({mutationFn:e=>r.create(l,{[d.filter]:t,...d.name&&{[d.name]:e}}),onSuccess:e=>{c.open(g(e.record)),i.show({state:`success`,title:Q(`searchSaved`),action:{label:Q(`openPlural`,b),href:o({kind:`list`,resource:l}),onNavigate:s}})},onError:e=>i.show({state:`error`,title:Q(`couldNotSave`),description:f9(e)}),onSettled:()=>a(l)}),C=qh({mutationFn:e=>r.remove(l,g(e)),onError:e=>i.show({state:`error`,title:Q(`couldNotTakeOff`),description:f9(e)}),onSettled:()=>a(l)}),w=qh({mutationFn:e=>r.update(l,g(e),{[d.filter]:t},e.etag??`*`),onSuccess:()=>i.show({state:`success`,title:Q(`searchUpdated`)}),onError:e=>i.show({state:`error`,title:Q(`couldNotUpdate`),description:f9(e)}),onSettled:()=>a(l)}),T=S.isPending||C.isPending||w.isPending;return{mode:p?`save`:m?`sign-in`:void 0,prompt:m,saved:_!==void 0,opened:v&&{filter:String(v[d.filter]??``),name:d.name&&typeof v[d.name]==`string`&&v[d.name]!==``?String(v[d.name]):void 0},noun:(y?.singular??q(l)).toLowerCase(),naming:x&&{label:n.views[l]?.fields[x.name]?.label??q(x.name),required:!x.nullable},ready:h.data!==void 0&&!T,updating:w.isPending,creating:S.isPending,remove:()=>_&&C.mutate(_),saveNew:(e,t)=>S.mutate(e,t),update:e=>v&&w.mutate(v,e)}},eTe=({model:e,view:t,search:n,filter:r,chips:i,className:a})=>{let o=$we(n,r),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)();if(!o.mode)return null;let p=n.label??Q(`saveSearch`);if(o.mode===`sign-in`)return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(V,{className:a,"aria-haspopup":`dialog`,onClick:()=>c(!0),children:[(0,z.jsx)(li,{className:`size-3.5`,"aria-hidden":!0}),p]}),(0,z.jsx)(Wm,{as:`dialog`,prompt:o.prompt,open:s,onClose:()=>c(!1)})]});let m=e=>{u(!1),o.naming?f(e):o.saveNew(null)},h=d!==void 0&&o.naming&&(0,z.jsx)(e9,{title:d,chips:i,label:o.naming.label,required:o.naming.required,busy:o.creating,onSave:e=>o.saveNew(e,{onSuccess:()=>f(void 0)}),onClose:()=>f(void 0)}),g=o.opened;if(g){let n=Q(`saveAsNew`,o.noun);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(V,{className:a,"aria-haspopup":`dialog`,"aria-disabled":!o.ready,onClick:()=>o.ready&&u(!0),children:[(0,z.jsx)(uo,{className:`size-3.5`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`max-w-60 truncate`,children:Q(`updateName`,g.name??o.noun)})]}),(0,z.jsxs)(V,{className:a,"aria-haspopup":o.naming?`dialog`:void 0,"aria-disabled":!o.ready,onClick:()=>o.ready&&m(n),children:[(0,z.jsx)(si,{className:`size-3.5`,"aria-hidden":!0}),n]}),l&&(0,z.jsx)(Zwe,{model:e,view:t,title:g.name?Q(`updateNameQuestion`,g.name):Q(`updateNounQuestion`,o.noun),before:g.filter,after:r,saveNewLabel:n,updating:o.updating,creating:o.creating,onUpdate:()=>o.update({onSuccess:()=>u(!1)}),onSaveNew:()=>m(n),onCancel:()=>u(!1)}),h]})}let _=o.saved?ai:li;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(V,{className:a,"aria-pressed":o.saved,"aria-haspopup":!o.saved&&o.naming?`dialog`:void 0,"aria-disabled":!o.ready,onClick:()=>o.ready&&(o.saved?o.remove():m(p)),children:[(0,z.jsx)(_,{className:o.saved?`size-3.5 text-primary`:`size-3.5`,"aria-hidden":!0}),p]}),h]})},tTe=e=>e instanceof Error?e.message:Q(`somethingWrong`),nTe=({model:e,view:t,name:n,value:r,onChange:i})=>{let a=(0,L.useId)(),o=e.fields[n],s=t.fields[n],c=s?.label??q(n);if(o?.type===`boolean`)return(0,z.jsx)(iC,{checked:r===!0,onChange:i,label:c});if(o?.type!==`enum`)throw Error(`Not implemented: "${n}" is ${o?.type??`unknown`}, and a saved search's controls are enums or booleans`);return(0,z.jsxs)(`label`,{htmlFor:a,className:`flex items-center gap-2 text-muted-foreground`,children:[c,(0,z.jsx)(`select`,{id:a,value:String(r??``),onChange:e=>i(e.target.value),className:`h-8 rounded-md border border-border-strong bg-background px-2 text-foreground shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20`,children:(o.enumValues??[]).map(e=>(0,z.jsx)(`option`,{value:e,children:ps(e,s?.valueLabels)},e))})]})},rTe=(e,t,n)=>Object.entries(n).map(([n,r])=>`${t.fields[n]?.label??q(n)}: ${e.fields[n]?.type===`boolean`?Q(r===!0?`on`:`off`):ps(String(r),t.fields[n]?.valueLabels)}`).join(`, `),iTe=({model:e,view:t,recordKey:n,title:r,row:i,fields:a})=>{let o=W(),s=Hb(),c=RT(),l=qh({mutationFn:t=>o.update(e.name,n,t,i.etag??`*`),onSuccess:(n,i)=>s.show({state:`success`,title:Q(`saved`,r),description:rTe(e,t,i)}),onError:e=>s.show({state:`error`,title:Q(`couldNotChange`),description:tTe(e)}),onSettled:()=>c(e.name)});return(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:a.map(n=>(0,z.jsx)(nTe,{model:e,view:t,name:n,value:l.isPending&&n in(l.variables??{})?l.variables[n]:i[n],onChange:e=>l.mutate({[n]:e})},n))})},aTe=e=>e instanceof Error?e.message:Q(`somethingWrong`),oTe=({model:e,view:t,of:n,target:r,targetView:i,row:a,recordKey:o,canRename:s,onDelete:c})=>{let l=W(),u=Hb(),d=RT(),[f,p]=(0,L.useState)(!1),{name:m,chips:h,title:g,body:_}=U6({model:e,of:n,target:r,targetView:i,row:a,recordKey:o}),v=qh({mutationFn:t=>l.update(e.name,o,{[n.name]:t},a.etag??`*`),onSuccess:()=>p(!1),onError:e=>u.show({state:`error`,title:Q(`couldNotRename`),description:aTe(e)}),onSettled:()=>d(e.name)}),y=n.name===void 0?void 0:e.fields[n.name];return(0,z.jsxs)(`section`,{"aria-label":g,className:`flex flex-col gap-3 rounded-lg border bg-surface p-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:(0,z.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:(0,z.jsx)(jS,{to:{kind:`record`,resource:e.name,key:o},className:`hover:underline`,children:m??(0,z.jsx)(T3,{chips:h})})})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.controls&&(0,z.jsx)(iTe,{model:e,view:t,recordKey:o,title:g,row:a,fields:n.controls}),s&&y&&(0,z.jsx)(V,{variant:`ghost`,"aria-label":Q(`renameTitle`,g),"aria-haspopup":`dialog`,onClick:()=>p(!0),children:(0,z.jsx)(Za,{className:`size-3.5`,"aria-hidden":!0})}),c&&(0,z.jsx)(V,{variant:`ghost`,"aria-label":Q(`deleteTitle`,g),onClick:()=>c(g),children:(0,z.jsx)(Ko,{className:`size-3.5`,"aria-hidden":!0})})]})]}),f&&y&&(0,z.jsx)(e9,{title:Q(`renameTitle`,g),chips:h,label:t.fields[y.name]?.label??q(y.name),required:!y.nullable,initial:m,busy:v.isPending,onSave:e=>v.mutate(e),onClose:()=>p(!1)}),(0,z.jsx)(V6,{..._})]})},sTe=({model:e,view:t})=>{let{resources:n,views:r}=G(),i=t.searchesOf,a=n[i.resource],o=r[i.resource],s=H6(e.name,!0),c=cg(e.name),l=H5({model:e,view:t}),u=t.names?.plural??q(e.name),d=e=>(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[l.dialogs,(0,z.jsx)(ef,{title:u,subtitle:t.help}),e]});if(!a)return d((0,z.jsx)(sg,{title:Q(`notFound`),children:gg(Q(`noResource`),i.resource)}));if(s.error)return d((0,z.jsx)(rC,{title:Q(`couldNotLoadYour`,u.toLowerCase()),error:s.error}));if(!s.data)return d((0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:2},(e,t)=>(0,z.jsx)(Yu,{className:`h-56`},t))}));if(s.data.length===0){let e=(o?.names?.plural??q(a.name)).toLowerCase();return d((0,z.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:gg(Q(`noSavedYet`,u.toLowerCase()),(0,z.jsx)(jS,{to:{kind:`list`,resource:a.name},className:`font-medium text-primary-text hover:underline`,children:e}))}))}return d((0,z.jsx)(`div`,{className:`flex flex-col gap-4`,children:s.data.map(n=>{let r=sr(Kx(e,n)),s=xT(c,`delete`)?e=>void l.start({key:r,title:e,etag:n.etag,snapshot:n}):void 0;return(0,z.jsx)(oTe,{model:e,view:t,of:i,target:a,targetView:o,row:n,recordKey:r,canRename:xT(c,`update`),onDelete:s},r)})}))},cTe=({field:e,hints:t,resource:n,stored:r,onSave:i,close:a})=>{let[o,s]=(0,L.useState)(()=>WS(e,r)),c=(0,L.useRef)(null),l=(0,L.useRef)(!1),u=!t?.widget&&(e.type===`boolean`||e.type===`enum`);(0,L.useEffect)(()=>{c.current?.querySelector(`input, select, textarea, button, [tabindex]`)?.focus()},[]);let d=(t,n,s=o)=>{l.current||(l.current=!0,t&&GS(e,s,r)&&i(HS(e,s)),a(n))};return(0,z.jsx)(`div`,{ref:c,className:`w-full min-w-0`,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),d(!0)):e.key===`Tab`?(e.preventDefault(),d(!0,e.shiftKey?-1:1)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),d(!1))},onBlur:e=>{c.current?.contains(e.relatedTarget)||d(!0)},children:(0,z.jsx)(SC,{field:e,hints:t,value:o,stored:r,resource:n,onChange:e=>{s(e),u&&d(!0,void 0,e)}})})},lTe=a({en:{changedBySomeoneElse:`Changed by someone else`,couldNotSave:`Could not save`},nl:{changedBySomeoneElse:`Gewijzigd door iemand anders`,couldNotSave:`Kon niet bewaren`}}),uTe=e=>{let t=W(),n=Km(),r=Hb(),[i,a]=(0,L.useState)(new Map),o=(0,L.useRef)(i),s=(0,L.useRef)(new Map),c=(e,t)=>{o.current=new Map(o.current).set(e,{...o.current.get(e),...t}),a(o.current)},l=async(i,a,s)=>{let l=Kx(e,i),u=String(o.current.get(i.id)?.etag??i.etag);try{let r=await t.update(e.name,l,{[a]:s},u);c(i.id,{[a]:r.record[a],etag:r.etag}),n.setQueryData(U.record(e.name,sr(l)),r),n.invalidateQueries({queryKey:[`page`,e.name]}),n.invalidateQueries({queryKey:[`list`,e.name]}),n.invalidateQueries({queryKey:[`map`,e.name]})}catch(n){if(!Xs(n))throw c(i.id,{[a]:i[a]}),n;let o=n.status===412,s=o?await t.get(e.name,l):void 0;c(i.id,s?{[a]:s.record[a],etag:s.etag}:{[a]:i[a]});let u=n.errors.find(e=>e.field===a)?.message??n.message;r.show({state:`error`,title:lTe(o?`changedBySomeoneElse`:`couldNotSave`),description:u})}};return{patches:i,save:(e,t,n)=>{c(e.id,{[t]:n});let r=(s.current.get(e.id)??Promise.resolve()).then(()=>l(e,t,n));return s.current.set(e.id,r.catch(()=>void 0)),r}}},dTe=(e,t,n)=>{let r=uTe(e),i=t?.list?.editable??[];return{editor:i.length>0&&xT(n,`update`)?{editable:(t,n)=>i.includes(n)&&e.fields[n]!==void 0&&BS(e.fields[n])&&ST(t,`update`),render:(n,i,a)=>(0,z.jsx)(cTe,{field:e.fields[i],hints:t?.fields[i],resource:e.name,stored:n[i],onSave:e=>void r.save(n,i,e),close:a})}:void 0,patches:r.patches}},p9=(e,t)=>({model:e,record:Object.fromEntries(Object.entries(CS(e,t).record).filter(([t])=>Object.hasOwn(e.fields,t))),key:t.id,...typeof t.etag==`string`&&{etag:t.etag},...typeof t.permissions==`object`&&t.permissions!==null&&{permissions:t.permissions}}),fTe=e=>{let{views:t}=G(),n=BT(e.name,void 0),{go:r,href:i}=AS(),[a,o]=(0,L.useState)(),s=(t[e.name]?.actions??[]).filter(e=>!e.inputs?.length),c=e=>`row`in e?n.run(e.action,e.row):n.runEach(e.action,e.selection,e.skipped),l=e=>{e.action.confirm?o(e):c(e)};return{rowActions:s.map(t=>{let a=n=>jT(t,p9(e,n).record),o={label:e=>a(e)?.label??t.label,destructive:hT(t)},s=t.run;if(s?.kind===`link`){let n=n=>a(n)!==void 0&&wT(t,p9(e,n).record);if(`to`in s){let t=t=>Kn(s.to,p9(e,t).record);return{...o,available:n,link:e=>({href:i(t(e)),onFollow:()=>r(t(e))})}}let c=t=>DT(s.href,p9(e,t).record)??``;return{...o,available:n,link:e=>({href:c(e),onFollow:()=>OT(c(e))})}}return{...o,available:e=>a(e)!==void 0,blocked:r=>n.blockedOn(t,p9(e,r)),onSelect:n=>l({action:t,row:p9(e,n)})}}),bulkActions:s.filter(e=>e.bulk&&e.run?.kind!==`link`).map(t=>({label:e=>U7(`actionCount`,t.label,e),destructive:hT(t),available:r=>n.appliesOn(t,p9(e,r)),onRun:(n,r)=>l({action:t,selection:n.map(t=>p9(e,t)),skipped:r})})),prompt:a&&(0,z.jsx)(mT,{action:a.action,label:a.action.label,danger:hT(a.action),onCancel:()=>o(void 0),onConfirm:()=>{o(void 0),c(a)}})}},pTe=(e,t,n)=>({order:r,index:i})=>{let a=t=>r.findIndex(n=>sr(Kx(e,n))===t),o=t.after.find(e=>a(e.key)>i);if(o)return d8(`dependsOn`,n,o.title);let s=t.before.find(e=>a(e.key)!==-1&&a(e.key)<i);return s?d8(`dependsOn`,s.title,n):void 0},mTe=(e,t,n,r)=>{let i=e[t],a;for(let o=n;o<e.length;o++){let n=r({record:i,order:zy(e,t,o),index:o});if(n===void 0)return{to:o,...a!==void 0&&{reason:a}};a??=n}return{to:t,reason:a}},hTe=({model:e,view:t,field:n,filter:r,fields:i,rule:a})=>{let o=W(),s=Hb(),c=RT(),{resources:l,views:u}=G(),d=`${n} asc`,f=Kh({queryKey:[...U.list(e.name,r,d,500,`hand-order`),i.join(`,`)],queryFn:async()=>{let t=Y0(l,u,e,i),n=[],a=``;do{let s=await o.search(e.name,{filter:r||void 0,orderBy:d,pageSize:500,labels:t,...a&&{pageToken:a}});n.push(...X0(l,e,i,s.items,s.labels).map((t,n)=>({...t,id:Gx(e,s.items[n])}))),a=s.nextPageToken}while(a);return n}}),[p,m]=(0,L.useState)(),h=(0,L.useRef)(void 0),g=(0,L.useRef)(void 0),_=(0,L.useRef)(Promise.resolve()),v=(0,L.useRef)(0),y=(0,L.useRef)(void 0),b=async()=>{let t=h.current,r=g.current;if(g.current=void 0,!t||!r)return;let i=c8(t.map(e=>e[n]),r.first,r.last),a=t.slice(i.first,i.last+1),c=Object.fromEntries(a.flatMap(t=>typeof t.etag==`string`?[[sr(Kx(e,t)),t.etag]]:[])),l=(await o.batchWrite([{op:`reorder`,resource:e.name,field:n,keys:a.map(t=>Kx(e,t)),start:i.start,etags:c}])).results[0];if(l?.op!==`reorder`)return;let u=new Map(a.map(e=>[e.id,{[n]:e[n]}])),d=r8(e,l.records.map(t=>({...t,before:u.get(Gx(e,t.record))??{}})),[n]);if(y.current!==void 0&&s.dismiss(y.current),y.current=s.show({state:`success`,title:n8(`orderChanged`),action:{label:n8(`undo`),onClick:()=>E(d)}}),!h.current)return;let f=new Map(l.records.map(t=>[Gx(e,t.record),t]));h.current=h.current.map(e=>{let t=f.get(e.id);return t?{...e,[n]:t.record[n],etag:t.etag}:e})},x=e=>t=>{h.current=void 0,g.current=void 0,m(void 0),s.show({state:`error`,title:e,description:dS(t)})},S=async()=>{--v.current,!(v.current>0)&&(await c(e.name),!(v.current>0)&&(h.current=void 0,m(void 0)))},C=(n,r)=>{let i=h.current??f.data;if(!i||n===r)return;if(!e.position?.after)return w(i,n,r,a);let s=CS(e,i[n]).record,c=i[n].id;o8(o,e,t,s).then(n=>{let i=h.current??f.data,o=pTe(e,n,Ux(e,t,s,c));w(i,i.findIndex(e=>e.id===c),r,e=>o(e)??a?.(e))},x(n8(`couldNotChange`)))},w=(e,t,n,r)=>{if(t===-1||t===n)return;let i=r?T(e,t,n,r):n;if(t===i)return;h.current=zy(e,t,i);let a=Math.min(t,i),o=Math.max(t,i);g.current=g.current?{first:Math.min(g.current.first,a),last:Math.max(g.current.last,o)}:{first:a,last:o},m(h.current),v.current+=1,_.current=_.current.then(b).catch(x(n8(`couldNotChange`))).then(S)},T=(t,n,r,i)=>{let a=mTe(t.map(t=>CS(e,t).record),n,r,i);return a.reason!==void 0&&s.show({state:`warning`,title:a.to===n?n8(`notMoved`):n8(`movedToPlace`,a.to+1),description:a.reason}),a.to},E=e=>{y.current!==void 0&&s.dismiss(y.current),y.current=void 0,v.current+=1,_.current=_.current.then(async()=>{await o.batchWrite(e),h.current=void 0,g.current=void 0,m(void 0)}).catch(x(n8(`couldNotUndo`))).then(S)};return{rows:p??f.data,loading:f.isPending,error:f.error,move:C}},m9=({model:e,view:t,field:n,filter:r,columns:i,sort:a})=>{let{resources:o,views:s}=G(),{fields:c,dropRules:l}=hC(),{go:u,href:d}=AS(),f=a!==void 0,p=(0,L.useMemo)(()=>_5(e,t,i,{resources:o,views:s,fieldTypes:c}).map(e=>f?e:{...e,sortable:!1}),[e,t,i.join(`,`),o,s,c,f]),m=(0,L.useMemo)(()=>SS(e,t,p.map(e=>e.id)),[e,t,p]),h=t?.list?.drag?.rule,g=h===void 0?void 0:l?.[h],_=hTe({model:e,view:t,field:n,filter:r,fields:m,...g&&{rule:g}}),v=_.rows,y=(0,L.useMemo)(()=>v&&{total:v.length,rowAt:e=>v[e]},[v]);if(h!==void 0&&!g)return(0,z.jsx)(Fg,{children:gg(n8(`noRule`),h)});if(_.loading)return(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-4 w-full`},t))});if(_.error)return(0,z.jsx)(rC,{title:n8(`couldNotLoad`),error:_.error});if(!y||y.total===0)return(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:n8(`nothingYet`)});let b=t=>u({kind:`record`,resource:e.name,key:Kx(e,t)});return(0,z.jsx)(_3,{fit:!0,scroll:`parent`,columns:p,source:y,latencyMs:0,onOpenRow:b,rowLink:t=>({href:d({kind:`record`,resource:e.name,key:Kx(e,t)}),onFollow:()=>b(t)}),...a&&{sort:a.value,onSortChange:a.onChange},rowNumbers:!1,reorder:{label:n=>Ux(e,t,n,n.id),onMove:_.move}})},h9=({sorting:e,onChange:t,size:n,iconOnly:r=!1})=>{let i=n8(e?`done`:`reorder`);return(0,z.jsxs)(V,{size:n,variant:e?`primary`:`secondary`,onClick:()=>t(!e),...r&&{"aria-label":i,title:i},children:[e?(0,z.jsx)(xi,{className:`size-3.5`}):(0,z.jsx)(Ur,{className:`size-3.5`}),!r&&i]})},gTe=Vn(),_Te=e=>e.find(e=>e.kind===`search`),vTe=({address:e})=>{let{resources:t,views:n,signIn:r}=G(),i=t[e.resource],a=r?.[e.resource];if(!i)return a?(0,z.jsx)(Wm,{as:`page`,prompt:a.signIn}):(0,z.jsx)(sg,{title:H(`notFound`),children:H(`noResource`,e.resource)});let o=$n(n[e.resource],e.list);if(e.list!==void 0&&!o)return(0,z.jsx)(sg,{title:H(`notFound`),children:U7(`noList`,e.list)});if(o?.searchesOf)return(0,z.jsx)(sTe,{model:i,view:o});let s=DS(t,n,e.resource,e.list);if(o&&s.listOf){let t=s.model;return(0,z.jsx)(Wwe,{model:i,view:o,target:t,children:n=>(0,z.jsx)(g9,{model:t,address:e,scope:n,heading:{title:o.names?.plural??q(i.name),subtitle:o.help}})})}return(0,z.jsx)(g9,{model:i,address:e})},g9=({model:e,address:t,scope:n,heading:r})=>{let i=G(),{set:a,listTo:o,go:s,href:c}=AS(),l=e.name,u=$n(i.views[l],t.list),d=(0,L.useMemo)(()=>l6(u,e),[u,e]),{fields:f}=hC(),p=(0,L.useMemo)(()=>Uwe(h5(tS(e,u),e,u,f),e,u,i.resources,i.views),[e,u,f,i.resources,i.views]),m=t.filter,h=(0,L.useMemo)(()=>o6(d,m),[d,m]),g=h.ok?h.state:A3,_=h.ok?h.extras:[],{orderBy:v,filterLayout:y}=t,b=Mu(),x=Nu(),[S,C]=(0,L.useState)(!1),w=n?[..._,n]:_,T=VSe({model:e,resources:i.resources,views:i.views,view:u,state:g,extras:w}),E=n?t6(d,g,w):h.ok?m:``,D=(0,L.useMemo)(()=>SS(e,u,p.map(e=>e.id)),[e,u,p]),O=(0,L.useMemo)(()=>xbe(u,i.resources,i.views,D),[u,i.resources,i.views,D]),k=S3({resources:i.resources,views:i.views,model:e,columns:D,filter:E,orderBy:v,related:O}),A=aoe(e,u,t.display),j=cg(l),M=n?void 0:q6(e,j),[N,P]=(0,L.useState)(!1),ee=N&&M!==void 0,te=!A&&!ee&&$be(u,M,v,E),ne=ee||A?.kind!==`map`;Gu(ne);let re=Q6(e,k.page,k.key,A?.kind===`custom`),ie=Pwe(),ae=Hx(e,u),oe=e=>({key:e.id,title:String(typeof e[ae]==`object`?e[ae].name:e[ae]??e.id),etag:typeof e.etag==`string`?e.etag:void 0,snapshot:e}),se=u?.names?.singular??q(l),ce=dTe(e,u,j),{state:le}=xf(),ue=H5({model:e,view:u,restore:U5(e),onReview:e=>s({kind:`record`,resource:l,key:e.key})}),F=fTe(e),de=u?.actions.some(e=>e.run?.kind===`delete`)??!1,fe=(e,t=_)=>a({filter:t6(d,e,t)}),pe=_Te(_),me=e=>{let t=_.filter(e=>e.kind!==`search`);fe(g,e?[...t,gTe.search(e)]:t)},I=u?.names?.plural??q(l),he=A?.kind===`calendar`||A?.kind===`timeline`||A?.kind===`board`&&lS(e)?void 0:A,ge=he&&(0,z.jsx)(m5,{model:e,view:u,display:he,orderBy:v,onChange:e=>a({orderBy:e})}),_e=e.search?.length?(0,z.jsx)(Vwe,{value:pe?.kind===`search`?pe.text:``,onCommit:me,placeholder:U7(`searchPlural`,I),className:b?void 0:`min-h-11`}):null,ve=(0,z.jsx)(q3,{layout:y,config:T,value:g,onChange:fe,leading:y===`bar`?ge:void 0,trailing:_e}),ye=y===`bar`?ve:(0,z.jsx)(K3,{groups:[ge?[ge]:[]],trailing:_e}),be=F3(T,g),xe=(0,z.jsx)(D3,{scroll:!0,chips:be,onRemove:e=>fe(I3(g,e)),onClear:()=>fe(A3)}),Se=he&&(0,z.jsx)(z3,{title:U7(`sort`),children:(0,z.jsx)(m5,{model:e,view:u,display:he,orderBy:v,onChange:e=>a({orderBy:e}),className:`min-h-11 w-full`})}),Ce=(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(V,{className:`min-h-11`,onClick:()=>C(!0),"aria-haspopup":`dialog`,children:[(0,z.jsx)(jo,{className:`size-3.5`}),be.length>0?U7(`filtersCount`,be.length):U7(`filters`)]}),_e??(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:xe})]}),_e&&xe,(0,z.jsx)(jm,{title:U7(`filters`),open:S,onClose:()=>C(!1),children:(0,z.jsx)(q3,{layout:`panel`,fullWidth:!0,config:T,value:g,onChange:fe,leading:Se})})]}),we=!n&&W5(u,i.pages,j)&&(0,z.jsxs)(jS,{to:{kind:`create`,resource:l},className:gp({variant:`primary`}),children:[(0,z.jsx)(no,{className:`size-3.5`}),U7(`newRecord`,se)]}),Te=u?.saveSearch&&!n&&h.ok&&m&&(0,z.jsx)(eTe,{model:e,view:u,search:u.saveSearch,filter:m,chips:p6(e,u,m,cbe(T))}),Ee=!n&&(0,z.jsx)(zCe,{model:e}),De=lwe({model:e,view:u,resources:i.resources,views:i.views,plural:I,filter:E,orderBy:v}),Oe=N7(u)&&(0,z.jsxs)(V,{onClick:()=>De.open(),...!b&&{"aria-label":U7(`export`),title:U7(`export`)},children:[(0,z.jsx)(Ui,{className:`size-3.5`}),b&&U7(`export`)]}),ke=M&&!te&&(0,z.jsx)(h9,{sorting:ee,onChange:P,iconOnly:!b}),Ae=t=>!ee&&(0,z.jsx)(p5,{view:u,choices:soe(e,u,x),value:A?.name??`table`,onChange:e=>a({display:e}),menu:t}),je=h6(e),Me=t=>{je(CS(e,t).record),s({kind:`record`,resource:l,key:Kx(e,t)})},Ne=k.source?(0,z.jsx)(_3,{columns:p,source:k.source,sort:TS(v),onSortChange:e=>a({orderBy:ES(e)}),onOpenRow:Me,rowLink:t=>({href:c({kind:`record`,resource:l,key:Kx(e,t)}),onFollow:()=>Me(t)}),cellEditor:ce.editor,rowPatches:ce.patches,initialScrollIndex:ie.initialIndex,onScrollIndex:ie.remember,rowActions:[{label:U7(`openRecord`,se),onSelect:Me},...F.rowActions,...xT(j,`delete`)&&!de?[{label:U7(`delete`),destructive:!0,available:e=>ST(e,`delete`),onSelect:e=>void ue.start(oe(e))}]:[]],bulkActions:[...N7(u)&&L7(e)?[{label:e=>U7(`exportCount`,e),onRun:e=>De.open(e)}]:[],...F.bulkActions,...xT(j,`delete`)?[{label:e=>U7(`deleteCount`,e),destructive:!0,onRun:e=>ue.startBulk(e.map(oe))}]:[]],rowNumbers:!1,pinKey:le.kind===`signed-in`?eye(le.user.id,Z7(l,t.list)):void 0,scroll:`parent`,className:`flex-1`}):(0,z.jsx)(`div`,{className:`flex-1 rounded-lg border bg-surface`}),Pe={...k,initialIndex:ie.initialIndex,onScrollIndex:ie.remember},Fe=dwe({plural:I,search:pe?.kind===`search`?pe.text:``,filtered:be.length>0,scoped:!!n||_.some(e=>e.kind!==`search`),canCreate:!!we}),Ie=(0,z.jsx)(uwe,{state:Fe,onClearSearch:()=>me(``),onClearFilters:()=>fe(A3),create:we}),Le=ee?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:U7(`dragToSort`)}),(0,z.jsx)(m9,{model:e,view:u,field:M,filter:``,columns:eS(e,u)})]}):te?(0,z.jsx)(m9,{model:e,view:u,field:M,filter:``,columns:eS(e,u),sort:{value:TS(v),onChange:e=>a({orderBy:ES(e)})}}):A?A.kind===`cards`?(0,z.jsx)(Ewe,{model:e,view:u,display:A,list:Pe,empty:Ie},k.key.join(` `)):A.kind===`map`?(0,z.jsx)(d5,{model:e,view:u,display:A,filter:E,orderBy:v,fields:D,at:t.map,onMove:e=>a({map:e}),flush:!0}):A.kind===`board`?(0,z.jsx)(m8,{model:e,view:u,display:A,fields:D,filter:E,orderBy:v}):A.kind===`calendar`?(0,z.jsx)(R8,{model:e,view:u,display:A,fields:D,filter:E,at:t.calendar,linkTo:e=>o({calendar:e})}):A.kind===`timeline`?(0,z.jsx)(q8,{model:e,view:u,display:A,fields:D,filter:E,at:t.timeline,linkTo:e=>o({timeline:e})}):(0,z.jsx)(X8,{display:A,list:re}):k.source?.total===0&&!k.error?Ie:Ne;return(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[ue.dialogs,De.dialogs,F.prompt,(0,z.jsx)(ef,{title:r?.title??I,subtitle:r?r.subtitle:u?.help,actions:(0,z.jsxs)(z.Fragment,{children:[Ae(!b),ke,Te,Ee,Oe,we]})}),!h.ok&&(0,z.jsx)(rC,{title:U7(`unreadableFilter`),error:Error(h.errors.map(e=>e.message).join(`; `))}),k.error&&!A&&!ee&&(0,z.jsx)(rC,{title:U7(`couldNotLoadRows`),error:k.error}),u?.chart&&!ee&&(or(u.chart)?(0,z.jsx)(Bwe,{model:e,view:u,chart:u.chart,plural:I,filter:E}):(0,z.jsx)(zwe,{resource:l,chart:u.chart,title:U7(`created`,I),noun:I.toLowerCase(),filter:E})),!ee&&(b?ye:Ce),b&&y===`panel`&&!ee?(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,z.jsx)(`div`,{className:ne?`sticky top-[calc(var(--pb-sticky-top,0px)+1rem)] flex max-h-[calc(100dvh-var(--pb-sticky-top,0px)-var(--pb-sticky-bottom,0px)-2rem)] shrink-0 self-start`:`flex shrink-0`,children:ve}),Le]}):Le]})},_9=e=>e?.role===`owner`?[`owner`,`admin`,`member`]:[`admin`,`member`],yTe=({member:e,current:t,onChanged:n})=>{let{session:r,organizations:i}=xf(),a=t.organization.id,{busy:o,error:s,run:c}=Ag(),l=i?.roles??[],u=e.id===t.memberId,d=_9(t),f=e.role===`owner`&&t.role!==`owner`,p=l.filter(e=>e.membership);return(0,z.jsx)(M5,{name:e.name,email:e.email,self:u,error:s,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`select`,{"aria-label":K(`roleOf`,e.name),value:e.role,disabled:o||f,onChange:t=>void c(async()=>{await r.organizations.setRole(a,e.id,t.target.value),n()}),className:`h-7 rounded-md border border-border-strong bg-background px-2 text-body`,children:(f?[e.role]:d).map(e=>(0,z.jsx)(`option`,{value:e,children:Eg(e)},e))}),!u&&(0,z.jsx)(V,{size:`sm`,variant:`danger`,loading:o,disabled:f,onClick:()=>void c(async()=>{await r.organizations.removeMember(a,e.id),n()}),children:K(`remove`)})]}),children:(0,z.jsx)(O5,{roles:p,selected:e.appRoles,grantable:kg(l,t),disabled:o,onChange:t=>void c(async()=>{await r.organizations.setAppRoles(e.id,t),n()})})})},bTe=({current:e})=>{let{session:t}=xf(),[n,r]=(0,L.useState)(),[i,a]=(0,L.useState)(),o=e?.organization?.id,s=(0,L.useCallback)(()=>{o&&t.organizations.members(o).then(r,e=>a(e instanceof Oc?sf(e):K(`couldNotReadMembers`)))},[t,o]);return(0,L.useEffect)(s,[s]),e?.organization?(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,z.jsx)(ef,{title:K(`members`),subtitle:K(`whoWorks`,e.organization.name)}),(0,z.jsxs)(vp,{title:K(`members`),description:K(`membersDescription`),children:[(0,z.jsx)(yp,{message:i}),n?(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:n.map(t=>(0,z.jsx)(yTe,{member:t,current:e,onChanged:s},`${t.id}/${t.role}/${t.appRoles.join()}`))}):!i&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,K(`loading`)]})]})]}):null},xTe=({current:e,onSent:t})=>{let{session:n,organizations:r}=xf(),i=r?.roles??[],[a,o]=(0,L.useState)(`member`),[s,c]=(0,L.useState)([]);return(0,z.jsx)(E5,{title:K(`inviteSomeone`),description:K(`inviteDescription`),onInvite:async r=>{let i=await n.organizations.invite(e.organization.id,{email:r,role:a,appRoles:s});return c([]),t(),i},beside:(0,z.jsx)(`select`,{"aria-label":K(`organizationRole`),value:a,onChange:e=>o(e.target.value),className:`h-8 rounded-md border border-border-strong bg-background px-2`,children:_9(e).map(e=>(0,z.jsx)(`option`,{value:e,children:Eg(e)},e))}),children:(0,z.jsx)(O5,{roles:i.filter(e=>e.membership),selected:s,grantable:kg(i,e),onChange:c})})},STe=({invitation:e,organizationId:t,onChanged:n})=>{let{session:r,organizations:i}=xf(),a=e.appRoles.map(e=>Dg(i?.roles??[],e));return(0,z.jsx)(D5,{email:e.email,gives:`${Eg(e.role)}${a.length>0?` · ${a.join(`, `)}`:``}`,expiresAt:e.expiresAt,onResend:async()=>{let i=await r.organizations.resend(t,e);return n(),i},onRevoke:async()=>{await r.organizations.revoke(e.id),n()}})},CTe=({current:e})=>{let{session:t}=xf(),[n,r]=(0,L.useState)([]),i=e?.organization?.id,a=(0,L.useCallback)(()=>{i&&t.organizations.invitations(i).then(e=>r(e.filter(e=>e.status===`pending`)),()=>r([]))},[t,i]);return(0,L.useEffect)(a,[a]),!e?.organization||!i?null:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,z.jsx)(ef,{title:K(`invitations`),subtitle:K(`peopleInvited`,e.organization.name)}),(0,z.jsx)(xTe,{current:e,onSent:a}),(0,z.jsx)(vp,{title:K(`notAcceptedYet`),description:n.length>0?K(`sendingAgain`):K(`nobodyWaiting`),children:n.length>0&&(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:n.map(e=>(0,z.jsx)(STe,{invitation:e,organizationId:i,onChanged:a},e.id))})})]})},wTe=e=>{let{session:t}=xf(),[n,r]=(0,L.useState)(),[i,a]=(0,L.useState)([]),[o,s]=(0,L.useState)(),[c,l]=(0,L.useState)(0),u=(0,L.useCallback)(()=>l(e=>e+1),[]);return(0,L.useEffect)(()=>{e&&Promise.all([t.organizations.current(),t.organizations.list()]).then(([e,t])=>{r(e),a(t)},e=>s(e instanceof Oc?sf(e):K(`couldNotReadOrganizations`)))},[e,t,c]),{current:n,organizations:i,...o&&{error:o},reload:u}},v9=e=>window.location.assign(`${e}/`),TTe=({organization:e,editable:t,onSaved:n})=>{let{session:r}=xf(),[i,a]=(0,L.useState)(e.name),[o,s]=(0,L.useState)(e.slug),{busy:c,error:l,run:u}=Ag(),d=i.trim()!==e.name||o!==e.slug;return(0,z.jsxs)(vp,{title:K(`details`),description:K(t?`detailsEditable`:`detailsReadOnly`),children:[(0,z.jsx)(yp,{message:l}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:t=>{t.preventDefault(),u(async()=>{await r.organizations.rename(e.id,{name:i.trim(),slug:o}),n()})},children:[(0,z.jsx)(Wd,{"aria-label":K(`name`),value:i,disabled:!t,onChange:e=>a(e.target.value),wrapperClassName:`flex-1`}),(0,z.jsx)(Wd,{"aria-label":K(`slug`),value:o,disabled:!t,onChange:e=>s(e.target.value),wrapperClassName:`sm:w-48`}),t&&(0,z.jsx)(V,{type:`submit`,variant:`primary`,loading:c,disabled:!d||!i.trim(),children:K(`save`)})]})]})},ETe=({organization:e,memberId:t})=>{let{session:n}=xf(),[r,i]=(0,L.useState)([]),[a,o]=(0,L.useState)(``),{busy:s,error:c,run:l}=Ag();return(0,L.useEffect)(()=>{n.organizations.members(e.id).then(e=>i(e.filter(e=>e.id!==t)),()=>i([]))},[n,e.id,t]),(0,z.jsxs)(vp,{title:K(`handOver`),description:K(`handOverDescription`),children:[(0,z.jsx)(yp,{message:c}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,z.jsxs)(`select`,{"aria-label":K(`newOwner`),value:a,onChange:e=>o(e.target.value),className:`h-8 flex-1 rounded-md border border-border-strong bg-background px-2`,children:[(0,z.jsx)(`option`,{value:``,children:K(`chooseMember`)}),r.map(e=>(0,z.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.email,`)`]},e.id))]}),(0,z.jsx)(V,{loading:s,disabled:!a,onClick:()=>void l(async()=>{await n.organizations.transferOwnership(a),window.location.reload()}),children:K(`handOver`)})]})]})},DTe=({organization:e,basePath:t})=>{let{session:n}=xf(),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(``),{busy:s,error:c,run:l}=Ag(),u=()=>l(async()=>{await n.organizations.remove(e.id),v9(t)});return(0,z.jsxs)(vp,{title:K(`deleteOrganization`),description:K(`deleteDescription`),children:[(0,z.jsx)(yp,{message:r?void 0:c}),(0,z.jsx)(V,{variant:`danger`,onClick:()=>i(!0),children:K(`deleteOrganization`)}),r&&(0,z.jsxs)(_p,{title:K(`deleteTitle`,e.name),description:K(`deleteConfirm`),onClose:()=>i(!1),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:()=>i(!1),children:K(`cancel`)}),(0,z.jsx)(V,{variant:`danger`,loading:s,disabled:a!==e.name,onClick:()=>void u(),children:K(`delete`)})]}),children:[(0,z.jsx)(yp,{message:c}),(0,z.jsx)(Wd,{"aria-label":K(`organizationName`),value:a,onChange:e=>o(e.target.value)})]})]})},OTe=({organization:e,basePath:t,owner:n})=>{let{session:r}=xf(),{busy:i,error:a,run:o}=Ag();return(0,z.jsxs)(vp,{title:K(`leave`),description:K(n?`leaveOwner`:`leaveMember`),children:[(0,z.jsx)(yp,{message:a}),(0,z.jsx)(V,{loading:i,onClick:()=>void o(async()=>{await r.organizations.leave(e.id),v9(t)}),children:K(`leaveName`,e.name)})]})},kTe=({current:e,basePath:t,onChanged:n})=>{let r=e?.organization;if(!r)return(0,z.jsx)(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-6 md:px-6`,children:(0,z.jsx)(ef,{title:K(`organization`),subtitle:K(`noOrganization`)})});let i=e.role===`owner`;return(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,z.jsx)(ef,{title:r.name,subtitle:e.role?K(`youAre`,Eg(e.role).toLowerCase()):K(`throughGlobalRoles`)}),(0,z.jsx)(TTe,{organization:r,editable:Og(e),onSaved:n},`${r.name}/${r.slug}`),i&&e.memberId&&(0,z.jsx)(ETe,{organization:r,memberId:e.memberId}),e.role&&(0,z.jsx)(OTe,{organization:r,basePath:t,owner:i}),i&&(0,z.jsx)(DTe,{organization:r,basePath:t})]})},y9=({organization:e,current:t,busy:n,onOpen:r})=>(0,z.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.slug})]}),t?(0,z.jsx)(_d,{tone:`green`,children:K(`current`)}):(0,z.jsx)(V,{size:`sm`,loading:n,onClick:r,children:K(`open`)})]}),ATe=({basePath:e,currentId:t})=>{let{session:n}=xf(),[r,i]=(0,L.useState)(``),a=j5((0,L.useCallback)((e,t)=>n.organizations.search(e,t).then(e=>({items:e.organizations,total:e.total})),[n]),r),{busy:o,error:s,run:c}=Ag();return(0,z.jsx)(A5,{title:K(`allOrganizations`),description:K(`allOrganizationsDescription`),searchLabel:K(`findOrganization`),placeholder:K(`nameOrSlug`),query:r,onQuery:i,list:a,error:s,renderRow:r=>(0,z.jsx)(y9,{organization:r,current:r.id===t,busy:o,onOpen:()=>void c(async()=>{await n.organizations.switchTo(r.id),v9(e)})},r.id)})},b9=e=>e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,63),jTe=({basePath:e})=>{let{session:t}=xf(),[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(),{busy:o,error:s,run:c}=Ag(),l=()=>c(async()=>{await t.organizations.create({name:n.trim(),slug:i??b9(n)}),v9(e)});return(0,z.jsxs)(vp,{title:K(`newOrganization`),description:K(`newOrganizationDescription`),children:[(0,z.jsx)(yp,{message:s}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,z.jsx)(Wd,{"aria-label":K(`name`),placeholder:K(`name`),value:n,onChange:e=>r(e.target.value),wrapperClassName:`flex-1`}),(0,z.jsx)(Wd,{"aria-label":K(`slug`),placeholder:`slug`,value:i??b9(n),onChange:e=>a(e.target.value),wrapperClassName:`sm:w-48`}),(0,z.jsx)(V,{type:`submit`,variant:`primary`,loading:o,disabled:!n.trim(),children:K(`create`)})]})]})},MTe=()=>{let{session:e,organizations:t}=xf(),[n,r]=(0,L.useState)([]);if((0,L.useEffect)(()=>{e.organizations.myInvitations().then(r,()=>r([]))},[e]),n.length===0)return null;let i=t?.roles??[];return(0,z.jsx)(vp,{title:K(`invitationsForYou`),description:K(`invitationsForYouDescription`),children:(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:n.map(e=>(0,z.jsxs)(`li`,{className:`px-3 py-2.5`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.organizationName??K(`anOrganization`)}),`: `,e.appRoles.map(e=>Dg(i,e)).join(`, `)||K(`noAppRoles`),(0,z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:K(`until`,new Date(e.expiresAt).toLocaleDateString(l()))})]},e.id))})})},NTe=({state:e,basePath:t})=>{let{session:n,organizations:r,state:i}=xf(),{busy:a,error:o,run:s}=Ag(),c=i.kind===`signed-in`?i.user:void 0,l=r?.create===`everyone`||c!==void 0&&l_(c),u=e.current?.organization?.id;return(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,z.jsx)(ef,{title:K(`organizations`),subtitle:K(`organizationsSubtitle`)}),(0,z.jsxs)(vp,{title:K(`yourOrganizations`),description:e.organizations.length>0?K(`memberOf`):K(`notMember`),children:[(0,z.jsx)(yp,{message:o??e.error}),e.organizations.length>0&&(0,z.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.organizations.map(e=>(0,z.jsx)(y9,{organization:e,current:e.id===u,busy:a,onOpen:()=>void s(async()=>{await n.organizations.switchTo(e.id),v9(t)})},e.id))})]}),(0,z.jsx)(MTe,{}),l&&(0,z.jsx)(jTe,{basePath:t}),(e.current?.globalRoles.length??0)>0&&(0,z.jsx)(ATe,{basePath:t,currentId:u})]})},PTe=(e,t)=>t?.active?{...e,role:t.active}:e,x9=a({en:{couldNotReadRoles:`Could not read your roles`,couldNotSwitch:`Could not switch the role`},nl:{couldNotReadRoles:`Kon je rollen niet lezen`,couldNotSwitch:`Kon niet van rol wisselen`}}),S9=(e,t)=>e instanceof Oc?sf(e):t,FTe=(e,t=!0)=>{let{session:n}=xf(),r=Hb(),[i,a]=(0,L.useState)();(0,L.useEffect)(()=>{t&&n.roles.current().then(a,e=>r.show({state:`error`,title:S9(e,x9(`couldNotReadRoles`))}))},[n,r,t]);let o=(0,L.useCallback)(t=>void n.roles.switchTo(t).then(e,e=>r.show({state:`error`,title:S9(e,x9(`couldNotSwitch`))})),[n,r,e]);return{...i&&{current:i},switchTo:o}},ITe=e=>{let t=hC().shell?.logo;return t?(0,z.jsx)(Lg,{name:`shell.logo`,fallback:(0,z.jsx)(ad,{...e}),children:(0,z.jsx)(t,{...e})}):(0,z.jsx)(ad,{...e})},C9=(0,L.createContext)([]),LTe=()=>(0,L.useContext)(C9),RTe=({ui:e,children:t})=>{let{plugins:n=[]}=G(),{loads:r,settled:i}=n_(n,$g()),a=(0,L.useMemo)(()=>Wg(e,r),[e,r]);return i?(0,z.jsx)(mC.Provider,{value:a.ui,children:(0,z.jsx)(C9.Provider,{value:a.off,children:t})}):(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,Gg(`loading`)]})},zTe=({off:e})=>{let[t,n]=(0,L.useState)(!1);return t||e.length===0?null:(0,z.jsxs)(`div`,{role:`region`,"aria-label":Gg(`pluginsOff`),className:`flex items-start gap-3 border-b border-warning/40 bg-warning-soft px-4 py-2 text-warning-text`,children:[(0,z.jsx)(oo,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,z.jsx)(`ul`,{className:`min-w-0 flex-1 space-y-0.5 break-words`,children:e.map(e=>(0,z.jsx)(`li`,{children:gg(Gg(`pluginOff`),(0,z.jsx)(`span`,{className:`font-semibold`,children:e.name??e.url}),e.reason)},e.url))}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Gg(`dismiss`),className:`rounded p-0.5 hover:bg-warning/10`,onClick:()=>n(!0),children:(0,z.jsx)(ss,{"aria-hidden":!0,className:`size-4`})})]})},w9=(e,t)=>[`${t}_at`,`${t}At`].find(t=>e.fields[t]),T9=({item:e,scope:t})=>{let{components:n}=hC(),r=n?.[e.component],i=r?(0,z.jsx)(yT,{value:t,children:(0,z.jsx)(Lg,{name:e.component,children:(0,z.jsx)(r,{...Jn(e.props??{})})})}):(0,z.jsx)(Fg,{children:gg(H(`noComponent`),e.component)});return e.sidebar?e.title?(0,z.jsx)(Zb,{title:e.title,children:i}):i:e.title?(0,z.jsx)(qb,{title:e.title,children:i}):(0,z.jsx)(`section`,{className:`py-8`,children:i})},BTe=(0,L.lazy)(()=>m(()=>import(`./record-map-DFy7sJEU.js`).then(e=>({default:e.RecordMap})),__vite__mapDeps([10,1,6,2,7,8,3,4,9]))),VTe=15,E9=({item:e,record:t})=>{let n=G().maps,r=n?.style,i=n5(t,e);if(!r||!i)return null;let a=(0,z.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted ${e.sidebar?`h-48`:`h-64 md:h-80`}`,children:(0,z.jsx)(L.Suspense,{fallback:null,children:(0,z.jsx)(BTe,{style:r,layers:n?.layers,position:i,zoom:e.zoom??VTe},`${i.latitude},${i.longitude}`)})});return e.sidebar?(0,z.jsx)(Zb,{title:e.title,children:a}):(0,z.jsx)(qb,{title:e.title,children:a})},HTe={"1h":`minute`,"24h":`5_minutes`,"7d":`hour`},UTe=(e,t,n)=>{let r=new Map;e.forEach((e,i)=>{for(let a of e){let e=Date.parse(`${String(a.value)}Z`),o=r.get(e)??{at:e,value:null,count:0};o[t[i]]=a[n]??null,o.count=Math.max(o.count,a.count),r.set(e,o)}});let i=Object.fromEntries(t.map(e=>[e,null]));return[...r.values()].sort((e,t)=>e.at-t.at).map(e=>({...i,...e}))},D9=a({en:{range:`Range`,hour:`Hour`,day:`Day`,week:`Week`,measure:`Per bucket`,average:`Average`,maximum:`Maximum`,noSamples:`No samples in this range.`,couldNotLoad:`Could not load the chart.`},nl:{range:`Periode`,hour:`Uur`,day:`Dag`,week:`Week`,measure:`Per interval`,average:`Gemiddelde`,maximum:`Maximum`,noSamples:`Geen metingen in deze periode.`,couldNotLoad:`Kon de grafiek niet laden.`}}),WTe=Vn(),GTe=[`1h`,`24h`,`7d`],KTe={"1h":`hour`,"24h":`day`,"7d":`week`},qTe=({item:e,recordKey:t})=>{let{resources:n,views:r}=G(),[i,a]=(0,L.useState)(e.range??`1h`),[o,s]=(0,L.useState)(`average`),c=n[e.resource],l=r[e.resource],u=HTe[i],d=Fn(WTe.eq(e.field,t)),p=e.series.map(t=>({groupBy:e.at,filter:d,...o===`average`?{average:t}:{maximum:t},range:i,granularity:u,timeZone:If()})),m=eE(e.resource,p,!!c);if(!c)return null;let h=e.series.map(e=>({kind:o,field:c.fields[e],...l?.fields[e]&&{hints:l.fields[e]}})),g=e.series.map((e,t)=>({key:`s${t}`,label:l?.fields[e]?.label??q(e),color:`var(--chart-${t+1})`,measure:h[t]})),_=m.every(e=>e.data)?UTe(m.map(e=>e.data.groups),g.map(e=>e.key),o):[],v=(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(f,{label:D9(`measure`),value:o,onChange:s,options:[{value:`average`,label:D9(`average`)},{value:`maximum`,label:D9(`maximum`)}]}),(0,z.jsx)(f,{label:D9(`range`),value:i,onChange:a,options:GTe.map(e=>({value:e,label:D9(KTe[e])}))})]});return(0,z.jsx)(qb,{title:e.title,help:e.help,actions:v,children:m.some(e=>e.error)?(0,z.jsx)(`p`,{className:`text-danger-text`,children:D9(`couldNotLoad`)}):m.some(e=>e.isPending)?(0,z.jsx)(Yu,{className:`h-40 w-full`}):_.every(e=>e.count===0)?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:D9(`noSamples`)}):(0,z.jsx)(W0,{points:_,measure:h[0],bucket:u,type:`line`,series:g,...g.length>1&&{resource:e.resource,view:l}})})},JTe=e=>km(e)??vte,YTe=({model:e,stored:t,recordKey:n,edit:r,onDelete:i})=>{let{go:a}=AS(),o=Bd(),s={model:e,record:t.record,key:n,etag:t.etag,permissions:t.permissions},c=BT(e.name,s,t=>t.run?.kind===`delete`&&a({kind:`list`,resource:e.name},{replace:!0})),[l,u]=(0,L.useState)(),d=c.actions.map(e=>({name:e.label,icon:JTe(e.icon),blocked:c.blocked(e),running:c.running===e.name,...hT(e)&&{tone:`danger`},onRun:()=>gT(e)?u(e):void c.run(e)})),f=c.actions.some(e=>e.run?.kind===`delete`),p=[...r?[{name:L5(`edit`),icon:Za,render:({className:e,children:t,role:n})=>(0,z.jsx)(jS,{to:r,role:n,className:e,children:t})}]:[],...d,...i&&!f?[{name:L5(`delete`),icon:Ko,tone:`danger`,onRun:i}]:[]];return p.length===0?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:o?`max-md:hidden`:void 0,children:(0,z.jsx)(Yb,{actions:p})}),o&&(0,ls.createPortal)((0,z.jsx)(voe,{actions:p,label:L5(`recordActions`),className:`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted md:hidden`}),o),l&&(0,z.jsx)(_T,{action:l,label:l.label,danger:hT(l),onCancel:()=>u(void 0),onConfirm:()=>{u(void 0),c.run(l)},onSubmit:async e=>{await c.submit(l,e),u(void 0)}})]})},XTe=(e=[],t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],ZTe=(e,t=[],n)=>!e.collapsed||t.includes(e.title)||e.items.some(e=>e.kind===`section`&&e.fields.some(n)),QTe=e=>{let t=e.findIndex(e=>e.kind===`tab`);if(t===-1)return{before:e,tabs:[],after:[]};let n=[];for(let r of e.slice(t)){if(r.kind!==`tab`)break;n.push(r)}return{before:e.slice(0,t),tabs:n,after:e.slice(t+n.length)}},$Te=(e,t)=>e.find(e=>e.title===t)??e[0],O9=e=>Qn(e.items).flatMap(e=>e.kind===`section`?e.fields:[]),eEe=(e,t,n)=>{if(t&&!O9(t).some(n))return e.find(e=>O9(e).some(n))},tEe=(e,t)=>Object.values(e).find(e=>e.name!==t.name&&e.fields.position&&e.fields.quantity&&Object.values(e.fields).some(e=>e.type===`relation`&&e.relation?.resource===t.name)),nEe=e=>({id:String(e.id),productId:String(e.productId??``),description:String(e.description??``),quantity:Number(e.quantity),unitPriceCents:Math.round(Number(e.unitPrice)*100)}),rEe=({lines:e,draft:t,vatRate:n,saving:r,locked:i=!1})=>{let a=xT(cg(e.name),`update`);return(0,z.jsx)(qb,{title:L5(`lines`),help:L5(`linesHelp`),children:(0,z.jsx)(`div`,{className:`-mx-4 overflow-x-auto px-4 [-webkit-overflow-scrolling:touch] md:mx-0 md:px-0`,children:(0,z.jsx)(`div`,{className:`min-w-[560px]`,children:(0,z.jsx)(Nb,{lines:t.shown.map(nEe),onChange:()=>void 0,onReorder:e=>t.setOrder(e.map(e=>e.id)),vatRate:n,readOnly:!0,reorderable:a&&!r&&!i})})})})},iEe=(e,t,n)=>`protobase:draft:${e}:${t}:${n}`,aEe=(e,t,n)=>u(()=>{let r=e.getItem(t);if(r===null)return;let i=JSON.parse(r);if(i&&i.etag===n&&typeof i.fields==`object`&&i.fields!==null)return{etag:n,fields:i.fields,...Array.isArray(i.order)&&{order:i.order.map(String)}}},void 0),oEe=(e,t,n)=>u(()=>n?e.setItem(t,JSON.stringify(n)):e.removeItem(t),void 0),sEe=(e,t)=>Number(e.position)-Number(t.position),cEe=(e,t,n)=>{let r=e&&Object.values(e.fields).find(e=>e.type===`relation`&&e.relation?.resource===t.name),i=sC(e?.name??``,{enabled:!!(e&&r),filter:r?`${r.name} = "${n}"`:void 0,pageSize:200,...e?.fields.position?.sortable&&{orderBy:`position asc`}});return{items:[...i.items].sort(sEe),loading:i.isPending&&!!e}},lEe=(e,t)=>{let[n,r]=(0,L.useState)(),i=t.map(e=>String(e.id)),a=(0,L.useMemo)(()=>{if(!n)return t;let e=n.flatMap(e=>t.filter(t=>String(t.id)===e)),r=t.filter(e=>!n.includes(String(e.id)));return[...e,...r]},[n,t]),o=a.map(e=>String(e.id)),s=n!==void 0&&o.some((e,t)=>e!==i[t]),c=(0,L.useCallback)(()=>!e||!s?[]:[{op:`reorder`,resource:e.name,field:`position`,keys:a.map(t=>Kx(e,t)),etags:Object.fromEntries(a.flatMap(t=>typeof t.etag==`string`?[[sr(Kx(e,t)),t.etag]]:[]))}],[e,s,a]);return{shown:a,dirty:s,order:s?o:void 0,setOrder:e=>r(e),reset:()=>r(void 0),op:c}},uEe=e=>{let t=e>=5?5:e===4?3:e;return{shown:t,more:e-t}},dEe=(e,t)=>Math.abs(e)<40||Math.abs(e)<=Math.abs(t)?0:e<0?1:-1,fEe=e=>e===`ArrowRight`?1:e===`ArrowLeft`?-1:0,pEe=(e,t,n)=>Math.min(Math.max(e+t,0),Math.max(n-1,0)),mEe=e=>e.key===`i`&&!e.ctrlKey&&!e.metaKey&&!e.altKey,k9=`protobase:lightbox-details`,hEe=e=>u(()=>e.getItem(k9)===`true`,!1),gEe=(e,t)=>u(()=>t?e.setItem(k9,`true`):e.removeItem(k9),void 0),A9=a({en:{couldNotLoad:`Could not load the photos`,showAll:e=>`Show all ${e} photos`,showPhoto:(e,t)=>`Show photo ${e} of ${t}`,details:`Details`,holderDetails:e=>`${e} details`,close:`Close`,previousPhoto:`Previous photo`,nextPhoto:`Next photo`,couldNotLoadOne:e=>`Could not load the ${e}`,open:e=>`Open ${e}`},nl:{couldNotLoad:`Kon de foto’s niet laden`,showAll:e=>`Alle ${e} foto’s tonen`,showPhoto:(e,t)=>`Foto ${e} van ${t} tonen`,details:`Gegevens`,holderDetails:e=>`Gegevens van ${e.toLowerCase()}`,close:`Sluiten`,previousPhoto:`Vorige foto`,nextPhoto:`Volgende foto`,couldNotLoadOne:e=>`Kon ${e} niet laden`,open:e=>`${e} openen`}}),j9=`flex size-10 shrink-0 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm transition-colors hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,_Ee=({title:e,photos:t,index:n,onIndex:r,onClose:i,details:a,detailsTitle:o=A9(`details`)})=>{let s=(0,L.useRef)(null),c=(0,L.useRef)(void 0),l=(0,L.useId)(),u=Mu(),[d,f]=(0,L.useState)(()=>hEe(localStorage)),[p,m]=(0,L.useState)(!1);Hu(s,!0,i),(0,L.useEffect)(()=>m(!0),[]);let h=t.length,_=e=>{let t=pEe(n,e,h);t!==n&&r(t)},v=dx(t[n],{width:1600,height:1200}),y=a?.(n),b=y!==void 0,x=e=>{f(e),gEe(localStorage,e)};return(0,z.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,onKeyDown:e=>{if(b&&mEe(e))return e.preventDefault(),x(!d);let t=fEe(e.key);t!==0&&(e.preventDefault(),_(t))},className:`fixed inset-0 z-[90] flex flex-col overflow-y-auto overscroll-contain bg-backdrop outline-none md:flex-row`,children:[(0,z.jsxs)(`div`,{className:`flex h-dvh shrink-0 flex-col md:sticky md:top-0 md:min-w-0 md:flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 p-3`,children:[(0,z.jsx)(`span`,{className:`rounded-full bg-background/85 px-3 py-1 font-medium tabular-nums text-foreground`,"aria-live":`polite`,children:`${n+1} / ${h}`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,z.jsx)(`button`,{type:`button`,className:g(j9,`aria-expanded:bg-foreground aria-expanded:text-background`),"aria-label":o,"aria-expanded":d,"aria-controls":u?l:void 0,"aria-keyshortcuts":`i`,onClick:()=>x(!d),children:(0,z.jsx)(rte,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(`button`,{type:`button`,className:j9,"aria-label":A9(`close`),onClick:i,children:(0,z.jsx)(ss,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 touch-pan-y items-center justify-center px-3 pb-3 md:px-16`,onPointerDown:e=>{e.pointerType===`touch`&&(c.current={x:e.clientX,y:e.clientY})},onPointerUp:e=>{c.current&&=(_(dEe(e.clientX-c.current.x,e.clientY-c.current.y)),void 0)},onPointerCancel:()=>c.current=void 0,children:[v&&(0,z.jsx)(fC,{image:v,className:`max-h-full max-w-full select-none object-contain`},v.url),h>1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,className:g(j9,`absolute left-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":A9(`previousPhoto`),"aria-disabled":n===0,onClick:()=>_(-1),children:(0,z.jsx)(Ti,{className:`size-5`,"aria-hidden":!0})}),(0,z.jsx)(`button`,{type:`button`,className:g(j9,`absolute right-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":A9(`nextPhoto`),"aria-disabled":n===h-1,onClick:()=>_(1),children:(0,z.jsx)(Di,{className:`size-5`,"aria-hidden":!0})})]})]})]}),b&&d&&u&&(0,z.jsxs)(`aside`,{id:l,"aria-label":o,className:`min-h-dvh w-[360px] shrink-0 border-l border-border bg-background p-5 text-foreground`,children:[(0,z.jsx)(`h2`,{className:`mb-3 text-[16px] font-semibold`,children:o}),y]}),(0,z.jsx)(jm,{title:o,open:b&&d&&!u&&p,onClose:()=>x(!1),children:(0,z.jsx)(`div`,{className:`pt-3`,children:y})})]})},vEe=(e,t,n)=>{let r=Qn(t?.layout??[]).flatMap(e=>e.kind===`section`&&JS(e.when,!1)?e.fields:[]);return(r.length>0?[...new Set(r)]:Object.keys(e.fields).filter(t=>t!==e.tenant&&!e.primaryKey.includes(t))).filter(r=>e.fields[r]&&!e.fields[r].sensitive&&!n.includes(r)&&JS(t?.fields[r]?.when,!1))},yEe=({model:e,view:t,photoKey:n,fields:r})=>{let i=f_(e.name,n),a=(t?.names?.singular??q(e.name)).toLowerCase();if(i.isPending)return(0,z.jsx)(Yu,{className:`h-4 w-48`});if(i.error)return(0,z.jsx)(rC,{title:A9(`couldNotLoadOne`,a),error:i.error});let o=r.filter(e=>CT(i.data.permissions,e)!==`hidden`);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(NS,{rows:o.map(n=>({label:t?.fields[n]?.label??q(n),value:(0,z.jsx)($0,{model:e,field:e.fields[n],value:i.data.record[n]})}))}),(0,z.jsx)(jS,{to:{kind:`record`,resource:e.name,key:n},className:`mt-3 inline-block font-medium text-primary-text hover:underline`,children:A9(`open`,a)})]})},M9=e=>dx(e,{width:0,height:0})!==void 0,bEe=(e,t)=>{let n=e.primaryKey.map(e=>t[e]);if(!n.some(e=>e==null))return sr(n)},xEe=(e,t,n,r)=>{let i=n===void 0?[]:t.flatMap(e=>{let t=e[n];if(!tx(t)||!M9(t))return[];let i=r&&bEe(r,e);return[{file:t,...i!==void 0&&{key:i}}]});if(!tx(e)||!M9(e))return i;let a=t=>tx(t.file)&&t.file.uri===e.uri,o=i.find(a)?.key;return[{file:e,...o!==void 0&&{key:o}},...i.filter(e=>!a(e))]},SEe=Vn(),CEe=(e,t,n)=>{let r=W(),{resources:i}=G(),a=e.photos?i[e.photos.resource]:void 0,o=e.photos?Fn(SEe.eq(e.photos.field,n)):``,s=e.photos?.sort??``,c=Kh({queryKey:U.list(a?.name??``,o,s,500,`gallery`),enabled:a!==void 0,queryFn:async()=>(await r.list(a.name,{filter:o,...s&&{orderBy:s},pageSize:500})).items});return{holder:a,items:xEe(e.image===void 0?void 0:t[e.image],c.data??[],e.photos?.image,a),isPending:a!==void 0&&c.isPending,error:c.error}},wEe={1:[`md:col-span-4 md:row-span-2`],2:[`md:col-span-2 md:row-span-2`,`md:col-span-2 md:row-span-2`],3:[`md:col-span-2 md:row-span-2`,`md:col-span-2`,`md:col-span-2`],5:[`md:col-span-2 md:row-span-2`,``,``,``,``]},TEe=({photo:e,large:t})=>{let n=dx(e,t?{width:960,height:720}:{width:480,height:360});return n?(0,z.jsx)(fC,{image:n,loading:`lazy`,className:`size-full object-cover transition-transform duration-300 group-hover/tile:scale-[1.02]`}):null},EEe=({item:e,record:t,recordKey:n})=>{let{views:r}=G(),i=CEe(e,t,n),a=cg(i.holder?.name??``),[o,s]=(0,L.useState)();if(i.isPending)return(0,z.jsx)(qb,{title:e.title,children:(0,z.jsx)(Yu,{className:`aspect-[4/3] w-full rounded-lg md:aspect-[2/1]`})});if(i.error)return(0,z.jsx)(qb,{title:e.title,children:(0,z.jsx)(rC,{title:A9(`couldNotLoad`),error:i.error})});let c=i.items.length;if(c===0)return null;let{shown:l,more:u}=uEe(c),d=i.holder,f=d&&r[d.name],p=d?vEe(d,f,[e.photos?.image,e.photos?.field].filter(e=>e!==void 0)):[],m=d!==void 0&&a.read!==!1&&p.length>0;return(0,z.jsxs)(qb,{title:e.title,children:[(0,z.jsx)(`div`,{className:`grid aspect-[4/3] grid-cols-4 grid-rows-2 gap-1.5 overflow-hidden rounded-lg md:aspect-[2/1]`,children:i.items.slice(0,l).map((e,t)=>{let n=t===l-1&&u>0;return(0,z.jsxs)(`button`,{type:`button`,"aria-label":n?A9(`showAll`,c):A9(`showPhoto`,t+1,c),onClick:()=>s(t),className:g(`group/tile relative overflow-hidden bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,t===0?`col-span-4 row-span-2`:`max-md:hidden`,wEe[l][t]),children:[(0,z.jsx)(TEe,{photo:e.file,large:t===0}),n&&(0,z.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-backdrop/55 text-lg font-semibold text-white`,"aria-hidden":!0,children:`+${u}`}),t===0&&c>1&&(0,z.jsxs)(`span`,{className:`absolute bottom-2 right-2 flex items-center gap-1.5 rounded-full bg-background/85 px-2.5 py-1 text-xs font-medium tabular-nums text-foreground md:hidden`,"aria-hidden":!0,children:[(0,z.jsx)(nte,{className:`size-3.5`}),c]})]},t)})}),o!==void 0&&(0,z.jsx)(_Ee,{title:e.title,photos:i.items.map(e=>e.file),index:o,onIndex:s,onClose:()=>s(void 0),details:e=>{let t=i.items[e]?.key;return m&&t!==void 0?(0,z.jsx)(yEe,{model:d,view:f,photoKey:t,fields:p},t):void 0},detailsTitle:d&&A9(`holderDetails`,f?.names?.singular??q(d.name))})]})},N9=a({en:{create:`created this`,update:`changed`,delete:`deleted this`,undelete:`restored this`,database:`Database`,databaseRole:e=>`Database (${e})`,changed:`changed`,changedThis:`changed this`,couldNotLoad:`Could not load the history`,noChanges:`No changes kept yet.`,showMore:`Show more`},nl:{create:`maakte dit`,update:`wijzigde`,delete:`verwijderde dit`,undelete:`zette dit terug`,database:`Database`,databaseRole:e=>`Database (${e})`,changed:`gewijzigd`,changedThis:`wijzigde dit`,couldNotLoad:`Kon de geschiedenis niet laden`,noChanges:`Nog geen wijzigingen bewaard.`,showMore:`Meer tonen`}}),DEe=e=>e.actor?e.actor.name??e.actor.id:e.databaseRole?N9(`databaseRole`,e.databaseRole):N9(`database`),OEe=(e,t,n)=>{let r=(e.operation===`create`?[]:e.changed).flatMap(r=>{let i=t.fields[r];if(!i||r===t.softDelete)return[];let a=n?.fields[r],o=a?.label??q(r);return i.sensitive||!e.before||!e.after?[{name:r,label:o}]:[{name:r,label:o,before:rS(i,e.before[r],a),after:rS(i,e.after[r],a)}]}),i=e.operation===`update`&&r.length===0?N9(`changedThis`):N9(e.operation);return{who:DEe(e),verb:i,fields:r}},kEe=1500,AEe=(e,t,n,r)=>{let i=W(),a=Jh({queryKey:U.history(e,t,n),initialPageParam:``,queryFn:({pageParam:r})=>i.history(e,t,{pageSize:n,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0}),{refetch:o}=a;return(0,L.useEffect)(()=>{let e=setTimeout(()=>void o(),kEe);return()=>clearTimeout(e)},[r,o]),{...a,items:a.data?.pages.flatMap(e=>e.items)??[]}},jEe=()=>(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-4 w-full`},t))}),MEe=({change:e,model:t,view:n})=>{let{who:r,verb:i,fields:a}=OEe(e,t,n),o=Date.parse(e.at);return(0,z.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-3 first:pt-0 last:pb-0`,children:[(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),` `,(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:i}),` `,(0,z.jsxs)(`time`,{dateTime:e.at,title:np(o),className:`text-muted-foreground`,children:[`· `,pp(Math.max(0,Math.round((Date.now()-o)/1e3)))]})]}),a.length>0&&(0,z.jsx)(`dl`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1`,children:a.map(e=>(0,z.jsxs)(`div`,{className:`contents`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,z.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.before===void 0?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`changed`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`del`,{className:`text-muted-foreground`,children:e.before}),` → `,(0,z.jsx)(`ins`,{className:`no-underline`,children:e.after})]})})]},e.name))})]})},NEe=({item:e,model:t,view:n,recordKey:r,etag:i})=>{let a=AEe(t.name,r,e.limit??10,i);return(0,z.jsx)(qb,{title:e.title,children:a.isPending?(0,z.jsx)(jEe,{}):a.error?(0,z.jsx)(rC,{title:`Could not load the history`,error:a.error}):a.items.length===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`No changes kept yet.`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`ol`,{className:`divide-y divide-border`,children:a.items.map(e=>(0,z.jsx)(MEe,{change:e,model:t,view:n},e.id))}),a.hasNextPage&&(0,z.jsx)(V,{size:`sm`,className:`mt-4`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Show more`})]})})},PEe=(e,t)=>{let n=/(?:^|\s)@([^\s@]*)$/.exec(e.slice(0,t));return n?{start:t-n[1].length-1,query:n[1]}:void 0},FEe=(e,t,n)=>{let r=e.slice(t.start+1+t.query.length),i=`@${n}${r.startsWith(` `)?``:` `}`;return{text:`${e.slice(0,t.start)}${i}${r}`,caret:t.start+i.length+ +!!r.startsWith(` `)}},IEe=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),P9=e=>{let t=[...new Set(e)].filter(Boolean).sort((e,t)=>t.length-e.length);return t.length===0?void 0:RegExp(`(?<![\\p{L}\\p{N}_@])@(${t.map(IEe).join(`|`)})(?![\\p{L}\\p{N}_])`,`gu`)},LEe=(e,t)=>{let n=P9(t.map(e=>e.name)),r=new Set(n?[...e.matchAll(n)].map(e=>e[1]):[]);return[...new Set(t.filter(e=>r.has(e.name)).map(e=>e.id))]},REe=(e,t)=>{let n=P9(t.flatMap(e=>e.name?[e.name]:[]));if(!n)return[{text:e}];let r=[],i=0;for(let t of e.matchAll(n))t.index>i&&r.push({text:e.slice(i,t.index)}),r.push({mention:t[1]}),i=t.index+t[0].length;return i<e.length&&r.push({text:e.slice(i)}),r},zEe=({comment:e})=>(0,z.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:REe(e.body,e.mentions).map((e,t)=>`mention`in e?(0,z.jsxs)(`span`,{className:`font-medium text-primary`,children:[`@`,e.mention]},t):e.text)}),BEe=(e,t,n)=>{let r=W(),i=V3(n,150);return Kh({queryKey:U.mentionable(e,t,i??``),queryFn:()=>r.mentionable(e,t,i??``),enabled:i!==void 0,placeholderData:lh})},VEe=(e,t)=>{let n=W(),r=Km();return qh({mutationFn:r=>n.comment(e,t,r),onSuccess:()=>r.invalidateQueries({queryKey:U.comments(e,t)})})},F9=a({en:{couldNotPost:`Could not post the comment`,comment:`Comment`,placeholder:`Write a comment, @ to mention someone`,peopleToMention:`People to mention`,noOneFound:`No one found`,couldNotLoad:`Could not load the comments`,showEarlier:`Show earlier comments`,noComments:`No comments yet.`},nl:{couldNotPost:`Kon de opmerking niet plaatsen`,comment:`Opmerking`,placeholder:`Schrijf een opmerking, @ om iemand te noemen`,peopleToMention:`Mensen om te noemen`,noOneFound:`Niemand gevonden`,couldNotLoad:`Kon de opmerkingen niet laden`,showEarlier:`Eerdere opmerkingen tonen`,noComments:`Nog geen opmerkingen.`}}),HEe=8,UEe=({resource:e,recordKey:t})=>{let[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(0),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)([]),[u,d]=(0,L.useState)(0),[f,p]=(0,L.useState)(),m=(0,L.useRef)(null),h=(0,L.useRef)(void 0),_=(0,L.useId)(),v=Hb(),y=VEe(e,t),b=PEe(n,i),x=o&&b!==void 0&&b.start!==f,S=BEe(e,t,x?b.query:void 0),C=x?(S.data??[]).slice(0,HEe):[],w=x&&S.data!==void 0,T=e=>`${_}-${e}`;(0,L.useEffect)(()=>d(0),[b?.query]);let E=b?.start;(0,L.useEffect)(()=>{E===void 0&&p(void 0)},[E]),(0,L.useLayoutEffect)(()=>{h.current!==void 0&&m.current&&(m.current.setSelectionRange(h.current,h.current),a(h.current),h.current=void 0)},[n]);let D=e=>{if(!b)return;let t=FEe(n,b,e.name);h.current=t.caret,r(t.text),l(t=>[...t,e])},O=()=>{n.trim()===``||y.isPending||y.mutate({body:n,mentions:LEe(n,c)},{onSuccess:()=>{r(``),l([])},onError:e=>v.show({state:`error`,title:F9(`couldNotPost`),description:dS(e)})})};return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(oC,{ref:m,role:`combobox`,"aria-label":F9(`comment`),"aria-multiline":!0,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":_,"aria-activedescendant":w&&C[u]?T(u):void 0,placeholder:F9(`placeholder`),value:n,onChange:e=>{r(e.target.value),a(e.target.selectionStart)},onSelect:e=>a(e.currentTarget.selectionStart),onFocus:()=>s(!0),onBlur:()=>s(!1),onKeyDown:e=>{if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){e.preventDefault(),O();return}if(!x)return;let t=B3(e.key,u,C.length);if(t!==void 0&&(e.key===`ArrowDown`||e.key===`ArrowUp`)){e.preventDefault(),d(t);return}if((e.key===`Enter`||e.key===`Tab`)&&C[u]){e.preventDefault(),D(C[u]);return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p(b.start))}}),w&&(0,z.jsxs)(`ul`,{id:_,role:`listbox`,"aria-label":F9(`peopleToMention`),className:`absolute z-30 mt-1 w-full max-w-sm rounded-md border bg-background py-1 shadow-pop`,onMouseDown:e=>e.preventDefault(),children:[C.map((e,t)=>(0,z.jsx)(`li`,{id:T(t),role:`option`,"aria-selected":t===u,className:g(`cursor-pointer truncate px-3 py-1.5`,t===u&&`bg-muted`),onMouseMove:()=>t!==u&&d(t),onClick:()=>D(e),children:e.name},e.id)),C.length===0&&(0,z.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:F9(`noOneFound`)})]})]}),(0,z.jsx)(`div`,{children:(0,z.jsx)(V,{variant:`primary`,size:`sm`,disabled:n.trim()===``,loading:y.isPending,onClick:O,children:F9(`comment`)})})]})},WEe=20,GEe=(e,t)=>{let n=W(),r=Jh({queryKey:U.comments(e,t),initialPageParam:``,queryFn:({pageParam:r})=>n.comments(e,t,{pageSize:WEe,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0});return{...r,items:r.data?.pages.flatMap(e=>e.items).reverse()??[]}},KEe=()=>(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-4 w-full`},t))}),qEe=({comment:e})=>{let t=e.author.name??e.author.id,n=Date.parse(e.createdAt);return(0,z.jsxs)(`li`,{className:`flex gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,z.jsx)(cd,{initials:s_(t)||`?`,hue:o_(e.author.id),size:`md`,className:`ring-0`}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),` `,(0,z.jsxs)(`time`,{dateTime:e.createdAt,title:np(n),className:`text-muted-foreground`,children:[`· `,pp(Math.max(0,Math.round((Date.now()-n)/1e3)))]})]}),(0,z.jsx)(zEe,{comment:e})]})]})},JEe=({item:e,resource:t,recordKey:n,canWrite:r})=>{let i=GEe(t,n);return(0,z.jsxs)(qb,{title:e.title,children:[i.isPending?(0,z.jsx)(KEe,{}):i.error?(0,z.jsx)(rC,{title:F9(`couldNotLoad`),error:i.error}):(0,z.jsxs)(z.Fragment,{children:[i.hasNextPage&&(0,z.jsx)(V,{size:`sm`,className:`mb-4`,disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:F9(`showEarlier`)}),i.items.length===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:F9(`noComments`)}):(0,z.jsx)(`ol`,{className:`divide-y divide-border`,children:i.items.map(e=>(0,z.jsx)(qEe,{comment:e},e.id))})]}),r&&(0,z.jsx)(`div`,{className:`mt-4`,children:(0,z.jsx)(UEe,{resource:t,recordKey:n})})]})},YEe=e=>e.kind===`group`||e.kind===`tab`?e.items:[],I9=e=>e.kind===`tab`?void 0:e.when,L9=e=>e.flatMap(e=>[e,...L9(YEe(e))]).filter(e=>fs(I9(e))),XEe=(e,t,n,r)=>{let i=0,a=e=>{let a=I9(e);return fs(a)?!r&&t[i++]===!0:JS(a,n)},o=e=>e.flatMap(e=>{let t=a(e);if(e.kind!==`group`&&e.kind!==`tab`)return t?[e]:[];let n=o(e.items);return t&&n.length>0?[{...e,items:n}]:[]});return o(e)},ZEe=(e,t,n,r)=>XEe(e,W6(r?[]:L9(e).map(e=>I9(e)),t),n,r),R9=(e,t)=>{let n=W(),r=Km(),i=sr(t);return qh({mutationFn:({patch:r,etag:i})=>n.update(e,t,r,i),onSuccess:t=>{r.setQueryData(U.record(e,i),t),r.invalidateQueries({queryKey:[`page`,e]}),r.invalidateQueries({queryKey:[`list`,e]}),r.invalidateQueries({queryKey:[`map`,e]})}})},z9=e=>e instanceof Ys,QEe=e=>{let t=typeof e.resource==`string`?e.resource:e.resource.toModel().name;return e.op===`reorder`?`reorder ${t} by ${e.field}`:`${e.op} ${t}`},$Ee=(e,t)=>{let n=e.operation,r=n===void 0?void 0:t[n];return r?H(`operationFailed`,n+1,QEe(r),e.message):H(`nothingSaved`,e.message)},eDe=(e,t)=>new e.constructor({...e.problem,detail:$Ee(e,t)}),B9=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),tDe=({model:e,stored:t,recordKey:n,mode:r,subject:i,draftKey:a,lines:o})=>{let s=W(),c=Km(),l=R9(e.name,n),u=R5(r,i),[d]=(0,L.useState)(()=>a?aEe(localStorage,a,t.etag):void 0),[f,p]=(0,L.useState)(d?.fields??{}),[m,h]=(0,L.useState)(!!d),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)({}),[b,x]=(0,L.useState)({}),[S,C]=(0,L.useState)(0),w=Object.entries(f).filter(([n,r])=>GS(e.fields[n],r,t.record[n])),T=w.length>0,E=T||!!o?.dirty;(0,L.useEffect)(()=>{d?.order&&o?.setOrder(d.order)},[]),(0,L.useEffect)(()=>{if(!a)return;let n=Object.fromEntries(Object.entries(f).filter(([t])=>!e.fields[t]?.sensitive)),r=Object.keys(n).length>0||!!o?.dirty;oEe(localStorage,a,r?{etag:t.etag,fields:n,...o?.order&&{order:o.order}}:void 0)},[a,e,f,o?.dirty,o?.order,t.etag]);let D=n=>n in f?f[n]:[`boolean`,`file`].includes(e.fields[n].type)?t.record[n]:zS(t.record[n]),O=(n,r)=>{x(e=>B9(e,n));let i=typeof r==`string`?r!==zS(t.record[n]):GS(e.fields[n],r,t.record[n]);p(e=>i?{...e,[n]:r}:B9(e,n))},k=async()=>{let r=await s.get(e.name,n);c.setQueryData(U.record(e.name,n),r);let i={},a={};for(let[n,o]of Object.entries(f)){let s=e.fields[n];GS(s,o,r.record[n])&&(a[n]=o,zS(r.record[n])!==zS(t.record[n])&&(i[n]=s.type===`file`?rS(s,r.record[n]):zS(r.record[n])))}p(a),y(i)},A=()=>Object.fromEntries(w.map(([t,n])=>[t,HS(e.fields[t],n)])),j=e=>{let t=AC(e);x(t),Object.keys(t).length>0&&C(e=>e+1)},M=async()=>{try{await l.mutateAsync({patch:A(),etag:t.etag})}catch(e){throw z9(e)?await k():Xs(e)&&j(e),e}},N=async r=>{let i=[...T?[{op:`update`,resource:e.name,key:n,data:A(),etag:t.etag}]:[],...r];try{await s.batchWrite(i)}catch(e){throw z9(e)?(await k(),await c.invalidateQueries({queryKey:[`list`]}),_(!0)):Xs(e)&&j(e),Xs(e)?eDe(e,i):e}await Promise.all([c.invalidateQueries({queryKey:U.record(e.name,n)}),c.invalidateQueries({queryKey:[`list`]}),c.invalidateQueries({queryKey:[`page`]}),c.invalidateQueries({queryKey:[`map`]})]),o?.reset()};return{value:D,change:O,save:()=>u.run(async()=>{let e=o?.op()??[];e.length>0?await N(e):await M(),p({}),y({}),x({}),_(!1),h(!1)}),dirty:E,discard:()=>{p({}),y({}),x({}),_(!1),h(!1),o?.reset()},restored:m&&E,dismissRestored:()=>h(!1),linesConflict:g,saving:u.phase===`saving`,phase:u.phase,message:u.message,conflicts:v,errors:b,rejections:S,keepMine:e=>y(t=>B9(t,e)),useTheirs:e=>{y(t=>B9(t,e)),p(t=>B9(t,e))}}},V9=(e,t,n,r)=>{let i=W(),a=Km(),o=Object.values(e.fields).filter(n=>n.type===`relation`&&n.relation&&n.name!==e.tenant&&r[n.name]!=null&&t[n.relation.resource]?.primaryKey.length===1),s=Wh({queries:o.map(e=>{let o=t[e.relation.resource],s=String(r[e.name]);return{queryKey:U.relatedLabel(o.name,s),queryFn:async()=>(await q0(a,i,o,[s],n[o.name])).get(s)??s}})}),c=o.map(e=>({kind:`record`,resource:e.relation.resource,key:String(r[e.name])}));return{addresses:Object.fromEntries(o.map((e,t)=>[e.name,c[t]])),labels:Object.fromEntries(o.map((e,t)=>[e.name,s[t]?.data]))}},nDe=Vn(),rDe=(e,t,n,r,i)=>{if(e.primaryKey.length!==1)return[];let a=new Set(Qn(r).flatMap(e=>e.kind===`related`&&!e.through&&!e.from?[`${e.resource}.${e.field}`]:[])),o=Object.values(t).flatMap(t=>Object.values(t.fields).filter(t=>t.type===`relation`&&t.relation?.resource===e.name&&t.relation.columns.length===1&&t.filterable).filter(e=>e.name!==t.tenant&&t.name!==i?.name&&!a.has(`${t.name}.${e.name}`)).map(e=>({source:t,field:e.name})));return o.map(({source:e,field:t})=>{let r=n[e.name],i=r?.names?.plural??q(e.name),a=o.filter(t=>t.source.name===e.name).length>1;return{resource:e.name,field:t,label:a?`${i} (${r?.fields[t]?.label??q(t)})`:i}})},iDe=(e,t)=>({kind:`list`,resource:e.resource,filter:Fn(nDe.eq(e.field,t))}),aDe=Vn(),oDe=(e,t,n)=>{let r=W(),i=Wh({queries:e.map(e=>{let i=Fn(aDe.eq(e.field,n));return{queryKey:U.list(e.resource,i,``,1,`incoming`),queryFn:async()=>{let n=await r.list(e.resource,{filter:i,pageSize:1,count:`exact`,fields:t[e.resource].primaryKey});return{count:n.totalSize??n.totalSizeEstimate,exact:n.totalSize!==void 0}}}})});return e.flatMap((e,t)=>{let n=i[t];return n.error?[]:[{relation:e,count:n.data}]})},sDe=({model:e,recordKey:t,layout:n,lines:r})=>{let{resources:i,views:a}=G(),o=oDe(rDe(e,i,a,n,r),i,t);return o.length===0?null:(0,z.jsx)(Zb,{title:L5(`relatedRecords`),children:(0,z.jsx)(`ul`,{className:`-mx-2`,children:o.map(({relation:e,count:n})=>(0,z.jsx)(`li`,{children:(0,z.jsxs)(jS,{to:iDe(e,t),className:`group flex items-center justify-between gap-3 rounded-md px-2 py-2 hover:bg-muted`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate font-medium text-primary-text`,children:e.label}),(0,z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 tabular-nums text-muted-foreground`,children:[n===void 0?(0,z.jsx)(Yu,{className:`h-4 w-6`}):`${Mf(n.count)}${n.exact?``:`+`}`,(0,z.jsx)(Di,{className:`size-4 text-faint-foreground group-hover:text-foreground`})]})]})},`${e.resource}.${e.field}`))})})},H9=Vn(),U9=(...e)=>{let t=e.filter(e=>!!e);return t.length===1?t[0]:t.map(e=>`(${e})`).join(` AND `)},cDe=(e,t)=>{let n=W(),{resources:r}=G(),i=e.through,a=i?r[i.resource]:void 0,o=i?.key??a?.primaryKey[0],s=i?U9(Fn(H9.eq(i.field,t)),i.filter):``,c=Kh({queryKey:U.list(a?.name??``,s,``,0,`related:${o}`),enabled:!!(a&&o),queryFn:async()=>{let e=await v3(n,a.name,{filter:s,fields:[o]});return[...new Set(e.items.flatMap(e=>e[o]===null||e[o]===void 0?[]:[String(e[o])]))]}});return t===null?{filter:null,isPending:!1,error:null}:i?c.data?{filter:c.data.length===0?null:U9(Fn(H9.in(e.field,c.data)),e.filter),isPending:!1,error:null}:{filter:void 0,isPending:c.isPending,error:c.error}:{filter:U9(Fn(H9.eq(e.field,t)),e.filter),isPending:!1,error:null}},lDe=()=>(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,z.jsx)(Yu,{className:`h-4 w-full`},t))}),uDe=({empty:e})=>(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:e??L5(`nothingYet`)}),dDe=({item:e,value:t,owner:n})=>{let{resources:r,views:i}=G(),a=r[e.resource],o=a&&i[a.name],s=cDe(e,t),[c,l]=C5(o,`related:${n}:${e.title}`,e.display),u=cg(e.resource),[d,f]=(0,L.useState)(!1),p=W(),m=!!(e.hideEmpty&&a&&s.filter),h=Kh({queryKey:U.count(e.resource,s.filter??``),enabled:m,queryFn:()=>PT(p,a,s.filter??``).queryFn()});if(!a||e.hideEmpty&&(s.isPending||s.filter===null||m&&(h.isPending||h.data===0)))return null;let g=mSe(e,a,r),_=e.columns??eS(a,o).filter(t=>t!==e.field),v=t=>s.isPending?(0,z.jsx)(lDe,{}):s.error?(0,z.jsx)(rC,{title:L5(`couldNotLoadRelated`),error:s.error}):s.filter===null||s.filter===void 0?(0,z.jsx)(uDe,{empty:e.empty}):t(s.filter);if(e.presentation===`cards`)return(0,z.jsx)(qb,{title:e.title,help:e.help,children:v(t=>(0,z.jsx)(f2,{model:a,view:o,filter:t,sort:e.sort??``,fields:_,actions:e.actions??[],limit:e.limit??10,display:e.display,empty:e.empty}))});let y=Qbe(e,a,u),b=(0,z.jsx)(x5,{view:o,value:c,onChange:l}),x=y?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!d&&b,(0,z.jsx)(h9,{size:`sm`,sorting:d,onChange:f})]}):b;return d&&y?(0,z.jsx)(qb,{title:e.title,help:e.help,actions:x,children:(0,z.jsx)(m9,{model:a,view:o,field:y,filter:Fn(H9.eq(e.field,t)),columns:_})}):(0,z.jsx)(qb,{title:e.title,help:e.help,actions:x,children:v(t=>(0,z.jsx)(S5,{model:a,view:o,filter:t,sort:e.sort??``,columns:_,limit:e.limit??10,display:c,empty:e.empty,opens:g},t))})},fDe=(e,t,n)=>{if(e.from===void 0)return n;let r=t[e.from];return typeof r==`boolean`?r:y5(t,e.from)??null},pDe=(e,t)=>t===e.tenant||e.primaryKey.includes(t),mDe=(e,t,n)=>{if(t&&t.layout.length>0)return t.layout;let r=Object.values(e.fields).filter(t=>!pDe(e,t.name)),i=r.filter(e=>!e.readOnly),a=(i.length>0&&!n?i:r).map(e=>e.name);return[{kind:`section`,title:L5(`details`),fields:a},...e.history?[{kind:`history`,title:L5(`history`)}]:[],...e.comments?[{kind:`comments`,title:L5(`comments`)}]:[]]},hDe=({resource:e,recordKey:t})=>{let{resources:n}=G(),r=n[e],i=p_(e,t);return r?i.isPending?(0,z.jsx)(sg,{title:L5(`loading`),children:L5(`fetching`)}):i.error?(0,z.jsx)(`div`,{className:`p-8`,children:Xs(i.error)&&i.error.status===404?(0,z.jsx)(sg,{title:H(`notFound`),children:L5(`noRecord`)}):(0,z.jsx)(rC,{title:L5(`couldNotLoad`),error:i.error})}):(0,z.jsx)(gDe,{model:r,recordKey:t,stored:i.data,preview:i.isPlaceholderData},i.isPlaceholderData?`preview`:`loaded`):(0,z.jsx)(sg,{title:H(`notFound`),children:H(`noResource`,e)})},gDe=({model:e,recordKey:t,stored:n,preview:r})=>{let i=G(),{address:a,go:o}=AS(),s=i.views[e.name],c=Ux(e,s,n.record,t),{state:l}=xf(),u=(0,L.useMemo)(()=>tEe(i.resources,e),[i.resources,e]),d=lEe(u,cEe(u,e,t).items),f=tDe({model:e,stored:n,recordKey:t,mode:s?.saveFeedback??`toast`,subject:c,draftKey:!r&&l.kind===`signed-in`?iEe(l.user.id,e.name,t):void 0,lines:d}),p=Km(),m=W(),h=MC(f.rejections),_=cg(e.name),v=U5(e),y=xT(_,`update`)&&n.permissions?.update!==!1,{shown:b,offersEdit:x,editing:S}=Soe(s?.recordMode,y,a?.kind===`record`&&a.edit===!0);Wne(f.dirty&&b===`form`),bre(f.dirty);let C=a?.kind===`record`?a.open:void 0,w=a?.kind===`record`&&a.edit===!0,T=a?.kind===`record`?a.tab:void 0,E=(n=[],r=!1,i)=>({kind:`record`,resource:e.name,key:t,...r&&{edit:r},...n.length>0&&{open:n},...i&&{tab:i}}),D=E(C,!1,T),O=E(C,!0,T),k=b===`form`&&s?.recordMode!==void 0&&s.recordMode!==`edit`,A=xT(_,`delete`)&&n.permissions?.delete!==!1,j=H5({model:e,view:s,restore:v,onDeleted:()=>o({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void p.invalidateQueries({queryKey:U.record(e.name,t)})}),M=V9(e,i.resources,i.views,n.record),N=t=>{let n=e.fields[t],r=n?.relation?i.resources[n.relation.resource]:void 0;if(r&&r.primaryKey.length===1&&t!==e.tenant&&!e.primaryKey.includes(t))return r},P=Object.values(e.fields).filter(e=>N(e.name)),ee={...n.record,...Object.fromEntries(P.map(e=>[e.name,US(e,f.value(e.name))]))},te=V9(e,i.resources,i.views,ee),ne=(e,t)=>{let n=N(e);if(!n||!XS(t))return f.change(e,t);p.setQueryData(U.relatedLabel(n.name,t.key),t.label),f.change(e,ZS(n,t.key))},{fields:re}=hC(),ie={model:e,record:n.record,key:t,etag:n.etag,permissions:n.permissions},ae=ZEe(mDe(e,s,b===`read`),ie,S,r),{before:oe,tabs:se,after:ce}=QTe(ae),le=$Te(se,T),ue=e=>S&&(f.errors[e]!==void 0||f.conflicts[e]!==void 0);(0,L.useEffect)(()=>{if(f.rejections===0)return;let e=eEe(se,le,ue);e&&o(E(C,w,e===se[0]?void 0:e.title),{replace:!0})},[f.rejections]);let F=ae.flatMap(e=>e.kind===`sidebar`?e.fields:[]),de=e.fields.status?.type===`enum`,fe=n.record.status,pe=de&&!F.includes(`status`)&&fe!=null&&fe!==``?String(fe):void 0,me=w9(e,`updated`),I=e=>s?.fields[e],he=e=>CT(n.permissions,e)!==`hidden`&&JS(I(e)?.when,S),ge=e=>!r||Object.hasOwn(n.record,e),_e=r=>{let a=e.fields[r],o=CT(n.permissions,r);if(!a||o===`hidden`)return null;let c=f.conflicts[r],l=N(r),u=I(r)?.label??q(r),d=f.errors[r];return(0,z.jsx)(Gb,{name:r,label:u,required:b===`form`&&o!==`read`&&boe(a),help:qS(I(r),s,S),error:d&&kC(a,u,d),wide:!!(I(r)?.multiline||I(r)?.markdown),conflict:c===void 0?void 0:{user:{name:L5(`someoneElse`),initials:`?`,hue:40},ago:L5(`justNow`),theirValue:c||`—`,onKeepMine:()=>f.keepMine(r),onUseTheirs:()=>f.useTheirs(r)},children:ge(r)?(0,z.jsx)(SC,{field:a,hints:I(r),value:f.value(r),stored:n.record[r],relationLabel:te.labels[r],relationTo:te.addresses[r],relationPicker:l&&{target:l,view:i.views[l.name]},locked:b!==`form`||o===`read`,invalid:!!f.errors[r],reveal:a.sensitive?()=>m.reveal(e.name,t,r):void 0,resource:e.name,onChange:e=>ne(r,e)}):(0,z.jsx)(Yu,{className:`h-9`})},a.sensitive?`${r}:${n.etag}`:r)},ve=r=>{let i=e.fields[r],a=ge(r)?i.sensitive?(0,z.jsx)(SC,{field:i,hints:I(r),value:``,stored:n.record[r],locked:!0,reveal:()=>m.reveal(e.name,t,r),resource:e.name,onChange:e=>f.change(r,e)}):(0,z.jsx)($0,{model:e,field:i,value:n.record[r],relationLabel:M.labels[r]}):(0,z.jsx)(Yu,{className:`h-4 w-32`});return{label:I(r)?.label??q(r),help:qS(I(r),s,S),wide:!!(I(r)?.multiline||I(r)?.markdown),value:a}},ye=ae.findIndex(e=>e.kind===`sidebar`),be=(0,z.jsx)(Qb,{title:L5(`summary`),rows:F.flatMap(t=>{let r=e.fields[t];if(!r||!he(t))return[];if(!ge(t))return[{label:I(t)?.label??q(t),value:(0,z.jsx)(Yu,{className:`h-4 w-24`})}];let i=n.record[t],a=zx(r,I(t))&&typeof i==`string`&&i!==``?Rx(i):rS(r,i,I(t)),o=r.type===`text`&&typeof i==`string`&&i!==``?Jx(I(t)):void 0,s=r.type===`enum`?(0,z.jsx)(Q0,{value:i,hints:I(t),children:a}):o?(0,z.jsx)(xC,{format:o,value:a}):(0,z.jsx)(`strong`,{title:iS(r,i,void 0,I(t)),children:a}),c=gC(re,r,I(t));return[{label:I(t)?.label??q(t),title:a,value:c?(0,z.jsx)(vC,{shown:c,part:`display`,field:r,value:n.record[t],fallback:s}):s}]})}),xe=async()=>{await f.save()&&k&&o(D,{replace:!0})},Se=A?()=>void j.start({key:t,title:c,etag:n.etag,snapshot:n.record}):void 0,Ce=b===`form`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(V,{variant:`primary`,className:`max-md:min-h-11 max-md:flex-1 md:w-full`,loading:f.saving,disabled:!f.dirty&&f.phase!==`saved`,onClick:()=>void xe(),children:[f.phase===`saved`&&(0,z.jsx)(xi,{className:`size-4`}),f.phase===`saved`?L5(`saved`):L5(`save`)]}),k&&(0,z.jsx)(jS,{to:D,className:g(gp(),`max-md:min-h-11 md:w-full`),onClick:e=>Xu(e)&&f.discard(),children:L5(`cancel`)}),f.dirty&&(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground max-md:order-first`,children:L5(`unsavedChanges`)})]}),we=(i,a)=>{if(i.kind===`group`){let e=i.items.flatMap(we);if(e.length===0)return[];let t=ZTe(i,C,ue),n=i.collapsed?E(XTe(C,i.title),w,T):void 0;return[(0,z.jsx)(poe,{title:i.title,open:t,toggle:n,children:e},`group:${i.title}`)]}if(i.kind===`related`)return i.from!==void 0&&!ge(i.from)?[]:[(0,z.jsx)(dDe,{item:i,value:fDe(i,n.record,t),owner:e.name},`related:${i.title}`)];if(i.kind===`chart`)return[(0,z.jsx)(qTe,{item:i,recordKey:t},`chart:${a}`)];if(r&&(i.kind===`custom`||i.kind===`map`||i.kind===`gallery`))return[];if(i.kind===`custom`)return i.sidebar?[]:[(0,z.jsx)(T9,{item:i,scope:ie},`custom:${a}`)];if(i.kind===`map`)return i.sidebar?[]:[(0,z.jsx)(E9,{item:i,record:n.record},`map:${a}`)];if(i.kind===`gallery`)return[(0,z.jsx)(EEe,{item:i,record:n.record,recordKey:t},`gallery:${a}`)];if(i.kind===`history`)return[(0,z.jsx)(NEe,{item:i,model:e,view:s,recordKey:t,etag:n.etag},`history:${a}`)];if(i.kind===`comments`)return[(0,z.jsx)(JEe,{item:i,resource:e.name,recordKey:t,canWrite:l.kind!==`visitor`},`comments:${a}`)];if(i.kind!==`section`)return[];let o=i.fields.filter(t=>e.fields[t]&&he(t)),c=b===`read`&&i.presentation===`facts`,u=c?cS(n.record,o):o;return u.length===0?[]:[(0,z.jsx)(qb,{title:i.title,help:KS(i.helpWhen,s,S)?i.help:void 0,children:c?(0,z.jsx)(hoe,{facts:u.map(e=>({label:ve(e).label,value:ve(e).value,icon:km(I(e)?.icon)}))}):b===`read`?(0,z.jsx)(NS,{rows:u.map(ve)}):(0,z.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:u.map(_e)})},i.title)]};return(0,z.jsxs)(`div`,{ref:h,className:`flex flex-1 flex-col`,inert:r,children:[j.dialogs,(0,z.jsx)(`div`,{className:`flex-1`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-[1100px] px-4 pb-8 pt-6 md:px-10 md:py-8`,children:[(0,z.jsx)($b,{title:c,status:pe?{label:ps(pe,I(`status`)?.valueLabels),tone:Qx(pe)}:void 0}),f.message&&(0,z.jsx)(`div`,{className:`mt-4`,children:(0,z.jsx)(rC,{title:L5(`notSaved`),error:Error(f.message)})}),f.linesConflict&&(0,z.jsx)(`div`,{className:`mt-4`,children:(0,z.jsx)(rC,{title:L5(`linesChanged`),error:Error(L5(`linesReloaded`))})}),b!==`form`&&x&&f.dirty&&(0,z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 rounded-lg border bg-surface px-3 py-2`,role:`status`,children:[(0,z.jsx)(`span`,{children:L5(`unsavedKept`)}),(0,z.jsxs)(`span`,{className:`flex gap-2`,children:[(0,z.jsx)(jS,{to:O,className:gp({size:`sm`}),children:L5(`continueEditing`)}),(0,z.jsx)(V,{size:`sm`,onClick:f.discard,children:L5(`discard`)})]})]}),b===`form`&&f.restored&&(0,z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 rounded-lg border bg-surface px-3 py-2`,role:`status`,children:[(0,z.jsx)(`span`,{children:L5(`unsavedRestored`)}),(0,z.jsxs)(`span`,{className:`flex gap-2`,children:[(0,z.jsx)(V,{size:`sm`,onClick:f.dismissRestored,children:L5(`keep`)}),(0,z.jsx)(V,{size:`sm`,onClick:f.discard,children:L5(`discard`)})]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,z.jsxs)(`main`,{className:`divide-y divide-border`,children:[oe.flatMap(we),le&&(0,z.jsx)(moe,{tabs:se.map((e,t)=>({title:e.title,to:E(C,w,t===0?void 0:e.title),current:e===le}))}),le&&(0,z.jsx)(`div`,{className:`divide-y divide-border`,children:le.items.flatMap(we)},`tab:${le.title}`),ce.flatMap(we),u&&!r&&(0,z.jsx)(rEe,{lines:u,draft:d,vatRate:Number(n.record.vatRate??21)/100,saving:f.saving,locked:b!==`form`})]}),(0,z.jsxs)(`aside`,{className:`space-y-4 md:pt-8`,children:[Ce&&(0,z.jsx)(`div`,{className:`hidden flex-col items-center gap-2 md:flex`,children:Ce}),!r&&(0,z.jsx)(YTe,{model:e,stored:n,recordKey:t,edit:x?O:void 0,onDelete:Se}),ye===-1&&be,ae.map((e,t)=>e.kind===`custom`&&e.sidebar&&!r?(0,z.jsx)(T9,{item:e,scope:ie},`custom:${t}`):e.kind===`map`&&e.sidebar&&!r?(0,z.jsx)(E9,{item:e,record:n.record},`map:${t}`):t===ye?(0,z.jsx)(L.Fragment,{children:be},`summary`):null),(0,z.jsx)(Qb,{title:L5(`details`),rows:[w9(e,`created`),me].flatMap(t=>{let r=t?e.fields[t]:void 0;return!t||!r||!he(t)?[]:[{label:I(t)?.label??q(t),value:ge(t)?(0,z.jsx)(`span`,{title:iS(r,n.record[t],void 0,I(t)),children:rS(r,n.record[t],I(t))}):(0,z.jsx)(Yu,{className:`h-4 w-24`})}]})}),!r&&(0,z.jsx)(sDe,{model:e,recordKey:t,layout:ae,lines:u})]})]})]})}),Ce&&(0,z.jsx)(`div`,{className:`sticky bottom-[var(--pb-sticky-bottom,0px)] z-20 flex shrink-0 items-center gap-2 border-t bg-background p-3 md:hidden`,children:Ce})]})},_De=e=>Xs(e)?e.status===401||e.status===403?H(`signInRefused`,e.message):e.message:H(`noAnswer`),vDe=({status:e})=>{let t=Km();return e.state===`error`?(0,z.jsx)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center p-8`,children:(0,z.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,z.jsx)(`h1`,{className:`text-[16px] font-semibold`,children:H(`cannotReach`,e.source.label)}),(0,z.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[_De(e.error),` `,H(`restWorks`)]}),(0,z.jsx)(V,{className:`mt-3`,onClick:()=>void t.refetchQueries({queryKey:U.sourceMetas(e.source.url)}),children:H(`tryAgain`)})]})}):(0,z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(qd,{}),` `,H(`loadingFrom`,e.source.label)]})},W9=a({en:{search:`Search`,searchOne:e=>`Search ${e}`,searchTwo:(e,t)=>`Search ${e} and ${t}`,searchMore:(e,t)=>`Search ${e}, ${t} and more`,goTo:`Go to`,create:`Create`},nl:{search:`Zoeken`,searchOne:e=>`Zoek in ${e}`,searchTwo:(e,t)=>`Zoek in ${e} en ${t}`,searchMore:(e,t)=>`Zoek in ${e}, ${t} en meer`,goTo:`Ga naar`,create:`Maken`}}),G9=(e,t)=>e.toLowerCase().includes(t.trim().toLowerCase()),yDe=(e,t,n=``)=>{let r=$7(e,n).flatMap(e=>e.items.filter(e=>e.href!==void 0&&!e.problem)).filter(e=>G9(e.label,t)).slice(0,5),i=t.trim().replace(/^new\s+/i,``),a=Object.values(e.resources).flatMap(r=>{let a=e.views[r.name];if(!a||a.nav?.hidden||!W5(a,e.pages,e.permissions[r.name]??ng))return[];let o=a.names?.singular??q(r.name),s=YS(`title`,o);return!G9(s,t)&&!G9(o,i)&&!G9(a.names?.plural??q(r.name),i)?[]:[{id:`new:${r.name}`,title:s,href:Cs({kind:`create`,resource:r.name},n)}]});return[...r.length>0?[{id:`go-to`,label:W9(`goTo`),hits:r.map(e=>({id:`go-to:${e.id}`,title:e.label,href:e.href}))}]:[],...a.length>0?[{id:`create`,label:W9(`create`),hits:a.slice(0,5)}]:[]]},bDe=Vn(),xDe=e=>Object.values(e.resources).flatMap(t=>{let n=e.views[t.name];return!t.search?.length||!n||n.nav?.hidden||e.permissions[t.name]?.read===!1?[]:[{model:t,view:n,label:n.names?.plural??q(t.name)}]}),SDe=e=>{let t=e.map(e=>e.label.toLowerCase());return t.length===0?W9(`search`):t.length===1?W9(`searchOne`,t[0]):t.length===2?W9(`searchTwo`,t[0],t[1]):W9(`searchMore`,t[0],t[1])},CDe=e=>Fn(bDe.search(e.trim())),K9=e=>{let t=e.view?.searchResult?.title;return t?.length?t:[Hx(e.model,e.view)]},q9=e=>{let t=K9(e);return e.view?.searchResult?.subtitle??e.model.search?.find(e=>!t.includes(e))},wDe=e=>{let t=q9(e),n=[...K9(e),...t?[t]:[],...e.model.search??[]];return[...new Set([...e.model.primaryKey,...n.filter(t=>Object.hasOwn(e.model.fields,t))])]},J9=(e,t,n)=>{let r=t[n];return r==null?``:e.model.fields[n]?.type===`enum`?ps(String(r),e.view?.fields[n]?.valueLabels):String(r)},TDe=(e,t,n,r=``)=>{let i=sr(Kx(e.model,t)),a=K9(e),o=q9(e),s=Nn(e.model,t,n,[...a,...o?[o]:[]])??o,c=s?J9(e,t,s):``;return{id:i,title:a.map(n=>J9(e,t,n)).filter(Boolean).join(` `)||i,...c&&{subtitle:c},href:Cs({kind:`record`,resource:e.model.name,key:i},r)}},EDe=()=>{let e=G(),t=W(),{basePath:n}=Pm(),r=(0,L.useMemo)(()=>xDe(e),[e]),[i,a]=(0,L.useState)(``),o=i.trim(),s=V3(o,200),c=o.length>=2,l=c&&s.length>=2,u=Wh({queries:r.map(e=>({queryKey:[`global-search`,e.model.name,s],enabled:l,staleTime:1/0,gcTime:0,queryFn:()=>t.list(e.model.name,{filter:CDe(s),pageSize:5,fields:wDe(e)})}))}),d=(0,L.useMemo)(()=>l?yDe(e,s,n):[],[l,e,s,n]),f=r.flatMap((e,t)=>{let r=u[t];if(!l||!r)return[];if(r.error)return[{id:e.model.name,label:e.label,hits:[],failed:!0}];let i=(r.data?.items??[]).map(t=>TDe(e,t,s,n));return i.length>0?[{id:e.model.name,label:e.label,hits:i}]:[]}),p=[...d,...f];return{available:Object.keys(e.pages).length>0||Object.keys(e.resources).length>0,placeholder:SDe(r),text:i,setText:a,query:l?s:``,loading:c&&(o!==s||u.some(e=>e.isFetching)),groups:p}},Y9=a({en:{immediate:`Updates as soon as a release is out`,weekly:`Updates at a set time every week`,scheduled:`Updates at the time set for this release`,manual:`Updates only when asked to`,job:`Preparing the update`,build:`Building`,updatingNow:`Updating now`,started:(e,t)=>`${e}, started ${t}`,nextOn:(e,t)=>`${e}: next on ${t}`,succeeded:(e,t)=>`Updated to ${e} on ${t}`,unchanged:(e,t)=>`The update to ${e} on ${t} changed nothing`,failed:(e,t)=>`The update to ${e} failed on ${t}`,alreadyLatest:`Already on the latest version, or an update is running.`,onlyAdmin:`Only an admin can update the runtime.`,couldNotStart:`The update could not be started. Try again later.`,runtimeUpdate:`Runtime update`,close:`Close`,updating:`Updating…`,updateNow:`Update now`,currentVersion:`Current version`,latestVersion:`Latest version`,checkFailed:`The status could not be checked again; this is the last one read.`,updateAvailable:`Update available`,update:`Update`},nl:{immediate:`Werkt bij zodra er een release is`,weekly:`Werkt elke week op een vast moment bij`,scheduled:`Werkt bij op het moment dat voor deze release is ingesteld`,manual:`Werkt alleen bij als erom wordt gevraagd`,job:`De update voorbereiden`,build:`Bouwen`,updatingNow:`Nu aan het bijwerken`,started:(e,t)=>`${e}, begonnen ${t}`,nextOn:(e,t)=>`${e}: volgende op ${t}`,succeeded:(e,t)=>`Bijgewerkt naar ${e} op ${t}`,unchanged:(e,t)=>`De update naar ${e} op ${t} veranderde niets`,failed:(e,t)=>`De update naar ${e} mislukte op ${t}`,alreadyLatest:`Al op de nieuwste versie, of er loopt een update.`,onlyAdmin:`Alleen een beheerder kan de runtime bijwerken.`,couldNotStart:`De update kon niet worden gestart. Probeer het later opnieuw.`,runtimeUpdate:`Runtime-update`,close:`Sluiten`,updating:`Bijwerken…`,updateNow:`Nu bijwerken`,currentVersion:`Huidige versie`,latestVersion:`Nieuwste versie`,checkFailed:`De status kon niet opnieuw worden gecontroleerd; dit is de laatst gelezen.`,updateAvailable:`Update beschikbaar`,update:`Bijwerken`}}),DDe=e=>!!(e?.updateAvailable&&e.indicator),ODe=e=>e?5e3:18e5,kDe=(e,t)=>{if(!e.updateStage)return Y9(`updatingNow`);let n=Y9(e.updateStage);return e.updateStartedAt?Y9(`started`,n,up(Math.max(0,Math.floor((t-Date.parse(e.updateStartedAt))/1e3)))):n},X9=(e,t=Date.now(),n=If())=>e.updating?kDe(e,t):e.nextUpdateAt?Y9(`nextOn`,Y9(e.policy),np(Date.parse(e.nextUpdateAt),n)):Y9(e.policy),ADe=(e,t=If())=>{let n=np(Date.parse(e.finishedAt),t),r=Y9(e.outcome,e.toVersion,n);return e.message?`${r}: ${e.message}`:`${r}.`},jDe=e=>Xs(e)&&e.status<500&&e.problem.detail?e.problem.detail:Xs(e)&&e.status===409?Y9(`alreadyLatest`):Xs(e)&&e.status===403?Y9(`onlyAdmin`):Y9(`couldNotStart`),Z9=({label:e,value:t})=>(0,z.jsxs)(`div`,{className:`flex justify-between gap-4 py-1`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,z.jsx)(`span`,{className:`font-medium tabular-nums`,children:t})]}),MDe=({status:e,requesting:t,error:n,checkError:r,onUpdate:i,onClose:a})=>{let o=e.updating?void 0:e.lastUpdate;return(0,z.jsxs)(_p,{title:Y9(`runtimeUpdate`),description:e.updating?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,z.jsx)(qd,{className:`size-3.5`}),X9(e)]}):X9(e),onClose:a,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{onClick:a,children:Y9(`close`)}),(0,z.jsx)(V,{variant:`primary`,loading:t,disabled:e.updating||!e.updateAvailable,onClick:i,children:e.updating?Y9(`updating`):Y9(`updateNow`)})]}),children:[(0,z.jsx)(Z9,{label:Y9(`currentVersion`),value:e.version}),(0,z.jsx)(Z9,{label:Y9(`latestVersion`),value:e.latest}),o&&(0,z.jsx)(`p`,{className:o.outcome===`failed`?`mt-3 text-danger-text`:`mt-3 text-muted-foreground`,children:ADe(o)}),n!==void 0&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-3 text-danger-text`,children:jDe(n)}),r!==void 0&&(0,z.jsx)(`p`,{className:`mt-3 text-muted-foreground`,children:Y9(`checkFailed`)})]})},NDe=e=>{let t=d_(),n=(0,L.useRef)(t);n.current=t;let r=t!==void 0;return(0,L.useMemo)(()=>r?Au({url:e,token:()=>n.current}):void 0,[e,r])},PDe=e=>{let[t,n]=(0,L.useState)(),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(),[s,c]=(0,L.useState)(),l=t?.updating??!1;return(0,L.useEffect)(()=>{if(!e)return;let t=!0,r=()=>e.status().then(e=>{t&&(n(e),c(void 0))},e=>t&&c(e));r();let i=setInterval(()=>void r(),ODe(l));return()=>{t=!1,clearInterval(i)}},[e,l]),{status:t,update:(0,L.useCallback)(async()=>{e&&(i(!0),o(void 0),await e.update().then(n,o),i(!1))},[e]),requesting:r,error:a,checkError:s}},Q9=({client:e})=>{let{status:t,update:n,requesting:r,error:i,checkError:a}=PDe(e),[o,s]=(0,L.useState)(!1);return!t||!o&&!DDe(t)?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(V,{size:`sm`,variant:`ghost`,"aria-label":Y9(`updateAvailable`),title:Y9(`updateAvailable`),onClick:()=>s(!0),className:`max-md:size-9 max-md:p-0`,children:[(0,z.jsx)(Vee,{className:`size-3.5 text-primary`}),(0,z.jsx)(`span`,{className:`max-md:sr-only`,children:Y9(`update`)})]}),o&&(0,z.jsx)(MDe,{status:t,requesting:r,error:i,checkError:a,onUpdate:()=>void n(),onClose:()=>s(!1)})]})},FDe=({url:e})=>(0,z.jsx)(Q9,{client:NDe(e)}),IDe=({url:e,client:t})=>t?(0,z.jsx)(Q9,{client:t}):(0,z.jsx)(FDe,{url:e}),LDe=({signIn:e,onStop:t})=>{let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(),o=async()=>{r(!0),a(void 0);try{await t()}catch(e){if(!(e instanceof Oc))throw e;a(sf(e)),r(!1)}};return(0,z.jsxs)(`div`,{role:`region`,"aria-label":H(`staffSession`),className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-warning/40 bg-warning-soft px-4 py-2 text-warning-text`,children:[(0,z.jsx)(hte,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,z.jsx)(`p`,{className:`min-w-64 flex-1 break-words`,children:gg(H(`staffSignedIn`),(0,z.jsx)(`span`,{className:`font-semibold`,children:e.staffName??e.staff}),(0,z.jsx)(`span`,{className:`font-semibold`,children:e.user}),np(Date.parse(e.expiresAt)),e.reason)}),i&&(0,z.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,z.jsx)(V,{size:`sm`,loading:n,onClick:()=>void o(),children:H(`stopStaffSession`)})]})},RDe=(e,t,n)=>({filter:n.filter??``,orderBy:n.orderBy??wS(e,t),pageSize:n.limit??3,fields:[...new Set([...e.primaryKey,Hx(e,t),n.status])]}),zDe=(e,t,n,r,i,a)=>r.map(r=>{let o=sr(Kx(e,r)),s=String(r[n.status]??``);return{id:o,label:Ux(e,t,r,o),href:Cs({kind:`record`,resource:e.name,key:o},i),status:e.fields[n.status]?.type===`enum`&&s?ps(s,t.fields[n.status]?.valueLabels):s,tone:n.tones[s]??`neutral`,pulse:n.pulse?.includes(s)??!1,active:o===a}}),BDe=(e,t,n,r,i)=>{let a=n.find(t=>sr(Kx(e,t))===r);return a!==void 0&&t.some(e=>!Object.is(a[e],i[e]))},$9=({model:e,request:t})=>U.navRecent(e.name,t.filter,t.orderBy,t.pageSize),VDe=e=>{let t=Km();(0,L.useEffect)(()=>t.getQueryCache().subscribe(n=>{if(n.type!==`updated`||n.action.type!==`success`)return;let[r,i,a]=n.query.queryKey,o=n.action.data?.record;if(r===`record`&&typeof a==`string`&&o)for(let n of e){if(n.model.name!==i)continue;let e=t.getQueryData($9(n));e&&BDe(n.model,n.request.fields,e.items,a,o)&&t.invalidateQueries({queryKey:$9(n),exact:!0})}}),[t,e])},HDe=(e,t,n)=>{let r=W(),i=(0,L.useMemo)(()=>{let t=X7(e);return Object.values(e.views).flatMap(n=>{let r=e.resources[n.resource],i=n.nav?.recent;return r&&i&&!n.nav?.hidden&&!t.has(r.name)?[{model:r,view:n,recent:i,request:RDe(r,n,i)}]:[]})},[e]);VDe(i);let a=Wh({queries:i.map(e=>({queryKey:$9(e),queryFn:()=>r.list(e.model.name,e.request)}))});return Object.fromEntries(i.map(({model:e,view:r,recent:i},o)=>{let s=a[o];if(s.isPending)return[e.name,{state:`loading`}];if(s.isError)return[e.name,{state:`error`}];let c=n.resource===e.name?n.key:void 0;return[e.name,{state:`ready`,records:zDe(e,r,i,s.data.items,t,c)}]}))},UDe=e=>e?.kind===`page`?e.page:e?.kind===`list`?Z7(e.resource,e.list):e?.resource,WDe=e=>e?.kind===`record`?e:void 0,GDe={title:`Sign in to connect an app`,description:`An app asks to act as you here. Sign in, then choose whether to allow it.`},KDe=({workspace:e,sidebarMode:t,assistant:n,runtime:r})=>{let i=G(),{state:a,session:o,signOut:s,stopStaffSession:c,organizations:l}=xf(),u=Vm();if(a.kind!==`signed-in`&&a.kind!==`visitor`)throw Error(`The shell is only rendered for a signed-in user or a visitor`);let d=a.kind===`signed-in`?a.user:void 0,f=a.kind===`signed-in`?a.staff:void 0,{path:p,params:m,basePath:h}=Pm(),{address:g,go:_,open:v}=AS(),y=UDe(g),b=WDe(g),x=EDe(),S=cw(),C=HDe(i,h,{resource:b?.resource,key:b?.key});uae(i);let w=$7(i,h,C),T=Object.keys(i.pages)[0],E=Object.keys(i.resources)[0],D=g?.kind===`page`?i.pages[g.page]:void 0;(0,L.useEffect)(()=>{p===`/`&&(T?_({kind:`page`,page:T},{replace:!0}):E&&_({kind:`list`,resource:E},{replace:!0}))},[p,T,E,_]);let O=g?.kind===`page`?void 0:g?.resource,k=O?ig(i,O):void 0,A=O?$n(i.views[O],g?.kind===`list`?g.list:void 0):void 0,j=w.find(e=>e.items.some(e=>e.id===y)),M=O?i.resources[O]:void 0,N=p_(b?.resource??``,b?.key??``,!!(M&&b)),P=M&&b&&N.data?Ux(M,A,N.data.record,b.key):void 0,ee=!!b&&(N.isLoading||k?.state===`loading`),{shell:te}=hC(),ne=te?.actions,re=te?.rightPanel,[ie,ae]=(0,L.useState)(!1),oe=i.assistant?.url,se=oe&&(0,z.jsx)(Ww,{open:ie,onToggle:()=>ae(!ie)}),ce=oe&&ie&&(0,z.jsx)(qw,{url:oe,client:n,page:m.size>0?`${p}?${m}`:p,onClose:()=>ae(!1)}),le=i.errorReporting;(0,L.useEffect)(()=>{le&&Hie(le)},[le]);let ue=i.runtime?.url,F=ue&&(0,z.jsx)(IDe,{url:ue,client:r}),de=FTe((0,L.useCallback)(()=>v9(h),[h]),!!d),fe=d&&PTe(d,de.current),pe=fe?l_(fe):!1,me=LTe(),I=wTe(!!(l&&d)),he=I.current,ge=!!l&&he!==void 0&&!he.organization,_e=l&&d?zie(p):void 0,ve=p===`/-/connect`?`Connect an app`:d?p===`/-/account`?H(`signInSecurity`):p===`/-/sign-in-policy`?H(`signInPolicy`):_e:void 0,ye=A?.names?.plural??(O&&q(O)),be=ve?[ve]:$w({basePath:h,address:g,group:j?.label,page:D,resourceLabel:ye,recordTitle:P,recordLoading:ee});nC(Doe(Eoe({address:g,page:D,accountPage:ve,resourceLabel:ye,singular:A?.names?.singular??(O&&q(O)),recordTitle:P,recordLoading:ee}),i.appName));let xe=p===`/-/connect`?d?(0,z.jsx)(qre,{email:d.email,appName:i.appName??`this app`}):(0,z.jsx)(Wm,{as:`page`,prompt:GDe}):d&&p===`/-/account`?(0,z.jsx)(Dm,{email:d.email}):d&&p===`/-/sign-in-policy`?pe?(0,z.jsx)(nie,{}):(0,z.jsx)(sg,{title:H(`adminsOnly`),children:H(`onlyAdminPolicy`)}):_e&&p===`/-/organization`?(0,z.jsx)(kTe,{current:he,basePath:h,onChanged:I.reload}):_e&&(p===`/-/organization/members`||p===`/-/organization/invitations`)?Og(he)?p===`/-/organization/members`?(0,z.jsx)(bTe,{current:he}):(0,z.jsx)(CTe,{current:he}):(0,z.jsx)(sg,{title:H(`ownersOnly`),children:H(`onlyOwners`)}):_e&&p===`/-/organizations`||ge?(0,z.jsx)(NTe,{state:I,basePath:h}):g?g.kind===`page`?D?(0,z.jsx)(I5,{name:D.name},D.name):(0,z.jsx)(sg,{title:H(`notFound`),children:gg(H(`noPage`),g.page)}):k&&k.state!==`ready`?(0,z.jsx)(vDe,{status:k}):g.kind===`create`?(0,z.jsx)(FSe,{resource:g.resource,values:g.values},g.resource):g.kind===`record`?(0,z.jsx)(hDe,{resource:g.resource,recordKey:g.key},`${g.resource}/${g.key}`):(0,z.jsx)(vTe,{address:g},Z7(g.resource,g.list)):p===`/`?(0,z.jsx)(sg,{title:H(`chooseResource`),children:H(`pickFromSidebar`)}):(0,z.jsx)(sg,{title:H(`notFound`),children:H(`nothingHere`)}),Se=(0,z.jsx)($d,{pageScroll:!0,sidebarMode:t??`text-small`,activeItem:y??``,breadcrumb:be,user:fe&&u_(fe),onSignOut:d&&(()=>void s()),signIn:d?void 0:u.link(),workspace:he?.organization?.name??e,appName:i.appName,appIcon:i.appIcon,logo:ITe,navGroups:w,bottomBar:Qw(i,h,y),userMenu:[...Hwe(i,h,y),...l&&d?Bie(h,p,he):[],...d?yte(h,p,pe):[]],organizations:l&&{...he?.organization&&{current:{id:he.organization.id,name:he.organization.name}},others:I.organizations.filter(e=>e.id!==he?.organization?.id),onSwitch:e=>void o.organizations.switchTo(e).then(()=>v9(h))},theme:{preference:S.preference,onChange:S.choose},roles:de.current?.active?{active:de.current.active,roles:de.current.roles,onSwitch:de.switchTo}:void 0,onNavigate:v,search:x.available?{placeholder:x.placeholder,text:x.text,onTextChange:x.setText,query:x.query,loading:x.loading,groups:x.groups,onSelect:v}:void 0,actions:(ne||F||se)&&(0,z.jsxs)(z.Fragment,{children:[ne&&(0,z.jsx)(Lg,{name:`shell.actions`,fallback:null,children:(0,z.jsx)(ne,{})}),F,se]}),rightPanel:(re||ce)&&(0,z.jsxs)(z.Fragment,{children:[re&&(0,z.jsx)(Lg,{name:`shell.rightPanel`,fallback:null,children:(0,z.jsx)(re,{})}),ce]}),children:xe}),Ce=pe&&me.length>0;return!f&&!Ce?Se:(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[f&&(0,z.jsx)(LDe,{signIn:f,onStop:c}),Ce&&(0,z.jsx)(zTe,{off:me}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1`,children:Se})]})},qDe=({baseUrl:e,client:t,sources:n,workspace:r,sidebarMode:i,ui:a,assistant:o,runtime:s})=>{let{state:c,session:l,markSignedOut:u}=xf();return(0,z.jsx)(eg,{baseUrl:e,client:t,sources:n,token:c.kind===`visitor`?void 0:l.token,onUnauthenticated:u,children:(0,z.jsx)(Are,{children:(0,z.jsx)(Ub,{children:(0,z.jsx)(RTe,{ui:a,children:(0,z.jsx)(KDe,{workspace:r,sidebarMode:i,assistant:o,runtime:s})})})})})},JDe=({baseUrl:e,client:t,ui:n,children:r})=>{let i=QC();return i?(0,z.jsx)(eg,{baseUrl:e,client:t,children:(0,z.jsx)(mC.Provider,{value:n??{},children:(0,z.jsx)(XC,{name:i.name},i.name)})}):r},YDe=({auth:e,workspace:t,basePath:n,initialUrl:r,pluginLoader:i,locale:a,...s})=>(o(a??`en`),(0,z.jsx)(sw,{children:(0,z.jsx)(Sf,{session:e,...s.baseUrl&&{origin:new URL(s.baseUrl,window.location.href).origin},children:(0,z.jsx)(Hne,{basePath:n,initialUrl:r,children:(0,z.jsx)(rae,{...i&&{loader:i},children:(0,z.jsx)(cae,{children:(0,z.jsx)(JDe,{baseUrl:s.baseUrl,client:s.client,ui:s.ui,children:(0,z.jsx)(i_,{workspace:t,children:(0,z.jsx)(qDe,{workspace:t,...s})})})})})})})}));export{rg as $,uw as A,qb as B,ww as C,vw as D,yw as E,uC as F,Zg as G,f_ as H,sC as I,Rg as J,Yie as K,oC as L,yC as M,Woe as N,hw as O,Uoe as P,G as Q,jS as R,Dw as S,Sw as T,d_ as U,Gb as V,Xg as W,mg as X,hg as Y,pg as Z,Hw as _,nd as _t,f5 as a,lh as at,Fw as b,Gxe as c,Mm as ct,XT as d,V as dt,eg as et,QT as f,gp as ft,Uw as g,Ud as gt,uT as h,Wd as ht,z5 as i,Kh as it,lw as j,fw as k,k3 as l,Mp as lt,bT as m,qd as mt,z9 as n,$h as nt,iSe as o,Km as ot,ZT as p,Df as pt,Ug as q,R9 as r,U as rt,Wxe as s,Wm as st,YDe as t,W as tt,q0 as u,_p as ut,Bw as v,Cw as w,Aw as x,zw as y,AS as z};
|
|
70
|
-
//# debugId=
|
|
70
|
+
//# debugId=428258ed-478a-43fe-b3b3-c97ea0292d85
|