@protobase/ui 0.28.2 → 0.28.4
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/account/messages.js +2 -2
- package/dist/package.js +1 -1
- package/dist/shell/assets/{app-CT9B90lM.js → app-CWIfBu7a.js} +4 -4
- package/dist/shell/assets/{index-Dl_cjkSq.js → index-DzdI6MZa.js} +1 -1
- package/dist/shell/assets/{records-map-B0KTc5ES.js → records-map-XhlRSjHH.js} +1 -1
- package/dist/shell/assets/{shared-protobase-ui-B3__v-fO.js → shared-protobase-ui-DrMFi4tl.js} +1 -1
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +1 -1
- package/dist/shell/protobase.sw.js +2 -2
- 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-XhlRSjHH.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,ee=(e,t,n)=>(e.lastIndex=n,e.exec(t)?.[0]),te=(e,t,n,r)=>{let i=ee(k,e,t);if(i&&w(i))return{kind:`timestamp`,end:t+i.length};if(i||ee(A,e,t)){let n=t+(ee(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=ee(M,e,t);if(a)return n(e[t+a.length])?{kind:`number`,end:t+a.length}:void 0;let o=t+ee(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},ne={a:`\x07`,b:`\b`,f:`\f`,n:`
|
|
3
3
|
`,r:`\r`,t:` `,v:`\v`,"'":`'`,'"':`"`,"\\":`\\`,"?":`?`,"`":"`"},re=(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},ie=(e,t)=>{let n=e[t+1];if(n===void 0)return{error:`a backslash at the end`,end:t+1};if(Object.hasOwn(ne,n))return{text:ne[n],end:t+2};let r={x:2,u:4,U:8};if(Object.hasOwn(r,n)){let i=re(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}},ae=(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=ie(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}},oe={"(":`lparen`,")":`rparen`,",":`comma`,".":`dot`,":":`has`,"=":`eq`,"<":`lt`,">":`gt`,"-":`minus`},se={AND:`and`,OR:`or`,NOT:`not`},ce=e=>{let[t,n,r]=[e.at(-1),e.at(-2),e.at(-3)];return t?.kind===`rparen`&&n?.kind===`lparen`&&r?.text===`now`},le=(e,t={})=>{let n=[],r=[],i=e=>e!==void 0&&(e in oe||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=ae(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=te(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(oe,i)){o(oe[i],c,c+1),c++;continue}let s=t.arithmetic===`now-offset`&&ce(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(se,u)?se[u]:`text`,c,l),c=l}return o(`eof`,e.length,e.length),{tokens:n,errors:r}},ue=class extends Error{error;constructor(e){super(e.message),this.error=e}},de=(e,t,n,r)=>{throw new ue(v(e,t,n,r))},P=(e,t=0)=>e.tokens[Math.min(e.pos+t,e.tokens.length-1)],fe=e=>{let t=P(e);return t.kind!==`eof`&&e.pos++,t},pe=(e,t)=>P(e).kind===t?fe(e):void 0,me=e=>e.kind===`eof`?`end of input`:`"${e.text}"`,he=(e,t,n,r)=>pe(e,t)??de(`expected-token`,`Expected ${n} but found ${me(P(e))}`,r,P(e).span),F=(e,t,n)=>{e.depth>=e.maxDepth&&de(`too-deep`,`The filter is nested too deeply`,`Nest at most ${e.maxDepth} levels`,t),e.depth++;try{return n()}finally{e.depth--}},ge=[`text`,`and`,`or`,`not`],_e=e=>{let t=he(e,`text`,`a field name or value`,`Text may not contain spaces or the characters ( ) - . = : < > ! ,`),n=[t.text],r=t.span;for(;P(e).kind===`dot`;){let t=P(e,1),i=t.kind===`number`&&/^\d+(\.\d+)?$/.test(t.text);!ge.includes(t.kind)&&!i&&de(`expected-token`,`Expected a field name after "." but found ${me(t)}`,`Write traversals like customer.country`,t.span),fe(e),fe(e),n.push(...i?t.text.split(`.`):[t.text]),r=x(r,t.span)}return{kind:`member`,path:n,span:r}},ve=e=>({kind:`duration`,amount:Number(e.text.slice(0,-1)),unit:e.text.slice(-1),span:e.span}),ye=[`member`,`string`,`number`,`boolean`,`duration`,`timestamp`,`call`,`binary`],be=e=>ye.includes(e.kind),xe=(e,t,n)=>F(e,n,()=>{fe(e);let r=[];if(P(e).kind!==`rparen`)do r.push(Ee(e));while(pe(e,`comma`));return{kind:`call`,name:t,args:r,span:x(n,he(e,`rparen`,`")"`,`Close the call to ${t}() with ")"`).span)}}),Se=e=>{let t=P(e);switch(t.kind){case`string`:return fe(e),{kind:`string`,value:t.value,span:t.span};case`number`:return fe(e),{kind:`number`,value:Number(t.text),raw:t.text,span:t.span};case`duration`:return fe(e),ve(t);case`timestamp`:return fe(e),{kind:`timestamp`,value:t.text,span:t.span};case`minus`:{let n=P(e,1);(n.kind!==`number`||n.span.start!==t.span.end)&&de(`unexpected-token`,`Expected a number after "-" but found ${me(n)}`,`Write negative numbers as -5, without a space`,n.span),fe(e),fe(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`)&&P(e,1).kind!==`dot`&&(P(e,1).kind!==`lparen`||P(e,1).span.start!==t.span.end))return fe(e),{kind:`boolean`,value:t.text===`true`,span:t.span};let n=_e(e);return P(e).kind===`lparen`&&P(e).span.start===n.span.end?xe(e,n.path.join(`.`),n.span):n}default:return de(`unexpected-token`,`Expected a value but found ${me(t)}`,`Values are text, "strings", numbers, true/false, durations, timestamps or function calls`,t.span)}},Ce=e=>{let t=fe(e);return F(e,t.span,()=>{let n=e.expression(e);return he(e,`rparen`,`")"`,`Close the group opened here`),n?n.kind===`global`?n.value:n:de(`unexpected-token`,`Empty group`,`Put an expression inside the parentheses`,t.span)})},we=e=>P(e).kind===`lparen`?Ce(e):Se(e),Te=e=>[`text`,`string`,`number`,`duration`,`timestamp`,`lparen`,`minus`].includes(P(e,1).kind),Ee=e=>{let t=we(e);if(!e.extensions.arithmetic||!be(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()&&P(e,1).kind===`duration`;if(r&&i()&&(P(e).kind===`plus`||P(e).kind===`minus`)&&P(e,1).kind!==`duration`)return de(`expected-token`,`Expected a duration after "${P(e).text}" but found ${me(P(e,1))}`,`Durations need a unit, for example now() - 30d`,P(e,1).span);for(;(P(e).kind===`plus`||P(e).kind===`minus`)&&Te(e)&&a();){let t=fe(e).kind===`plus`?`+`:`-`,r=we(e);if(!be(r))return de(`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},De=e=>{let t=P(e),n=Ee(e);return be(n)||de(`unexpected-token`,`A comparison needs a value on the right`,`Write field = value`,t.span),n},Oe={eq:`=`,ne:`!=`,lt:`<`,le:`<=`,gt:`>`,ge:`>=`},ke=[`text`,`string`,`number`,`duration`,`timestamp`,`not`,`minus`,`lparen`],Ae=(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)}},je=e=>{let t=0;for(;;){let{kind:n}=P(e);if(n===`eof`||t===0&&(n===`and`||n===`or`||n===`rparen`))return;n===`lparen`&&t++,n===`rparen`&&t--,fe(e)}},Me=e=>{let t=Se(e),n=P(e);if(n.kind===`has`){fe(e);let n=P(e);if(n.kind===`text`&&n.text===`*`)return fe(e),{kind:`present`,left:t,span:x(t.span,n.span)};let r=De(e);return{kind:`has`,left:t,right:r,span:x(t.span,r.span)}}let r=Oe[n.kind];if(r){fe(e);let n=De(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}},Ne=e=>{let t=P(e);return t.kind===`lparen`?(fe(e),F(e,t.span,()=>{let n=Re(e);return pe(e,`rparen`)||e.errors.push(v(`expected-token`,`Expected ")" but found ${me(P(e))}`,`Close the group opened here`,t.span)),n})):Me(e)},Pe=e=>{let t=P(e);if(t.kind!==`not`&&t.kind!==`minus`)return ke.includes(t.kind)?F(e,t.span,()=>Ne(e)):de(`unexpected-token`,`Unexpected ${me(t)}`,`Expected a field, a value or "("`,t.span);fe(e);let n=P(e),r=n.kind===`minus`&&P(e,1).kind===`number`&&P(e,1).span.start===n.span.end;(n.kind===`not`||n.kind===`minus`&&!r)&&de(`unexpected-token`,`Negations cannot be stacked`,`Group the inner one: NOT (NOT a)`,n.span);let i=F(e,t.span,()=>Ne(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}},Fe=e=>{try{return Pe(e)}catch(t){if(!(t instanceof ue))throw t;e.errors.push(t.error),je(e);return}},Ie=e=>{let t=[Fe(e)];for(;pe(e,`or`);)t.push(Fe(e));return Ae(`or`,t)},Le=e=>{let t=[Ie(e)];for(;ke.includes(P(e).kind);)t.push(Ie(e));return Ae(`sequence`,t)},Re=e=>{let t=[Le(e)];for(;pe(e,`and`);)t.push(Le(e));return Ae(`and`,t)},ze=(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=le(e,r),a={tokens:i.tokens,pos:0,errors:i.errors,depth:0,maxDepth:t.maxDepth??64,extensions:r,expression:Re},o=[];for(;P(a).kind!==`eof`;){if(P(a).kind===`rparen`){let e=fe(a);a.errors.push(v(`unexpected-token`,`Unmatched ")"`,`Remove it or add a matching "("`,e.span));continue}o.push(Re(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}},Be=(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]}},Ve=(e,t)=>{let n=t.path[0],r=Be(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}}},He=(e,t)=>({message:e,hint:t}),Ue=(e,t)=>He(`Expected ${e}`,t),We=e=>e.kind===`string`?e.value:e.kind===`member`?e.path.join(`.`):void 0,Ge={integer:/^-?(\d+|0[xX][0-9a-fA-F]+)$/,number:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$|^-?0[xX][0-9a-fA-F]+$/},Ke=(e,t)=>e===t||e===`any`||t===`any`||[`integer`,`number`].includes(e)&&[`integer`,`number`].includes(t),qe=(e,t,n)=>{let r=We(n);switch(e){case`any`:return;case`string`:return r===void 0?Ue(`a string`,`Quote text values: "..."`):void 0;case`enum`:return r!==void 0&&t?.values?.includes(r)?void 0:He(`Invalid enum value`,`Allowed values: ${(t?.values??[]).join(`, `)}`);case`integer`:case`number`:{let t=n.kind===`number`?n.raw:r;return t!==void 0&&Ge[e].test(t)?void 0:Ue(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:Ue(`true or false`,`Write true or false`);case`timestamp`:return n.kind===`timestamp`||r!==void 0&&w(r)?void 0:Ue(`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:Ue(`a duration`,`Use a number with a unit, for example 20s or 1.5s`);case`map`:case`message`:return He(`${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=Ve(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`)?Ke(t.type,i.type)?void 0:{message:`Expected ${t.type}`,hint:`Argument "${t.name}" is ${i.type}`}:qe(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},Je=(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`},Ye=(e,t)=>{switch(t.kind){case`call`:{let n=Je(e,t,Ye);return n&&{node:n.call,type:n.returns}}case`binary`:{let n=Ye(e,t.left),r=Ye(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}}},Xe=[`string`,`integer`,`number`,`timestamp`,`duration`,`any`],Ze=(e,t)=>{if(t.kind===`member`){let n=Ve(e,t);return n&&{node:n,type:n.field.spec.type,spec:n.field.spec}}let n=Ye(e,t);return n&&{...n,spec:void 0}},Qe=(e,t,n,r)=>{e.errors.push(v(`operator-not-allowed`,t,n,r.span))},$e=(e,t,n)=>{if(!t.type)return Ye(e,n)?.node;let r=Ye(e,n);if(!r)return;let i=r.type&&(n.kind===`call`||n.kind===`binary`)?Ke(t.type,r.type)?void 0:{message:`Expected ${t.type} but got ${r.type}`,hint:`Compare values of the same type`}:qe(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=Ze(e,t.left);if(!n)return;let r=n.type;if(n.spec?.repeated)return Qe(e,`"${t.op}" is not supported on repeated fields`,`Use field:value to test membership`,t);if(r===`map`||r===`message`)return Qe(e,`${r} fields cannot be compared`,`Use field:key, or compare a nested field`,t);if(r&&![`=`,`!=`].includes(t.op)&&!Xe.includes(r))return Qe(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:$e(e,n,t.right);return a&&{...t,left:n.node,right:a}},aee=(e,t)=>{let n=Ze(e,t.left);if(!n)return;let{type:r,spec:i}=n,a=$e(e,!i?.repeated&&(r===`map`||r===`message`)?{...n,type:`string`}:n,t.right);return a&&{...t,left:n.node,right:a}},et=(e,t)=>{switch(t.kind){case`sequence`:case`and`:case`or`:{let n=t.args.map(t=>et(e,t));return n.every(e=>e)?{...t,args:n}:void 0}case`not`:{let n=et(e,t.arg);return n&&{...t,arg:n}}case`compare`:return iee(e,t);case`has`:return aee(e,t);case`present`:{let n=Ze(e,t.left);return n&&{...t,left:n.node}}case`global`:return t;case`call`:{let n=Je(e,t,Ye);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}}},tt=(e,t)=>{let n={schema:t,errors:[]},r=et(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}},oee={"\\":`\\\\`,'"':`\\"`,"\n":`\\n`,"\r":`\\r`," ":`\\t`,"\x07":`\\a`,"\b":`\\b`,"\f":`\\f`,"\v":`\\v`},see=e=>{if(!e.isWellFormed())throw Error(`Strings with unpaired surrogates cannot be printed`);return`"${e.replace(/[\\"\u0000-\u001f\u007f-\u009f]/g,e=>oee[e]??`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}"`},cee=e=>{switch(e.kind){case`string`:return see(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}},lee=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 cee(e)}},rt=e=>uee(e)?`(${st(e)})`:nt(e),it=[`member`,`string`,`number`,`boolean`,`duration`,`timestamp`,`binary`],uee=e=>!it.includes(e.kind)&&e.kind!==`call`,at=e=>{if(lee(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)},dee=(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 dee(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)),fee=(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},pee=(e,t)=>{let n=fee(e.left,Nt(e.right,t)),r=Pt(e.left,t);return e.op===`!=`?!Ft(`=`,r,n):Ft(e.op,r,n)},mee=(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 pee(e,t);case`has`:return mee(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}),hee=(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]},gee=(e,t)=>{let n=e.toLowerCase(),r=t.map(e=>({candidate:e,score:hee(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`}},_ee={extensions:{arithmetic:`now-offset`,durationUnits:!0}},Bt=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`}},Vt=e=>({fields:Object.fromEntries(Object.values(e.fields).map(e=>[e.name,{type:Bt(e),filterable:e.filterable,sortable:e.sortable,aliases:e.aliases,...e.enumValues&&{values:e.enumValues}}])),functions:zt}),Ht=(e,t,n,r)=>{e.errors.push(Rt(`unsupported`,t,n,r))},Ut=(e,t)=>t.kind===`member`?{kind:`field`,path:t.path,span:t.span}:Ht(e,`Only fields can be compared`,`Put a field name on the left, for example total > 100`,t.span),Wt=(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}:Ht(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}:Ht(e,`Arithmetic is only supported as now() +/- duration`,`Write now() - 30d`,t.span)}default:return t}},Gt=(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}:Ht(e,`Expected a literal value`,`Use strings, numbers, true/false, durations or timestamps`,t.span)),Kt=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``}},qt=(e,t)=>{let[n,r,...i]=t.args,a=n?.kind===`member`?Ut(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=>Gt(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}},vee=e=>e.every(e=>e)?e:void 0,Jt=(e,t)=>{switch(t.kind){case`sequence`:case`and`:case`or`:{let n=vee(t.args.map(t=>Jt(e,t)));return n&&{kind:t.kind===`or`?`or`:`and`,args:n,span:t.span}}case`not`:{let n=Jt(e,t.arg);return n&&{kind:`not`,arg:n,span:t.span}}case`compare`:{let n=Ut(e,t.left),r=Wt(e,t.right);return n&&r&&{kind:`compare`,op:t.op,field:n,value:r,span:t.span}}case`has`:{let n=Ut(e,t.left),r=Gt(e,t.right);return n&&r&&{kind:`has`,field:n,value:r,span:t.span}}case`present`:{let n=Ut(e,t.left);return n&&{kind:`present`,field:n,span:t.span}}case`global`:return{kind:`search`,text:Kt(t.value),span:t.span};case`call`:return qt(e,t)}},Yt=(e,t={})=>{let n=ze(e,{..._ee,...t}),r={errors:[]},i=n.ast&&Jt(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}},yee=(e,t)=>t===2?e%4==0&&(e%100!=0||e%400==0)?29:28:[4,6,9,11].includes(t)?30:31,Xt=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<=yee(n,r)},bee=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 Xt(t[1])&&n<=23&&r<=59&&i<=59&&a<=23&&o<=59},Zt=(e,t)=>({message:e,hint:t}),xee=-(2n**63n),See=2n**63n-1n,Cee=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Qt=e=>e.kind===`number`?e.raw:e.kind===`string`?e.value:void 0,$t=(e,t=`Write ${e} values like the examples in the docs`)=>Zt(`Expected ${e}`,t),wee=e=>{let t=Qt(e),n=t===void 0?NaN:Number(t);if(t===void 0||t.trim()===``||!Number.isSafeInteger(n))return $t(`a whole number`,`Use an integer such as 42, or a bigint field for larger values`)},en=e=>{let t=Qt(e);if(t===void 0||!/^-?\d+$/.test(t)||BigInt(t)<xee||BigInt(t)>See)return $t(`a 64-bit integer`,`Use plain digits such as 9007199254740993 (no exponent or fraction)`)},tn=e=>{let t=Qt(e);if(t===void 0||!/^-?\d+(\.\d+)?$/.test(t))return $t(`a decimal number`,`Use plain digits such as 100.50, or quote it: "100.50" (no exponent)`)},nn=(e,t)=>{if(t.kind===`now`)return e.type===`date`||e.type===`timestamp`?void 0:Zt(`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:$t(`a quoted string`,`Wrap the text in double quotes`);case`integer`:return wee(t);case`bigint`:return en(t);case`decimal`:return tn(t);case`boolean`:return t.kind===`boolean`?void 0:$t(`true or false`);case`date`:return t.kind===`string`&&Xt(t.value)?void 0:$t(`a date`,`Quote a calendar date: "2012-04-21"`);case`timestamp`:return t.kind===`timestamp`||t.kind===`string`&&bee(t.value)?void 0:$t(`an RFC-3339 timestamp`,`Use 2012-04-21T11:30:00Z, or now() - 7d`);case`uuid`:return t.kind===`string`&&Cee.test(t.value)?void 0:$t(`a uuid`,`Quote a uuid like "0b5a4f0e-6f2a-4a3c-9d4e-1f2a3b4c5d6e"`);case`enum`:return t.kind===`string`&&e.enumValues?.includes(t.value)?void 0:Zt(`Invalid enum value`,`Allowed values: ${(e.enumValues??[]).join(`, `)}`);case`currency`:return t.kind===`string`&&/^[A-Z]{3}$/.test(t.value)?void 0:$t(`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:$t(`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:$t(`a record key`,`Use the related record key: 42 or "abc"`);case`json`:case`file`:return Zt(`${e.type} fields cannot be compared`,`Use field:value on json fields, or isNull(field)`)}},rn=(e,t)=>Object.hasOwn(e.fields,t)?e.fields[t]:Object.values(e.fields).find(e=>e.aliases.includes(t)),an=(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=rn(e.model,r);if(!i){let i=Object.values(e.model.fields).filter(e=>e[n]).map(e=>e.name),a=gee(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},on=[`=`,`!=`],sn=[`=`,`!=`,`<`,`<=`,`>`,`>=`],cn=e=>{switch(e){case`text`:case`integer`:case`bigint`:case`decimal`:case`date`:case`timestamp`:return sn;case`json`:case`file`:return[];default:return on}},ln=e=>e===`json`||e===`file`,un=(e,t,n)=>{let r=nn(t,n);return r&&e.errors.push(Rt(`invalid-value`,r.message,r.hint,n.span)),!r},dn=(e,t,n,r)=>{e.errors.push(Rt(`operator-not-allowed`,t,n,r))},fn=(e,t)=>(e===`=`||e===`!=`)&&t.kind===`string`&&t.value.includes(`*`),pn=(e,t)=>{let n=an(e,t.field,`filterable`);if(!n)return;let r=cn(n.type);if(!r.includes(t.op)){dn(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(fn(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(fn(t.op,t.value)||un(e,n,t.value))return{...t,field:n}},mn=(e,t)=>{let n=an(e,t.field,`filterable`);if(n){if(n.type!==`json`){dn(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}}},hn=(e,t)=>{let n=an(e,t.field,`filterable`);if(n){if(ln(n.type)){dn(e,`in() is not supported for ${n.type} fields`,`Use field:value on json fields`,t.span);return}return t.values.map(t=>un(e,n,t)).every(Boolean)?{...t,field:n}:void 0}},gn=(e,t,n)=>{let r=an(e,n,`filterable`);if(r&&r.type!==`text`){dn(e,`${t}() only works on text fields, not ${r.type}`,`Field "${r.name}" is ${r.type}`,n.span);return}return r},_n=(e,t)=>{switch(t.kind){case`and`:case`or`:{let n=t.args.map(t=>_n(e,t));return n.every(e=>e)?{...t,args:n}:void 0}case`not`:{let n=_n(e,t.arg);return n&&{...t,arg:n}}case`compare`:return pn(e,t);case`has`:return mn(e,t);case`in`:return hn(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=an(e,t.field,`filterable`);return n&&{...t,field:n}}case`similar`:case`regex`:{let n=gn(e,t.kind,t.field);return n&&{...t,field:n}}}},vn=(e,t)=>{let n={model:e,errors:[]},r=_n(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}},yn=(e,t)=>`path`in e?{kind:`member`,path:e.path,span:e.span}:{kind:`member`,path:[e.name],field:{name:e.name,spec:{type:Bt(e)}},span:t},bn=(e,t,n)=>({kind:`call`,name:e,args:t,span:n}),xn=(e,t)=>({kind:`string`,value:e,span:t}),Sn=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},Cn=(e,t={})=>{let n=e=>Cn(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:yn(e.field,e.span),right:Sn(e.value),span:e.span};case`has`:return{kind:`has`,left:yn(e.field,e.span),right:e.value,span:e.span};case`present`:return{kind:`present`,left:yn(e.field,e.span),span:e.span};case`in`:return t.expand?{kind:`or`,args:e.values.map(t=>({kind:`compare`,op:`=`,left:yn(e.field,e.span),right:t,span:e.span})),span:e.span}:bn(`in`,[yn(e.field,e.span),...e.values],e.span);case`search`:return bn(`search`,[xn(e.text,e.span)],e.span);case`similar`:return bn(`similar`,[yn(e.field,e.span),xn(e.text,e.span)],e.span);case`regex`:return bn(`regex`,[yn(e.field,e.span),xn(e.pattern,e.span)],e.span);case`isNull`:return t.expand?{kind:`not`,arg:{kind:`present`,left:yn(e.field,e.span),span:e.span},span:e.span}:bn(`isNull`,[yn(e.field,e.span)],e.span)}},wn=(e,t)=>{let n=vn(e,t);if(!n.ok&&n.errors.some(e=>e.code===`unsupported-traversal`))return n;let r=tt(Cn(t),Vt(e));return r.ok?vn(e,t):{ok:!1,errors:r.errors}},Tn=/^[\d\s+\-().\/]+$/,En=e=>Tn.test(e)?e.replace(/\D/g,``):``,Dn=e=>{let t=e.split(/\s+/).filter(Boolean).map(e=>({text:e,digits:En(e),whole:!1})),n=t.length>1?En(e.trim()):``;return n?[{text:e.trim(),digits:n,whole:!0},...t]:t},On=(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()),kn=(e,t,n)=>(e.search??[]).filter(r=>On(t[r],n,e.searchMatch?.[r])),An=(e,t,n)=>{let r=Dn(n),i=r.filter(e=>!e.whole),a=r.find(e=>e.whole);return a&&kn(e,t,a).length>0?!0:i.length>0&&i.every(n=>kn(e,t,n).length>0)},jn=(e,t,n,r)=>{for(let i of Dn(n)){let n=kn(e,t,i);if(n.length>0&&!n.some(e=>r.includes(e)))return n[0]}},Mn=e=>()=>{throw Error(`Not implemented: ${e}() needs the database (the resource's search fields, trigram matching), so it cannot be evaluated against a record`)},Nn=(e,t,n)=>({...zt,search:{...zt.search,evaluate:n?e=>An(n,t,e):Mn(`search`)},similar:{...zt.similar,evaluate:Mn(`similar`)},regex:{...zt.regex,evaluate:(e,t)=>e.some(e=>typeof e==`string`&&new RegExp(t).test(e))},now:{...zt.now,evaluate:e}}),Pn=(e,t,n={})=>Lt(Cn(e,{expand:!0}),t,{functions:Nn(n.now??(()=>new Date),t,n.search)}),Fn=e=>st(Cn(e)),In=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},Ln=e=>{let t=In(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}},Rn=(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]}},Tee=(e,t)=>{let n=[],r=[];for(let i of e){let e=Rn(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?Rn(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?Rn(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}},Eee=e=>e.map(e=>({path:e.path.path,direction:e.direction,span:e.span})),Dee=e=>e.replace(/([^\s,])(\s+)(asc|desc)(?=\s|,|$)/gi,(e,t,n,r)=>`${t}${n}${r.toLowerCase()}`),Oee=e=>{let t=Ln(Dee(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}},kee=(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=Tee(Eee(t),Vt(e));return r.ok?{ok:!0,sort:r.items.map(e=>[e.path[0],e.direction])}:{ok:!1,errors:r.errors}},Aee=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}}},zn={start:0,end:0},Bn=e=>({kind:`field`,path:e.split(`.`),span:zn}),Vn=e=>{if(typeof e==`string`)return{kind:`string`,value:e,span:zn};if(typeof e==`boolean`)return{kind:`boolean`,value:e,span:zn};if(!Number.isFinite(e))throw Error(`Filter numbers must be finite`);return{kind:`number`,value:e,raw:String(e),span:zn}},jee=e=>typeof e==`object`?e:Vn(e),Hn=(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:zn}},Un=()=>{let e=e=>(t,n)=>({kind:`compare`,op:e,field:Bn(t),value:jee(n),span:zn}),t=e=>t=>({kind:`now`,offset:{sign:e,duration:Aee(t)},span:zn});return{eq:e(`=`),ne:e(`!=`),lt:e(`<`),lte:e(`<=`),gt:e(`>`),gte:e(`>=`),between:(t,n,r)=>Hn(`and`,[e(`>=`)(t,n),e(`<=`)(t,r)]),has:(e,t)=>({kind:`has`,field:Bn(e),value:Vn(t),span:zn}),present:e=>({kind:`present`,field:Bn(e),span:zn}),in:(e,t)=>({kind:`in`,field:Bn(e),values:t.map(Vn),span:zn}),isNull:e=>({kind:`isNull`,field:Bn(e),span:zn}),search:e=>({kind:`search`,text:e,span:zn}),similar:(e,t)=>({kind:`similar`,field:Bn(e),text:t,span:zn}),regex:(e,t)=>({kind:`regex`,field:Bn(e),pattern:t,span:zn}),and:(...e)=>Hn(`and`,e),or:(...e)=>Hn(`or`,e),not:e=>({kind:`not`,arg:e,span:zn}),now:()=>({kind:`now`,span:zn}),ago:t(`-`),fromNow:t(`+`)}},Wn=Un(),Gn=/\{([A-Za-z_][A-Za-z0-9_]*)\}/g,Mee=e=>[...e.matchAll(Gn)].map(e=>e[1]),Nee=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??{}):[],Kn=e=>[...new Set(Nee(e).flatMap(Mee))],qn=(e,t)=>e.replace(Gn,(e,n)=>t[n]===null||t[n]===void 0?``:String(t[n])),Jn=(e,t={})=>{if(e.kind===`record`){let n=e=>typeof e==`string`?qn(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,qn(n,t)]))}:e:e.kind===`list`?{...e,...e.filter!==void 0&&{filter:qn(e.filter,t)},...e.orderBy!==void 0&&{orderBy:qn(e.orderBy,t)}}:e},Yn=e=>/^\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(e)?.[1],Pee=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===1&&typeof e.$field==`string`,Xn=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Zn=e=>Pee(e)?e.$field:Array.isArray(e)?e.map(Zn):Xn(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Zn(t)])):e,Qn=`table`,$n=/^[a-z0-9][a-z0-9_-]*$/,er=e=>{if(!e.startsWith(`/-/forms/`))return;let t=e.slice(9);return $n.test(t)?{name:t}:void 0},tr=e=>e.flatMap(e=>e.kind===`group`||e.kind===`tab`?tr(e.items):[e]),nr=(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}},rr={text:`text`,integer:`integer`,decimal:`decimal`,boolean:`boolean`,date:`date`,choice:`text`,custom:`json`},ir=e=>({name:e.name,column:e.name,type:e.options?`enum`:rr[e.kind],nullable:!0,readOnly:!1,filterable:e.kind!==`custom`,sortable:!1,aliases:[],...e.options&&{enumValues:e.options.map(e=>e.value)}}),ar=e=>({name:`inputs`,table:{name:`inputs`},fields:Object.fromEntries(e.map(e=>[e.name,ir(e)])),primaryKey:[]}),or=(e,t)=>{let n=e[t].when;if(n===void 0)return;let r=Yt(n);if(!r.ok)return r.errors.map(e=>e.message).join(`; `);if(!r.ast)return`it is empty`;let i=wn(ar(e.slice(0,t)),r.ast);return i.ok?i.filter:i.errors.map(e=>e.message).join(`; `)},sr=(e,t)=>{let n=new Set,r={};return e.forEach((i,a)=>{let o=or(e,a);if(typeof o==`string`)throw Error(`Input "${i.name}": ${o}`);let s=o===void 0||Pn(o,r)===!0;s&&n.add(i.name),r[i.name]=s?t[i.name]??null:null}),n},cr=(e,t)=>Object.fromEntries(Object.entries(e).flatMap(([e,n])=>{let r=typeof n==`string`?Yn(n):void 0;return r===void 0?[[e,n]]:Object.hasOwn(t,r)?[[e,t[r]]]:[]})),lr=e=>`groupBy`in e,ur=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(`,`)},dr=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/,fr=e=>{let t=dr.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:void 0},pr=(e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2],mr=/^(>=|<=|>|<|=)?(.+)$/,hr={">=":e=>e>=0,"<=":e=>e<=0,">":e=>e>0,"<":e=>e<0,"=":e=>e===0},gr=(e,t)=>{let n=fr(e),r=t.trim().split(/\s+/);if(!n||t.trim()===``)return;let i=!0;for(let e of r){let[,t=`=`,r=``]=mr.exec(e)??[],a=fr(r);if(!a)return;i&&=hr[t](pr(n,a))}return i},_r=(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=gr(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}`},vr=`[Filtered]`,yr=/authorization|cookie|passw|secret|token|api[-_]?key|credential|session|csrf|signature|^sig$/i,br=new Set([`url`,`query_string`,`from`,`to`]),xr=12,Sr=e=>e.replace(/(^|&)([^=&]*)=([^&]*)/g,(e,t,n)=>yr.test(n)?`${t}${n}=${vr}`:e),Cr=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)}${Sr(r)}${n===-1?``:e.slice(n)}`},wr=(e,t,n)=>yr.test(e)?vr:typeof t==`string`&&br.has(e)?e===`query_string`?Sr(t):Cr(t):Tr(t,n+1),Tr=(e,t)=>t>xr||typeof e!=`object`||!e?e:Array.isArray(e)?e.map(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`?[e[0],wr(e[0],e[1],t)]:Tr(e,t+1)):Object.fromEntries(Object.entries(e).map(([e,n])=>[e,wr(e,n,t)])),Er=e=>Tr(e,0),Dr=[`unknown-field`,`not-filterable`,`not-sortable`,`unsupported-traversal`,`invalid-traversal`],Or=e=>e.replace(/(["']?)\{[A-Za-z_][A-Za-z0-9_]*\}\1/g,(e,t)=>t?`${t}x${t}`:`0`),kr=(e,t)=>{let n=Yt(Or(t));if(!n.ok)return n.errors.map(e=>`filter: ${e.message}`);if(!n.ast)return[];let r=wn(e,n.ast);return r.ok?[]:r.errors.filter(e=>Dr.includes(e.code)).map(e=>`filter: ${e.message}`)},Ar=(e,t)=>{if(Kn({kind:`list`,resource:e.name,orderBy:t}).length>0)return[];let n=Oee(t);if(!n.ok)return n.errors.map(e=>`orderBy: ${e.message}`);let r=kee(e,n.items);return r.ok?[]:r.errors.map(e=>`orderBy: ${e.message}`)},jr=(e,{models:t,pages:n,source:r,createPages:i})=>{let a=Kn(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?kr(n,e.filter):[],...e.orderBy?Ar(n,e.orderBy):[]]:a:[`unknown resource "${e.resource}"`]}default:return[`an address's kind is list, record, create or page, not "${String(e.kind)}"`]}},Mr={messages:[],replying:!1},Nr=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);return n===-1?[...e,t]:e.map((e,r)=>r===n?t:e)},Pr=(e,t,n)=>{let r=e.find(e=>e.id===t);return Nr(e,r?{...r,parts:Nr(r.parts,n)}:{id:t,from:`assistant`,parts:[n]})},Fr=(e,t)=>{switch(t.type){case`state`:return t.state;case`message`:return{...e,messages:Nr(e.messages,t.message)};case`part`:return{...e,messages:Pr(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}}}}},Ir=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
|
-
`)),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(``)}},Lr={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`}]]};Lr.node;var Rr=d(Lr),zr={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};zr.node;var Br=d(zr),Vr={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`}]]};Vr.node;var Hr=d(Vr),Ur={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Ur.node;var Wr=d(Ur),Gr={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`}]]};Gr.node;var Kr=d(Gr),qr={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};qr.node;var Jr=d(qr),Yr={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};Yr.node;var Xr=d(Yr),Zr={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`}]]};Zr.node;var Qr=d(Zr),$r={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`}]]};$r.node;var ei=d($r),ti={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`}]]};ti.node;var ni=d(ti),ri={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`}]]};ri.node;var ii=d(ri),ai={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`}]]};ai.node;var oi=d(ai),si={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`}]]};si.node;var ci=d(si),li={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`}]]};li.node;var ui=d(li),di={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`}]]};di.node;var fi=d(di),pi={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`}]]};pi.node;var mi=d(pi),hi={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`]};hi.node;var gi=d(hi),_i={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`}]]};_i.node;var vi=d(_i),yi={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`}]]};yi.node;var Fee=d(yi),bi={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`]};bi.node;var Iee=d(bi),xi={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`}]]};xi.node;var Lee=d(xi),Si={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Si.node;var Ci=d(Si),wi={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};wi.node;var Ti=d(wi),Ei={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};Ei.node;var Di=d(Ei),Oi={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Oi.node;var ki=d(Oi),Ai={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`}]]};Ai.node;var ji=d(Ai),Mi={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`]};Mi.node;var Ree=d(Mi),Ni={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`]};Ni.node;var zee=d(Ni),Pi={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`}]]};Pi.node;var Bee=d(Pi),Fi={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`]};Fi.node;var Vee=d(Fi),Ii={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Ii.node;var Hee=d(Ii),Li={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`]};Li.node;var Uee=d(Li),Ri={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`}]]};Ri.node;var zi=d(Ri),Bi={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`}]]};Bi.node;var Wee=d(Bi),Vi={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`}]]};Vi.node;var Hi=d(Vi),Ui={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`}]]};Ui.node;var Gee=d(Ui),Wi={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`}]]};Wi.node;var Gi=d(Wi),Ki={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`]};Ki.node;var Kee=d(Ki),qi={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`]};qi.node;var qee=d(qi),Ji={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`]};Ji.node;var Yi=d(Ji),Xi={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`}]]};Xi.node;var Zi=d(Xi),Qi={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`}]]};Qi.node;var Jee=d(Qi),$i={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`}]]};$i.node;var Yee=d($i),ea={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`]};ea.node;var Xee=d(ea),ta={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`}]]};ta.node;var Zee=d(ta),na={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`}]]};na.node;var ra=d(na),ia={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`}]]};ia.node;var aa=d(ia),oa={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`}]]};oa.node;var Qee=d(oa),sa={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`}]]};sa.node;var ca=d(sa),la={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`]};la.node;var $ee=d(la),ua={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`}]]};ua.node;var ete=d(ua),da={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`}]]};da.node;var tte=d(da),fa={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`}]]};fa.node;var pa=d(fa),ma={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`}]]};ma.node;var nte=d(ma),ha={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`}]]};ha.node;var ga=d(ha),_a={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`}]]};_a.node;var va=d(_a),ya={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`}]]};ya.node;var ba=d(ya),xa={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`}]]};xa.node;var Sa=d(xa),Ca={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`}]]};Ca.node;var rte=d(Ca),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 Ta=d(wa),Ea={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};Ea.node;var Da=d(Ea),Oa={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`}]]};Oa.node;var ite=d(Oa),ka={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`}]]};ka.node;var Aa=d(ka),ja={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`}]]};ja.node;var ate=d(ja),Ma={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`}]]};Ma.node;var Na=d(Ma),Pa={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`}]]};Pa.node;var Fa=d(Pa),Ia={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`}]]};Ia.node;var La=d(Ia),Ra={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};Ra.node;var za=d(Ra),Ba={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Ba.node;var Va=d(Ba),Ha={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`}]]};Ha.node;var Ua=d(Ha),Wa={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`}]]};Wa.node;var ote=d(Wa),Ga={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`}]]};Ga.node;var Ka=d(Ga),qa={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`}]]};qa.node;var Ja=d(qa),Ya={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`}]]};Ya.node;var Xa=d(Ya),Za={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`}]]};Za.node;var Qa=d(Za),$a={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`}]]};$a.node;var ste=d($a),eo={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`}]]};eo.node;var to=d(eo),no={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};no.node;var ro=d(no),io={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`}]]};io.node;var ao=d(io),oo={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`}]]};oo.node;var so=d(oo),co={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`}]]};co.node;var lo=d(co),uo={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`}]]};uo.node;var fo=d(uo),po={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`}]]};po.node;var mo=d(po),ho={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`}]]};ho.node;var go=d(ho),_o={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};_o.node;var vo=d(_o),yo={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`]};yo.node;var bo=d(yo),xo={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`}]]};xo.node;var So=d(xo),Co={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`}]]};Co.node;var wo=d(Co),To={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`}]]};To.node;var Eo=d(To),Do={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`}]]};Do.node;var Oo=d(Do),ko={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`}]]};ko.node;var Ao=d(ko),jo={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`}]]};jo.node;var Mo=d(jo),No={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`]};No.node;var Po=d(No),Fo={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`]};Fo.node;var Io=d(Fo),Lo={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Lo.node;var Ro=d(Lo),zo={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`}]]};zo.node;var Bo=d(zo),Vo={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`}]]};Vo.node;var Ho=d(Vo),Uo={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`}]]};Uo.node;var Wo=d(Uo),Go={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`}]]};Go.node;var cte=d(Go),Ko={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`}]]};Ko.node;var qo=d(Ko),Jo={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Jo.node;var lte=d(Jo),Yo={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`]};Yo.node;var Xo=d(Yo),Zo={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`]};Zo.node;var Qo=d(Zo),$o={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`}]]};$o.node;var es=d($o),ts={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`}]]};ts.node;var ns=d(ts),rs={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`]};rs.node;var ute=d(rs),is={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`}]]};is.node;var as=d(is),os={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`}]]};os.node;var dte=d(os),ss={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`}]]};ss.node;var cs=d(ss),ls={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`}]]};ls.node;var fte=d(ls),us={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};us.node;var ds=d(us),fs={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`}]]};fs.node;var pte=d(fs),I=t(r(),1),L=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: everything is on, nothing is required.`,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: alles staat aan, niets is verplicht.`,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.`}}),ps=t(i()),ms=`/-/account`,hs=`/-/sign-in-policy`,mte=(e,t,n)=>[{id:`account-security`,label:L(`signInSecurity`),icon:pa,href:`${e}${ms}`,active:t===ms},...n?[{id:`sign-in-policy`,label:L(`signInPolicy`),icon:Oo,href:`${e}${hs}`,active:t===hs}]:[]],hte=[`always`,`editing`,`reading`],gs=e=>e!==void 0&&!hte.includes(e),_s=(e,t)=>t?.[e]??e,vs={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`},gte=[`list`,`display`,`filter`,`orderBy`,`filterLayout`,`savedSearch`],_te=e=>`${e.latitude.toFixed(5)},${e.longitude.toFixed(5)},${e.zoom.toFixed(2)}`,ys=(e,t,n=-t)=>Number.isFinite(e)&&e>=n&&e<=t,vte=e=>{let t=e?.split(`,`);if(t?.length!==3||t.some(e=>e.trim()===``))return;let[n,r,i]=t.map(Number);return ys(n,90)&&ys(r,180)&&ys(i,22,0)?{latitude:n,longitude:r,zoom:i}:void 0},bs=e=>`${e.scale},${e.day}`,yte=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},xs=(e,t)=>{let n=e?.split(`,`);if(n?.length!==2)return;let[r,i]=n;return t.includes(r)&&yte(i)?{scale:r,day:i}:void 0},Ss=e=>{let t=new URLSearchParams;for(let n of gte){let r=e[n];r===void 0||r===``&&n!==`filter`||t.set(vs[n],r)}e.map&&t.set(vs.map,_te(e.map)),e.calendar&&t.set(vs.calendar,bs(e.calendar)),e.timeline&&t.set(vs.timeline,bs(e.timeline));let n=t.toString();return n?`?${n}`:``},Cs=e=>{let t=new URLSearchParams;e.edit&&t.set(vs.edit,`true`);for(let n of e.open??[])t.append(vs.open,n);e.tab&&t.set(vs.tab,e.tab);let n=t.toString();return n?`?${n}`:``},ws=(e,t=``)=>{switch(e.kind){case`page`:return`${t}/${encodeURIComponent(e.page)}`;case`create`:return`${t}/${encodeURIComponent(e.resource)}/${vs.create}${Es(e.values)}`;case`record`:return`${t}/${encodeURIComponent(e.resource)}/${encodeURIComponent(ur(e.key))}${Cs(e)}`;case`list`:return`${t}/${encodeURIComponent(e.resource)}${Ss(e)}`}},Ts=e=>{try{return e.split(`/`).filter(Boolean).map(decodeURIComponent)}catch(e){if(e instanceof URIError)return;throw e}},Es=(e={})=>{let t=new URLSearchParams(Object.entries(e).filter(([,e])=>e!==``)).toString();return t?`?${t}`:``},Ds=e=>e===`bar`||e===`panel`?e:void 0,Os=(e,t)=>{let n=new URL(e,`http://app`),r=Ts(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===vs.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(vs.open).filter(e=>e!==``))],t=n.searchParams.get(vs.tab)||void 0;return{kind:`record`,resource:i,key:a,...n.searchParams.get(vs.edit)===`true`&&{edit:!0},...e.length>0&&{open:e},...t&&{tab:t}}}let o=n.searchParams,s=o.get(vs.list)||void 0,c=o.get(vs.display)||void 0,l=o.get(vs.filter)??void 0,u=o.get(vs.orderBy)||void 0,d=Ds(o.get(vs.filterLayout)),f=vte(o.get(vs.map)),p=xs(o.get(vs.calendar),[`month`,`week`]),m=xs(o.get(vs.timeline),[`week`,`month`,`quarter`]),h=o.get(vs.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}}},ks=`/-/sign-in`,As={step:`step`,next:`next`},js=[`sign-in`,`forgot-password`,`email-code`,`sign-up`,`sign-up-code`,`sign-up-details`],Ms=e=>js.includes(e),Ns=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}`},Ps=({step:e=`sign-in`,next:t}={})=>{let n=new URLSearchParams;e!==`sign-in`&&n.set(As.step,e);let r=Ns(t);r&&r!==`/`&&n.set(As.next,r);let i=n.toString();return i?`${ks}?${i}`:ks},Fs=(e,t)=>{if(e!==`/-/sign-in`)return;let n=t.get(As.step),r=Ns(t.get(As.next));return{step:Ms(n)?n:`sign-in`,...r&&{next:r}}},Is=e=>typeof e==`string`?e:e&&Fn(e),Ls=e=>{let t=Object.entries(e??{}).map(([e,t])=>`${e}.${t}`);return t.length>0?t:void 0},Rs=e=>({photos:e&&`${e.resource}.${e.field}.${e.image}`,photos_order_by:e?.sort}),zs=(e={})=>({filter:Is(e.filter)||void 0,order_by:e.orderBy,page_size:e.pageSize,page_token:e.pageToken||void 0,fields:e.fields?.join(`,`),labels:Ls(e.labels)?.join(`,`),...Rs(e.photos),count:e.count}),Bs=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}`:``},Vs=e=>e.startsWith(`/`)&&!e.startsWith(`//`),Hs=e=>{if(typeof e!=`object`||!e)return!1;let{uri:t,url:n}=e;return typeof t==`string`&&typeof n==`string`&&Vs(n)},Us=e=>e!==void 0&&URL.canParse(e)?new URL(e).origin:void 0,Ws=(e,t)=>({...e,url:`${t}${e.url}`,...e.variants&&{variants:Object.fromEntries(Object.entries(e.variants).map(([e,n])=>[e,Vs(n.url)?{...n,url:`${t}${n.url}`}:n]))}}),Gs=(e,t)=>t===void 0||typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Hs(n)?Ws(n,t):n])),Ks=(e,t)=>t===void 0?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n.map(e=>Hs(e)?Ws(e,t):e)])),qs=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:[]}},Js=class extends qs{constructor(e){super(e),this.name=`PreconditionFailedError`}},Ys=e=>e instanceof qs,Xs=e=>typeof e==`object`&&!!e&&`type`in e&&`status`in e,Zs=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.json():void 0,n=Xs(t)?t:{type:`urn:protobase:problem:unknown`,title:e.statusText||`Request failed`,status:e.status};return n.status===412?new Js(n):new qs(n)},Qs=(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 Zs(h);return h}},$s=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()]})),ec=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:$s(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)}),tc=e=>Math.min(3e4,1e3*2**e),nc=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),rc=(e,t,n=tc)=>{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:Bs({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 Ir(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 nc(n(o++),i)}})(),()=>r.abort()},ic=e=>typeof e==`string`?e:e.toModel().name,ac=(e,t)=>`/${ic(e)}/${ur(t)}`,oc=(e,t,n)=>({items:e.items.map(e=>Gs(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:Ks(e.photos,n)},...t.headers.get(`x-protobase-warning`)&&{warning:t.headers.get(`x-protobase-warning`)}}),sc=({created_at:e,...t})=>({...t,createdAt:e}),cc=e=>e.headers.get(`etag`)??``,lc=async(e,t)=>{let{permissions:n,...r}=await e.json();return{record:Gs(r,t),etag:cc(e),...n&&{permissions:n}}},uc=(e,t)=>({results:(e.results??[]).map(e=>e.op===`create`||e.op===`update`?{...e,record:Gs(e.record,t)}:e.op===`reorder`?{...e,records:e.records.map(e=>({...e,record:Gs(e.record,t)}))}:e)}),dc=(e={})=>{let t=Qs(e),n=Us(e.baseUrl),r=async(e,r)=>{let i=await t({method:`GET`,path:`/${ic(e)}`,query:Bs(zs(r))});return oc(await i.json(),i,n)},i=async(e,r)=>{let i=zs(r),a=await t({method:`POST`,path:`/${ic(e)}:search`,body:{...i,fields:r?.fields,labels:Ls(r?.labels)}});return oc(await a.json(),a,n)},a=async(e,r)=>lc(await t({method:`GET`,path:ac(e,r)}),n),o=async(e,r)=>{let i=await t({method:`POST`,path:`/${ic(e)}`,body:r});return{record:Gs(await i.json(),n),etag:cc(i),location:i.headers.get(`location`)??``}},s=async(e,r,i,a)=>lc(await t({method:`PATCH`,path:ac(e,r),body:i,headers:{"if-match":a}}),n),c=async(e,n,{etag:r}={})=>{await t({method:`DELETE`,path:ac(e,n),headers:r?{"if-match":r}:void 0})},l=async(e,r)=>{let i=await t({method:`POST`,path:`${ac(e,r)}:undelete`});return{record:Gs(await i.json(),n),etag:cc(i)}},u=async(e,n,r)=>(await(await t({method:`POST`,path:`${ac(e,n)}:reveal`,body:{field:r}})).json()).value,d=async(e,r,i)=>lc(await t({method:`POST`,path:`${ac(e,r)}:generate`,body:{action:i}}),n),f=async(e,n,{pageSize:r,pageToken:i}={})=>{let a=Bs({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${ac(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=Bs({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${ac(e,n)}:comments`,query:a})).json();return{items:o.items.map(sc),nextPageToken:o.next_page_token}},m=async(e,n,{body:r,mentions:i=[]})=>sc(await(await t({method:`POST`,path:`${ac(e,n)}:comments`,body:{body:r,mentions:i}})).json()),h=async(e,n,r)=>(await(await t({method:`GET`,path:`${ac(e,n)}:mentionable`,query:Bs({q:r})})).json()).items,g=async e=>{let r=e=>typeof e==`object`&&e&&`$ref`in e?e:ur(e),i=e.map(e=>({...e,resource:ic(e.resource),...`key`in e&&{key:r(e.key)},...e.op===`reorder`&&{keys:e.keys.map(r)}}));return uc(await(await t({method:`POST`,path:`:batchWrite`,body:{ops:i}})).json(),n)},_=async(e,n,r={})=>(await(await t({method:`GET`,path:`/${ic(e)}:facets`,query:Bs({field:n,filter:Is(r.filter)||void 0,limit:r.limit,label:r.label})})).json()).facets,v=async(e,n)=>{let r=await(await t({method:`GET`,path:`/${ic(e)}:aggregate`,query:Bs({group_by:n.groupBy,filter:Is(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:`/${ic(e)}:series`,query:Bs({field:n.field,range:n.range,from:n.from,to:n.to,granularity:n.granularity,time_zone:n.timeZone,filter:Is(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:`/${ic(e)}:histogram`,query:Bs({field:n,buckets:r.buckets,filter:Is(r.filter)||void 0})})).json(),x=async(e,r)=>{let i=await(await t({method:`GET`,path:`/${ic(e)}:map`,query:Bs({latitude:r.latitude,longitude:r.longitude,zoom:r.zoom,filter:Is(r.filter)||void 0,order_by:r.orderBy,fields:r.fields?.join(`,`),labels:Ls(r.labels)?.join(`,`),...Rs(r.photos)})})).json();return{items:i.items.map(e=>Gs(e,n)),buckets:i.buckets,totalSize:i.total_size,...i.labels!==void 0&&{labels:i.labels},...i.photos!==void 0&&{photos:Ks(i.photos,n)}}},S=async(e,r)=>{let i=await t({method:`GET`,path:`/${ic(e)}:seek`,query:Bs({...zs(r),position:r.position})});return oc(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:cc(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`?ec(i):void 0,c=await(await t({method:`POST`,path:`/${ic(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=>rc(t,e)}},fc=e=>typeof e==`string`?e:e.toModel().name,pc=(e,t)=>{let n=n=>t(fc(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=>fc(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)}},mc=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.type==`string`&&Array.isArray(e.children),hc=e=>typeof e==`object`&&!!e&&e.kind===`member`,gc=e=>hc(e)?[e.path.join(`.`)]:typeof e!=`object`||!e?[]:Object.values(e).flatMap(gc),_c=e=>hc(e)?{...e,path:[e.path.join(`.`)]}:Array.isArray(e)?e.map(_c):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,_c(t)])),vc=e=>{let t=ze(e);return t.ok?t.ast?{ok:!0,ast:t.ast,paths:[...new Set(gc(t.ast))]}:{ok:!1,message:`the condition is empty`}:{ok:!1,message:t.errors.map(e=>e.message).join(`; `)}},yc=(e,t)=>e.ast!==void 0&&Lt(_c(e.ast),t),bc=(e,t)=>{let[n,r,...i]=e.split(`.`);return n&&r===`count`&&i.length===0&&!t(n)?n:void 0},xc=(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}},Sc=(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]}))}),Cc=(e,t)=>{if(e.kind===`group`){let n=e.items.flatMap(e=>Cc(e,t));return n.length>0?[{...e,items:n}]:[]}if(e.kind===`tab`){let n=e.items.flatMap(e=>Cc(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=>xc(t,e.resource,n).ok);return[i&&i.length>0?{...r,columns:i}:r]},wc=(e,t,n)=>e.run?.kind!==`link`||!(`to`in e.run)||jr(e.run.to,{models:n,pages:new Set,source:t}).length===0,Tc=(e,t)=>({...e,layout:e.layout.flatMap(e=>Cc(e,t)),actions:e.actions.filter(n=>wc(n,t[e.resource],t))}),Ec=(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=>Sc(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=>Tc(e,a)),permissions:Object.fromEntries(n.flatMap(t=>e.permissions?.[t.name]?[[t.name,e.permissions[t.name]]]:[]))}},Dc=class extends Error{status;code;constructor(e,t,n){super(e),this.status=t,this.code=n,this.name=`AuthError`}},Oc=(e,t)=>new Dc(e?.message||t,e?.status??500,e?.code),kc=e=>({signInMethods:async()=>{let{data:t,error:n}=await e.$fetch(`/account/sign-in-methods`);if(n||!t)throw Oc(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 Oc(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 Oc(n,`Could not add the passkey`)},renamePasskey:async(t,n)=>{let{error:r}=await e.passkey.updatePasskey({id:t,name:n});if(r)throw Oc(r,`Could not rename the passkey`)},removePasskey:async t=>{let{error:n}=await e.passkey.deletePasskey({id:t});if(n)throw Oc(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 Oc(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 Oc(n,`The code did not work`)},turnOnEmailedCodes:async t=>{let{error:n}=await e.twoFactor.enable({method:`otp`,...t&&{password:t}});if(n)throw Oc(n,`Could not turn on two-factor authentication`)},turnOffTwoFactor:async t=>{let{error:n}=await e.twoFactor.disable(t?{password:t}:{});if(n)throw Oc(n,`Could not turn off two-factor authentication`)},linkedProviders:async()=>{let{data:t,error:n}=await e.listAccounts();if(n||!t)throw Oc(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 Oc(i,`Could not start linking the account`);return r.url},newBackupCodes:async t=>{let{data:n,error:r}=await e.twoFactor.generateBackupCodes(t?{password:t}:{});if(r||!n)throw Oc(r,`Could not make new backup codes`);return n.backupCodes}});function Ac(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{code:e,message:t,toString:()=>e}]))}var jc=Ac({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`}),Mc=`1.7.7`;function Nc(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 Pc(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 Fc(){return Ic.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var Ic={stubThis:e=>e};function Lc(e){let{id:t}=e;return{...e,id:Pc(t),transports:e.transports}}function Rc(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 zc=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 Bc({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 zc({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 zc({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 zc({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 zc({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 zc({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new zc({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 zc({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new zc({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(!Rc(t))return new zc({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new zc({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 zc({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 zc({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 Vc=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}}},Hc=[`cross-platform`,`platform`];function Uc(e){if(e&&!(Hc.indexOf(e)<0))return e}async function Wc(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(!Fc())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:Pc(t.challenge),user:{...t.user,id:Pc(t.user.id)},excludeCredentials:t.excludeCredentials?.map(Lc)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=Vc.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw Bc({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){Gc(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=Nc(e))}catch(e){Gc(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=Nc(c.getAuthenticatorData())}catch(e){Gc(`getAuthenticatorData()`,e)}return{id:o,rawId:Nc(s),response:{attestationObject:Nc(c.attestationObject),clientDataJSON:Nc(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:Uc(a.authenticatorAttachment)}}function Gc(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 Kc(){if(!Fc())return qc.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?qc.stubThis(new Promise(e=>e(!1))):qc.stubThis(e.isConditionalMediationAvailable())}var qc={stubThis:e=>e};function Jc({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 zc({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new zc({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!Rc(t))return new zc({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new zc({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 zc({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 Yc(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(!Fc())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(Lc));let a={...t,challenge:Pc(t.challenge),allowCredentials:i},o={};if(n){if(!await Kc())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=Vc.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Jc({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=Nc(u.userHandle)),{id:c,rawId:Nc(l),response:{authenticatorData:Nc(u.authenticatorData),clientDataJSON:Nc(u.clientDataJSON),signature:Nc(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Uc(s.authenticatorAttachment)}}var Xc=`1.7.7`,Zc=Symbol.for(`better-auth:broadcast-channel`),Qc=()=>Math.floor(Date.now()/1e3),$c=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:Qc()}))}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 el(e=`better-auth.message`){return globalThis[Zc]||(globalThis[Zc]=new $c(e)),globalThis[Zc]}var tl=[],nl=0,rl=null,il=4,bte=globalThis.nanostoresGlobal||={epoch:0},xte=()=>{let e,t;for(;nl<tl.length;){t=nl,nl+=il;let n=rl?.get(tl[t]);if(n){if(!n.has(tl[t+1]))continue;n.clear()}try{tl[t](tl[t+1].value,tl[t+2],tl[t+3])}catch(t){e=t}}if(tl.length=nl=0,e)throw e},al=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),()=>{rl?.get(e)?.delete(n);for(let t=nl;t<tl.length;)tl[t]===e&&tl[t+1]===n?tl.splice(t,il):t+=il;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){bte.epoch++;let i=!tl.length&&!0;for(let i of t)tl.push(i,n,e,r);i&&xte()},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},Ste=2,Cte=5,ol=6,sl=10,cl=(e,t,n,r)=>(e.events=e.events||{},e.events[n+sl]||(e.events[n+sl]=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+sl](),delete e.events[n+sl]))}),wte=(e,t)=>cl(e,t,Ste,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}}),ll=1e3,ul=(e,t)=>cl(e,n=>{let r=t(n);r&&e.events[ol].push(r)},Cte,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[ol]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[ol])t();e.events[ol]=[]}},ll)},()=>{e.listen=n,e.off=r}});function dl(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function fl(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(!fl(e[n],t[n]))return!1;return!0}if(dl(e)&&dl(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)||!fl(e[r],t[r]))return!1;return!0}return!1}function pl(e,t){return wte(e,({newValue:n,abort:r})=>{t(e.value,n)&&r()})}var ml=Symbol.for(`better-auth:focus-manager`),Tte=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 hl(){return globalThis[ml]||(globalThis[ml]=new Tte),globalThis[ml]}var gl=Symbol.for(`better-auth:online-manager`),Ete=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 _l(){return globalThis[gl]||(globalThis[gl]=new Ete),globalThis[gl]}var Dte={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*:/},Ote=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,vl={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},kte=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Ate(e){return e instanceof Date&&!isNaN(e.getTime())}function jte(e){let t=kte.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 Ate(f)?f:null}function Mte(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 vl)return vl[s];if(!Ote.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(Dte).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=jte(t);if(e)return e}return i?i(e,t):t})}catch(t){if(n)throw t;return e}}function Nte(e,t={strict:!0}){return Mte(e,t)}var Pte=Symbol.for(`better-auth:auth-query`);function yl(e){let t=al(e);return Object.defineProperty(t,Pte,{value:!0}),t}var Fte=()=>typeof window>`u`;function Ite(e,t){return fl(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}var Lte=(e,t,n,r)=>{let i=yl({data:null,error:null,isPending:!0,isRefetching:!1,refetch:e=>o(e)});ul(i,()=>pl(i,Ite));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&&fl(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 ul(i,()=>{if(Fte())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},bl=()=>Math.floor(Date.now()/1e3),Rte=5;function zte(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||_l().isOnline,u=e=>{if(l()){if(e?.event===`storage`){t();return}if(e?.event===`poll`){c.lastSessionRequest=bl(),t();return}if(e?.event===`visibilitychange`){if(bl()-c.lastSessionRequest<Rte)return;c.lastSessionRequest=bl(),t();return}t()}},d=e=>{el().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=el().subscribe(()=>{u({event:`storage`})})},m=()=>{o&&(c.unsubscribeFocus=hl().subscribe(()=>{u({event:`visibilitychange`})}))},h=()=>{c.unsubscribeOnline=_l().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=el().setup(),c.cleanupFocusSetup=hl().setup(),c.cleanupOnlineSetup=_l().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 xl=Object.create(null),Sl=e=>({}),Cl=new Proxy(xl,{get(e,t){return Sl()[t]??xl[t]},has(e,t){return t in Sl()||t in xl},set(e,t,n){let r=Sl(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=Sl(!0);return delete n[t],!0},ownKeys(){let e=Sl(!0);return Object.keys(e)}});Cl.NODE_ENV;function wl(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 wl(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return wl(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return wl(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return wl(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return wl(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return wl(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return wl(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function Bte(){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 Vte(e){let t=e.split(`
|
|
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(``)}},Lr={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`}]]};Lr.node;var Rr=d(Lr),zr={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};zr.node;var Br=d(zr),Vr={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`}]]};Vr.node;var Hr=d(Vr),Ur={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Ur.node;var Wr=d(Ur),Gr={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`}]]};Gr.node;var Kr=d(Gr),qr={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};qr.node;var Jr=d(qr),Yr={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};Yr.node;var Xr=d(Yr),Zr={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`}]]};Zr.node;var Qr=d(Zr),$r={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`}]]};$r.node;var ei=d($r),ti={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`}]]};ti.node;var ni=d(ti),ri={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`}]]};ri.node;var ii=d(ri),ai={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`}]]};ai.node;var oi=d(ai),si={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`}]]};si.node;var ci=d(si),li={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`}]]};li.node;var ui=d(li),di={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`}]]};di.node;var fi=d(di),pi={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`}]]};pi.node;var mi=d(pi),hi={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`]};hi.node;var gi=d(hi),_i={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`}]]};_i.node;var vi=d(_i),yi={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`}]]};yi.node;var Fee=d(yi),bi={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`]};bi.node;var Iee=d(bi),xi={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`}]]};xi.node;var Lee=d(xi),Si={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Si.node;var Ci=d(Si),wi={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};wi.node;var Ti=d(wi),Ei={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};Ei.node;var Di=d(Ei),Oi={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Oi.node;var ki=d(Oi),Ai={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`}]]};Ai.node;var ji=d(Ai),Mi={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`]};Mi.node;var Ree=d(Mi),Ni={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`]};Ni.node;var zee=d(Ni),Pi={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`}]]};Pi.node;var Bee=d(Pi),Fi={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`]};Fi.node;var Vee=d(Fi),Ii={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Ii.node;var Hee=d(Ii),Li={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`]};Li.node;var Uee=d(Li),Ri={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`}]]};Ri.node;var zi=d(Ri),Bi={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`}]]};Bi.node;var Wee=d(Bi),Vi={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`}]]};Vi.node;var Hi=d(Vi),Ui={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`}]]};Ui.node;var Gee=d(Ui),Wi={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`}]]};Wi.node;var Gi=d(Wi),Ki={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`]};Ki.node;var Kee=d(Ki),qi={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`]};qi.node;var qee=d(qi),Ji={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`]};Ji.node;var Yi=d(Ji),Xi={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`}]]};Xi.node;var Zi=d(Xi),Qi={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`}]]};Qi.node;var Jee=d(Qi),$i={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`}]]};$i.node;var Yee=d($i),ea={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`]};ea.node;var Xee=d(ea),ta={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`}]]};ta.node;var Zee=d(ta),na={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`}]]};na.node;var ra=d(na),ia={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`}]]};ia.node;var aa=d(ia),oa={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`}]]};oa.node;var Qee=d(oa),sa={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`}]]};sa.node;var ca=d(sa),la={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`]};la.node;var $ee=d(la),ua={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`}]]};ua.node;var ete=d(ua),da={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`}]]};da.node;var tte=d(da),fa={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`}]]};fa.node;var pa=d(fa),ma={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`}]]};ma.node;var nte=d(ma),ha={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`}]]};ha.node;var ga=d(ha),_a={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`}]]};_a.node;var va=d(_a),ya={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`}]]};ya.node;var ba=d(ya),xa={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`}]]};xa.node;var Sa=d(xa),Ca={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`}]]};Ca.node;var rte=d(Ca),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 Ta=d(wa),Ea={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};Ea.node;var Da=d(Ea),Oa={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`}]]};Oa.node;var ite=d(Oa),ka={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`}]]};ka.node;var Aa=d(ka),ja={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`}]]};ja.node;var ate=d(ja),Ma={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`}]]};Ma.node;var Na=d(Ma),Pa={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`}]]};Pa.node;var Fa=d(Pa),Ia={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`}]]};Ia.node;var La=d(Ia),Ra={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};Ra.node;var za=d(Ra),Ba={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Ba.node;var Va=d(Ba),Ha={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`}]]};Ha.node;var Ua=d(Ha),Wa={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`}]]};Wa.node;var ote=d(Wa),Ga={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`}]]};Ga.node;var Ka=d(Ga),qa={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`}]]};qa.node;var Ja=d(qa),Ya={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`}]]};Ya.node;var Xa=d(Ya),Za={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`}]]};Za.node;var Qa=d(Za),$a={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`}]]};$a.node;var ste=d($a),eo={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`}]]};eo.node;var to=d(eo),no={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};no.node;var ro=d(no),io={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`}]]};io.node;var ao=d(io),oo={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`}]]};oo.node;var so=d(oo),co={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`}]]};co.node;var lo=d(co),uo={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`}]]};uo.node;var fo=d(uo),po={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`}]]};po.node;var mo=d(po),ho={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`}]]};ho.node;var go=d(ho),_o={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};_o.node;var vo=d(_o),yo={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`]};yo.node;var bo=d(yo),xo={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`}]]};xo.node;var So=d(xo),Co={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`}]]};Co.node;var wo=d(Co),To={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`}]]};To.node;var Eo=d(To),Do={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`}]]};Do.node;var Oo=d(Do),ko={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`}]]};ko.node;var Ao=d(ko),jo={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`}]]};jo.node;var Mo=d(jo),No={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`]};No.node;var Po=d(No),Fo={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`]};Fo.node;var Io=d(Fo),Lo={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Lo.node;var Ro=d(Lo),zo={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`}]]};zo.node;var Bo=d(zo),Vo={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`}]]};Vo.node;var Ho=d(Vo),Uo={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`}]]};Uo.node;var Wo=d(Uo),Go={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`}]]};Go.node;var cte=d(Go),Ko={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`}]]};Ko.node;var qo=d(Ko),Jo={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Jo.node;var lte=d(Jo),Yo={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`]};Yo.node;var Xo=d(Yo),Zo={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`]};Zo.node;var Qo=d(Zo),$o={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`}]]};$o.node;var es=d($o),ts={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`}]]};ts.node;var ns=d(ts),rs={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`]};rs.node;var ute=d(rs),is={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`}]]};is.node;var as=d(is),os={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`}]]};os.node;var dte=d(os),ss={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`}]]};ss.node;var cs=d(ss),ls={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`}]]};ls.node;var fte=d(ls),us={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};us.node;var ds=d(us),fs={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`}]]};fs.node;var pte=d(fs),I=t(r(),1),L=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.`}}),ps=t(i()),ms=`/-/account`,hs=`/-/sign-in-policy`,mte=(e,t,n)=>[{id:`account-security`,label:L(`signInSecurity`),icon:pa,href:`${e}${ms}`,active:t===ms},...n?[{id:`sign-in-policy`,label:L(`signInPolicy`),icon:Oo,href:`${e}${hs}`,active:t===hs}]:[]],hte=[`always`,`editing`,`reading`],gs=e=>e!==void 0&&!hte.includes(e),_s=(e,t)=>t?.[e]??e,vs={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`},gte=[`list`,`display`,`filter`,`orderBy`,`filterLayout`,`savedSearch`],_te=e=>`${e.latitude.toFixed(5)},${e.longitude.toFixed(5)},${e.zoom.toFixed(2)}`,ys=(e,t,n=-t)=>Number.isFinite(e)&&e>=n&&e<=t,vte=e=>{let t=e?.split(`,`);if(t?.length!==3||t.some(e=>e.trim()===``))return;let[n,r,i]=t.map(Number);return ys(n,90)&&ys(r,180)&&ys(i,22,0)?{latitude:n,longitude:r,zoom:i}:void 0},bs=e=>`${e.scale},${e.day}`,yte=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},xs=(e,t)=>{let n=e?.split(`,`);if(n?.length!==2)return;let[r,i]=n;return t.includes(r)&&yte(i)?{scale:r,day:i}:void 0},Ss=e=>{let t=new URLSearchParams;for(let n of gte){let r=e[n];r===void 0||r===``&&n!==`filter`||t.set(vs[n],r)}e.map&&t.set(vs.map,_te(e.map)),e.calendar&&t.set(vs.calendar,bs(e.calendar)),e.timeline&&t.set(vs.timeline,bs(e.timeline));let n=t.toString();return n?`?${n}`:``},Cs=e=>{let t=new URLSearchParams;e.edit&&t.set(vs.edit,`true`);for(let n of e.open??[])t.append(vs.open,n);e.tab&&t.set(vs.tab,e.tab);let n=t.toString();return n?`?${n}`:``},ws=(e,t=``)=>{switch(e.kind){case`page`:return`${t}/${encodeURIComponent(e.page)}`;case`create`:return`${t}/${encodeURIComponent(e.resource)}/${vs.create}${Es(e.values)}`;case`record`:return`${t}/${encodeURIComponent(e.resource)}/${encodeURIComponent(ur(e.key))}${Cs(e)}`;case`list`:return`${t}/${encodeURIComponent(e.resource)}${Ss(e)}`}},Ts=e=>{try{return e.split(`/`).filter(Boolean).map(decodeURIComponent)}catch(e){if(e instanceof URIError)return;throw e}},Es=(e={})=>{let t=new URLSearchParams(Object.entries(e).filter(([,e])=>e!==``)).toString();return t?`?${t}`:``},Ds=e=>e===`bar`||e===`panel`?e:void 0,Os=(e,t)=>{let n=new URL(e,`http://app`),r=Ts(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===vs.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(vs.open).filter(e=>e!==``))],t=n.searchParams.get(vs.tab)||void 0;return{kind:`record`,resource:i,key:a,...n.searchParams.get(vs.edit)===`true`&&{edit:!0},...e.length>0&&{open:e},...t&&{tab:t}}}let o=n.searchParams,s=o.get(vs.list)||void 0,c=o.get(vs.display)||void 0,l=o.get(vs.filter)??void 0,u=o.get(vs.orderBy)||void 0,d=Ds(o.get(vs.filterLayout)),f=vte(o.get(vs.map)),p=xs(o.get(vs.calendar),[`month`,`week`]),m=xs(o.get(vs.timeline),[`week`,`month`,`quarter`]),h=o.get(vs.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}}},ks=`/-/sign-in`,As={step:`step`,next:`next`},js=[`sign-in`,`forgot-password`,`email-code`,`sign-up`,`sign-up-code`,`sign-up-details`],Ms=e=>js.includes(e),Ns=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}`},Ps=({step:e=`sign-in`,next:t}={})=>{let n=new URLSearchParams;e!==`sign-in`&&n.set(As.step,e);let r=Ns(t);r&&r!==`/`&&n.set(As.next,r);let i=n.toString();return i?`${ks}?${i}`:ks},Fs=(e,t)=>{if(e!==`/-/sign-in`)return;let n=t.get(As.step),r=Ns(t.get(As.next));return{step:Ms(n)?n:`sign-in`,...r&&{next:r}}},Is=e=>typeof e==`string`?e:e&&Fn(e),Ls=e=>{let t=Object.entries(e??{}).map(([e,t])=>`${e}.${t}`);return t.length>0?t:void 0},Rs=e=>({photos:e&&`${e.resource}.${e.field}.${e.image}`,photos_order_by:e?.sort}),zs=(e={})=>({filter:Is(e.filter)||void 0,order_by:e.orderBy,page_size:e.pageSize,page_token:e.pageToken||void 0,fields:e.fields?.join(`,`),labels:Ls(e.labels)?.join(`,`),...Rs(e.photos),count:e.count}),Bs=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}`:``},Vs=e=>e.startsWith(`/`)&&!e.startsWith(`//`),Hs=e=>{if(typeof e!=`object`||!e)return!1;let{uri:t,url:n}=e;return typeof t==`string`&&typeof n==`string`&&Vs(n)},Us=e=>e!==void 0&&URL.canParse(e)?new URL(e).origin:void 0,Ws=(e,t)=>({...e,url:`${t}${e.url}`,...e.variants&&{variants:Object.fromEntries(Object.entries(e.variants).map(([e,n])=>[e,Vs(n.url)?{...n,url:`${t}${n.url}`}:n]))}}),Gs=(e,t)=>t===void 0||typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Hs(n)?Ws(n,t):n])),Ks=(e,t)=>t===void 0?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n.map(e=>Hs(e)?Ws(e,t):e)])),qs=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:[]}},Js=class extends qs{constructor(e){super(e),this.name=`PreconditionFailedError`}},Ys=e=>e instanceof qs,Xs=e=>typeof e==`object`&&!!e&&`type`in e&&`status`in e,Zs=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.json():void 0,n=Xs(t)?t:{type:`urn:protobase:problem:unknown`,title:e.statusText||`Request failed`,status:e.status};return n.status===412?new Js(n):new qs(n)},Qs=(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 Zs(h);return h}},$s=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()]})),ec=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:$s(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)}),tc=e=>Math.min(3e4,1e3*2**e),nc=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),rc=(e,t,n=tc)=>{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:Bs({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 Ir(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 nc(n(o++),i)}})(),()=>r.abort()},ic=e=>typeof e==`string`?e:e.toModel().name,ac=(e,t)=>`/${ic(e)}/${ur(t)}`,oc=(e,t,n)=>({items:e.items.map(e=>Gs(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:Ks(e.photos,n)},...t.headers.get(`x-protobase-warning`)&&{warning:t.headers.get(`x-protobase-warning`)}}),sc=({created_at:e,...t})=>({...t,createdAt:e}),cc=e=>e.headers.get(`etag`)??``,lc=async(e,t)=>{let{permissions:n,...r}=await e.json();return{record:Gs(r,t),etag:cc(e),...n&&{permissions:n}}},uc=(e,t)=>({results:(e.results??[]).map(e=>e.op===`create`||e.op===`update`?{...e,record:Gs(e.record,t)}:e.op===`reorder`?{...e,records:e.records.map(e=>({...e,record:Gs(e.record,t)}))}:e)}),dc=(e={})=>{let t=Qs(e),n=Us(e.baseUrl),r=async(e,r)=>{let i=await t({method:`GET`,path:`/${ic(e)}`,query:Bs(zs(r))});return oc(await i.json(),i,n)},i=async(e,r)=>{let i=zs(r),a=await t({method:`POST`,path:`/${ic(e)}:search`,body:{...i,fields:r?.fields,labels:Ls(r?.labels)}});return oc(await a.json(),a,n)},a=async(e,r)=>lc(await t({method:`GET`,path:ac(e,r)}),n),o=async(e,r)=>{let i=await t({method:`POST`,path:`/${ic(e)}`,body:r});return{record:Gs(await i.json(),n),etag:cc(i),location:i.headers.get(`location`)??``}},s=async(e,r,i,a)=>lc(await t({method:`PATCH`,path:ac(e,r),body:i,headers:{"if-match":a}}),n),c=async(e,n,{etag:r}={})=>{await t({method:`DELETE`,path:ac(e,n),headers:r?{"if-match":r}:void 0})},l=async(e,r)=>{let i=await t({method:`POST`,path:`${ac(e,r)}:undelete`});return{record:Gs(await i.json(),n),etag:cc(i)}},u=async(e,n,r)=>(await(await t({method:`POST`,path:`${ac(e,n)}:reveal`,body:{field:r}})).json()).value,d=async(e,r,i)=>lc(await t({method:`POST`,path:`${ac(e,r)}:generate`,body:{action:i}}),n),f=async(e,n,{pageSize:r,pageToken:i}={})=>{let a=Bs({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${ac(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=Bs({page_size:r,page_token:i||void 0}),o=await(await t({method:`GET`,path:`${ac(e,n)}:comments`,query:a})).json();return{items:o.items.map(sc),nextPageToken:o.next_page_token}},m=async(e,n,{body:r,mentions:i=[]})=>sc(await(await t({method:`POST`,path:`${ac(e,n)}:comments`,body:{body:r,mentions:i}})).json()),h=async(e,n,r)=>(await(await t({method:`GET`,path:`${ac(e,n)}:mentionable`,query:Bs({q:r})})).json()).items,g=async e=>{let r=e=>typeof e==`object`&&e&&`$ref`in e?e:ur(e),i=e.map(e=>({...e,resource:ic(e.resource),...`key`in e&&{key:r(e.key)},...e.op===`reorder`&&{keys:e.keys.map(r)}}));return uc(await(await t({method:`POST`,path:`:batchWrite`,body:{ops:i}})).json(),n)},_=async(e,n,r={})=>(await(await t({method:`GET`,path:`/${ic(e)}:facets`,query:Bs({field:n,filter:Is(r.filter)||void 0,limit:r.limit,label:r.label})})).json()).facets,v=async(e,n)=>{let r=await(await t({method:`GET`,path:`/${ic(e)}:aggregate`,query:Bs({group_by:n.groupBy,filter:Is(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:`/${ic(e)}:series`,query:Bs({field:n.field,range:n.range,from:n.from,to:n.to,granularity:n.granularity,time_zone:n.timeZone,filter:Is(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:`/${ic(e)}:histogram`,query:Bs({field:n,buckets:r.buckets,filter:Is(r.filter)||void 0})})).json(),x=async(e,r)=>{let i=await(await t({method:`GET`,path:`/${ic(e)}:map`,query:Bs({latitude:r.latitude,longitude:r.longitude,zoom:r.zoom,filter:Is(r.filter)||void 0,order_by:r.orderBy,fields:r.fields?.join(`,`),labels:Ls(r.labels)?.join(`,`),...Rs(r.photos)})})).json();return{items:i.items.map(e=>Gs(e,n)),buckets:i.buckets,totalSize:i.total_size,...i.labels!==void 0&&{labels:i.labels},...i.photos!==void 0&&{photos:Ks(i.photos,n)}}},S=async(e,r)=>{let i=await t({method:`GET`,path:`/${ic(e)}:seek`,query:Bs({...zs(r),position:r.position})});return oc(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:cc(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`?ec(i):void 0,c=await(await t({method:`POST`,path:`/${ic(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=>rc(t,e)}},fc=e=>typeof e==`string`?e:e.toModel().name,pc=(e,t)=>{let n=n=>t(fc(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=>fc(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)}},mc=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.type==`string`&&Array.isArray(e.children),hc=e=>typeof e==`object`&&!!e&&e.kind===`member`,gc=e=>hc(e)?[e.path.join(`.`)]:typeof e!=`object`||!e?[]:Object.values(e).flatMap(gc),_c=e=>hc(e)?{...e,path:[e.path.join(`.`)]}:Array.isArray(e)?e.map(_c):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,_c(t)])),vc=e=>{let t=ze(e);return t.ok?t.ast?{ok:!0,ast:t.ast,paths:[...new Set(gc(t.ast))]}:{ok:!1,message:`the condition is empty`}:{ok:!1,message:t.errors.map(e=>e.message).join(`; `)}},yc=(e,t)=>e.ast!==void 0&&Lt(_c(e.ast),t),bc=(e,t)=>{let[n,r,...i]=e.split(`.`);return n&&r===`count`&&i.length===0&&!t(n)?n:void 0},xc=(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}},Sc=(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]}))}),Cc=(e,t)=>{if(e.kind===`group`){let n=e.items.flatMap(e=>Cc(e,t));return n.length>0?[{...e,items:n}]:[]}if(e.kind===`tab`){let n=e.items.flatMap(e=>Cc(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=>xc(t,e.resource,n).ok);return[i&&i.length>0?{...r,columns:i}:r]},wc=(e,t,n)=>e.run?.kind!==`link`||!(`to`in e.run)||jr(e.run.to,{models:n,pages:new Set,source:t}).length===0,Tc=(e,t)=>({...e,layout:e.layout.flatMap(e=>Cc(e,t)),actions:e.actions.filter(n=>wc(n,t[e.resource],t))}),Ec=(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=>Sc(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=>Tc(e,a)),permissions:Object.fromEntries(n.flatMap(t=>e.permissions?.[t.name]?[[t.name,e.permissions[t.name]]]:[]))}},Dc=class extends Error{status;code;constructor(e,t,n){super(e),this.status=t,this.code=n,this.name=`AuthError`}},Oc=(e,t)=>new Dc(e?.message||t,e?.status??500,e?.code),kc=e=>({signInMethods:async()=>{let{data:t,error:n}=await e.$fetch(`/account/sign-in-methods`);if(n||!t)throw Oc(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 Oc(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 Oc(n,`Could not add the passkey`)},renamePasskey:async(t,n)=>{let{error:r}=await e.passkey.updatePasskey({id:t,name:n});if(r)throw Oc(r,`Could not rename the passkey`)},removePasskey:async t=>{let{error:n}=await e.passkey.deletePasskey({id:t});if(n)throw Oc(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 Oc(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 Oc(n,`The code did not work`)},turnOnEmailedCodes:async t=>{let{error:n}=await e.twoFactor.enable({method:`otp`,...t&&{password:t}});if(n)throw Oc(n,`Could not turn on two-factor authentication`)},turnOffTwoFactor:async t=>{let{error:n}=await e.twoFactor.disable(t?{password:t}:{});if(n)throw Oc(n,`Could not turn off two-factor authentication`)},linkedProviders:async()=>{let{data:t,error:n}=await e.listAccounts();if(n||!t)throw Oc(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 Oc(i,`Could not start linking the account`);return r.url},newBackupCodes:async t=>{let{data:n,error:r}=await e.twoFactor.generateBackupCodes(t?{password:t}:{});if(r||!n)throw Oc(r,`Could not make new backup codes`);return n.backupCodes}});function Ac(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{code:e,message:t,toString:()=>e}]))}var jc=Ac({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`}),Mc=`1.7.7`;function Nc(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 Pc(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 Fc(){return Ic.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var Ic={stubThis:e=>e};function Lc(e){let{id:t}=e;return{...e,id:Pc(t),transports:e.transports}}function Rc(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 zc=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 Bc({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 zc({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 zc({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 zc({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 zc({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 zc({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new zc({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 zc({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new zc({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(!Rc(t))return new zc({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new zc({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 zc({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 zc({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 Vc=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}}},Hc=[`cross-platform`,`platform`];function Uc(e){if(e&&!(Hc.indexOf(e)<0))return e}async function Wc(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(!Fc())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:Pc(t.challenge),user:{...t.user,id:Pc(t.user.id)},excludeCredentials:t.excludeCredentials?.map(Lc)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=Vc.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw Bc({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){Gc(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=Nc(e))}catch(e){Gc(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=Nc(c.getAuthenticatorData())}catch(e){Gc(`getAuthenticatorData()`,e)}return{id:o,rawId:Nc(s),response:{attestationObject:Nc(c.attestationObject),clientDataJSON:Nc(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:Uc(a.authenticatorAttachment)}}function Gc(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 Kc(){if(!Fc())return qc.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?qc.stubThis(new Promise(e=>e(!1))):qc.stubThis(e.isConditionalMediationAvailable())}var qc={stubThis:e=>e};function Jc({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 zc({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new zc({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!Rc(t))return new zc({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new zc({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 zc({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 Yc(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(!Fc())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(Lc));let a={...t,challenge:Pc(t.challenge),allowCredentials:i},o={};if(n){if(!await Kc())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=Vc.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Jc({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=Nc(u.userHandle)),{id:c,rawId:Nc(l),response:{authenticatorData:Nc(u.authenticatorData),clientDataJSON:Nc(u.clientDataJSON),signature:Nc(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Uc(s.authenticatorAttachment)}}var Xc=`1.7.7`,Zc=Symbol.for(`better-auth:broadcast-channel`),Qc=()=>Math.floor(Date.now()/1e3),$c=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:Qc()}))}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 el(e=`better-auth.message`){return globalThis[Zc]||(globalThis[Zc]=new $c(e)),globalThis[Zc]}var tl=[],nl=0,rl=null,il=4,bte=globalThis.nanostoresGlobal||={epoch:0},xte=()=>{let e,t;for(;nl<tl.length;){t=nl,nl+=il;let n=rl?.get(tl[t]);if(n){if(!n.has(tl[t+1]))continue;n.clear()}try{tl[t](tl[t+1].value,tl[t+2],tl[t+3])}catch(t){e=t}}if(tl.length=nl=0,e)throw e},al=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),()=>{rl?.get(e)?.delete(n);for(let t=nl;t<tl.length;)tl[t]===e&&tl[t+1]===n?tl.splice(t,il):t+=il;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){bte.epoch++;let i=!tl.length&&!0;for(let i of t)tl.push(i,n,e,r);i&&xte()},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},Ste=2,Cte=5,ol=6,sl=10,cl=(e,t,n,r)=>(e.events=e.events||{},e.events[n+sl]||(e.events[n+sl]=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+sl](),delete e.events[n+sl]))}),wte=(e,t)=>cl(e,t,Ste,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}}),ll=1e3,ul=(e,t)=>cl(e,n=>{let r=t(n);r&&e.events[ol].push(r)},Cte,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[ol]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[ol])t();e.events[ol]=[]}},ll)},()=>{e.listen=n,e.off=r}});function dl(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function fl(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(!fl(e[n],t[n]))return!1;return!0}if(dl(e)&&dl(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)||!fl(e[r],t[r]))return!1;return!0}return!1}function pl(e,t){return wte(e,({newValue:n,abort:r})=>{t(e.value,n)&&r()})}var ml=Symbol.for(`better-auth:focus-manager`),Tte=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 hl(){return globalThis[ml]||(globalThis[ml]=new Tte),globalThis[ml]}var gl=Symbol.for(`better-auth:online-manager`),Ete=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 _l(){return globalThis[gl]||(globalThis[gl]=new Ete),globalThis[gl]}var Dte={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*:/},Ote=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,vl={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},kte=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Ate(e){return e instanceof Date&&!isNaN(e.getTime())}function jte(e){let t=kte.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 Ate(f)?f:null}function Mte(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 vl)return vl[s];if(!Ote.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(Dte).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=jte(t);if(e)return e}return i?i(e,t):t})}catch(t){if(n)throw t;return e}}function Nte(e,t={strict:!0}){return Mte(e,t)}var Pte=Symbol.for(`better-auth:auth-query`);function yl(e){let t=al(e);return Object.defineProperty(t,Pte,{value:!0}),t}var Fte=()=>typeof window>`u`;function Ite(e,t){return fl(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}var Lte=(e,t,n,r)=>{let i=yl({data:null,error:null,isPending:!0,isRefetching:!1,refetch:e=>o(e)});ul(i,()=>pl(i,Ite));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&&fl(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 ul(i,()=>{if(Fte())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},bl=()=>Math.floor(Date.now()/1e3),Rte=5;function zte(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||_l().isOnline,u=e=>{if(l()){if(e?.event===`storage`){t();return}if(e?.event===`poll`){c.lastSessionRequest=bl(),t();return}if(e?.event===`visibilitychange`){if(bl()-c.lastSessionRequest<Rte)return;c.lastSessionRequest=bl(),t();return}t()}},d=e=>{el().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=el().subscribe(()=>{u({event:`storage`})})},m=()=>{o&&(c.unsubscribeFocus=hl().subscribe(()=>{u({event:`visibilitychange`})}))},h=()=>{c.unsubscribeOnline=_l().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=el().setup(),c.cleanupFocusSetup=hl().setup(),c.cleanupOnlineSetup=_l().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 xl=Object.create(null),Sl=e=>({}),Cl=new Proxy(xl,{get(e,t){return Sl()[t]??xl[t]},has(e,t){return t in Sl()||t in xl},set(e,t,n){let r=Sl(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=Sl(!0);return delete n[t],!0},ownKeys(){let e=Sl(!0);return Object.keys(e)}});Cl.NODE_ENV;function wl(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 wl(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return wl(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return wl(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return wl(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return wl(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return wl(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return wl(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function Bte(){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 Vte(e){let t=e.split(`
|
|
5
5
|
at `);return t.length<=1?e:(t.splice(1,1),t.join(`
|
|
6
6
|
at `))}function Hte(e,t){class n extends e{#e;constructor(...e){if(Bte()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=Vte(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 Ute={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};Hte(class extends Error{status;body;headers;statusCode;constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:Ute[e]){super(t?.message,t?.cause?{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,this.body=t}},Error);var Tl=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},Wte=47;function El(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===Wte;)t--;return t===e.length?e:e.slice(0,t)}function Gte(e){try{return(El(new URL(e).pathname)||`/`)!==`/`}catch{throw new Tl(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function Kte(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new Tl(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof Tl?t:new Tl(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function Dl(e,t=`/api/auth`){if(Kte(e),Gte(e))return e;let n=El(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function Ol(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 qte(e,t,n,r,i){if(e)return Dl(e,t);if(r!==!1){let e=Cl.BETTER_AUTH_URL||Cl.NEXT_PUBLIC_BETTER_AUTH_URL||Cl.PUBLIC_BETTER_AUTH_URL||Cl.NUXT_PUBLIC_BETTER_AUTH_URL||Cl.NUXT_PUBLIC_AUTH_URL||(Cl.BASE_URL===`/`?void 0:Cl.BASE_URL);if(e)return Dl(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&Ol(o,`proto`)&&Ol(a,`host`))try{return Dl(`${o}://${a}`,t)}catch{}if(n){let e=Jte(n.url);if(!e)throw new Tl(`Could not get origin from request. Please provide a valid base URL.`);return Dl(e,t)}if(typeof window<`u`&&window.location)return Dl(window.location.origin,t)}function Jte(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var Yte=[`javascript:`,`data:`,`vbscript:`];function kl(e){let t;try{t=new URL(e)}catch{return!0}return!Yte.includes(t.protocol)}var Xte={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&kl(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}},Zte=()=>typeof window>`u`,Qte=ll;function $te(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 Al(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}function ene(e){return!e||e.session===null&&e.user===null?null:e}function tne(e,t){return fl(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function nne(e,t){let n=al(!1),r,i=0,a=0;n.listen(()=>{a++,i=0});let o=e=>u(e),s=yl({data:null,error:null,isPending:!0,isRefetching:!1,refetch:o});pl(s,tne);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}=Al(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}=Al(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=ene(i),u=s.value,d=u.data!=null&&l!=null&&fl(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()+Qte,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 ul(s,()=>{let e;Zte()||(e=setTimeout(()=>{d()},0));let r=zte({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 jl(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 Ml(e,t,n=`.`,r){if(!jl(t))return Ml(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]]:jl(a)&&jl(i[t])?Ml(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function rne(e){return(...t)=>t.reduce((t,n)=>Ml(t,n,``,e),{})}var ine=rne(),ane=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)}},one=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}},Nl=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}},sne=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 cne(e){if(typeof e==`number`)return new Nl({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new Nl(e);case`exponential`:return new sne(e);default:throw Error(`Invalid retry strategy`)}}var lne=[`get`,`post`,`put`,`patch`,`delete`];function Pl(e){if(!e.startsWith(`@`))return{method:void 0,path:e};let t=e.indexOf(`/`),n=e.slice(1,t===-1?void 0:t);return lne.includes(n)?{method:n,path:t===-1?e:e.slice(t+1)}:{method:void 0,path:e}}var une=e=>e===`.`||e===`..`,dne=e=>e.split(`:`).map(e=>encodeURIComponent(e)).join(`:`);function fne(e,t){let n=t.get(e);if(n===void 0)return dne(e);if(une(n))throw TypeError(`Path parameters cannot be reserved path segments`);return encodeURIComponent(n)}function pne(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}=Pl(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=>fne(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 mne=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},hne=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function gne(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 hne.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function _ne(e){try{return JSON.parse(e),!0}catch{return!1}}function Fl(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 Il(e){try{return JSON.parse(e)}catch{return e}}function Ll(e){return typeof e==`function`}function vne(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&Ll(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&Ll(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}function Rl(...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 yne(e){let t=new Headers(Rl(e?.headers,await mne(e)));if(!t.has(`content-type`)){let n=bne(e?.body);n&&t.set(`content-type`,n)}return t}function bne(e){return Fl(e)?`application/json`:null}function xne(e){let t=e.get(`content-type`);return t?t.split(`;`)[0].trim().toLowerCase():null}function Sne(e,t){let{body:n}=e;return n?!Fl(n)||typeof n==`string`?n:xne(t)===`application/x-www-form-urlencoded`?new URLSearchParams(n).toString():JSON.stringify(n):null}function Cne(e,t){if(t?.method)return t.method.toUpperCase();let{method:n}=Pl(e);return n?n.toUpperCase():t?.body?`POST`:`GET`}function wne(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var Tne=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function zl(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new Tne(n.issues);return n.value}function Bl(e){"@babel/helpers - typeof";return Bl=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},Bl(e)}function Ene(e,t){if(Bl(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Bl(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Dne(e){var t=Ene(e,`string`);return Bl(t)==`symbol`?t:t+``}function One(e,t,n){return(t=Dne(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vl(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 Hl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Vl(Object(n),!0).forEach(function(t){One(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vl(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Ul=async(e,t)=>{var n;let{hooks:r,url:i,options:a}=await one(e,t),o=vne(a),s=new AbortController,c=a.signal??s.signal,l=pne(i,a),u=await yne(a),d=Sne(a,u),f=Cne(i,a),p=Hl(Hl({},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}=wne(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(Hl(Hl({},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=gne(h),n={data:null,response:h,request:p};if(e===`json`||e===`text`){let e=await h.text();n.data=await(p.jsonParser??Il)(e)}else n.data=await h[e]();p?.output&&p.output&&!p.disableValidation&&(n.data=await zl(p.output,n.data));for(let e of r.onSuccess)if(e){var v;await e(Hl(Hl({},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??Il,b=await h.text(),x=_ne(b),S=x?await y(b):null,C={response:h,responseText:b,request:p,error:Hl(Hl({},S),{},{status:h.status,statusText:h.statusText})};for(let e of r.onError)if(e){var w;await e(Hl(Hl({},C),{},{response:t!=null&&(w=t.hookOptions)!=null&&w.cloneResponse?h.clone():h}))}if(t?.retry){let n=cne(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 Ul(e,Hl(Hl({},t),{},{retryAttempt:i+1}))}}if(t?.throw)throw new ane(h.status,h.statusText,x?S:b);return{data:null,error:Hl(Hl({},S),{},{status:h.status,statusText:h.statusText})}},kne=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){var r;let i=Hl(Hl({},n),e.query!==void 0&&{query:Hl(Hl({},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}=Pl(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 zl(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=Hl(Hl(Hl(Hl({},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 zl(o.query,n?.query),i.query!==null&&typeof i.query==`object`)){let t=Hl({},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=Hl(Hl({},t),i.query)}i=Hl(Hl({},i),{},{body:o.input?await zl(o.input,n?.body):n?.body,params:o.params?await zl(o.params,n?.params):n?.params})}return{url:t,options:i}}}return Hl({url:t},(n!==void 0||e.query!==void 0)&&{options:i})}}),Ane=e=>{async function t(t,n){let r=Hl(Hl(Hl({},e),n),{},{headers:Rl(e?.headers,n?.headers),plugins:[...e?.plugins||[],kne(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await Ul(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 Ul(t,r)}return t},jne=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{}}},Mne=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`,Nne=(e,t)=>{let n=`credentials`in Request.prototype,r=qte(e?.baseURL,e?.basePath,void 0,t)??jne(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=Ane({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?Nte(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Xte],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=nne(d,e),h=!1,g=e=>{h||e===null||(h=!0,$te(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:Mne,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=ine(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 Pne(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function Fne(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ine=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,Lne=/['\u2019]/g;function Rne(e){return e.replace(Lne,``).match(Ine)??[]}function zne(e){return Rne(e).map(e=>e.toLowerCase()).join(`-`)}function Bne(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 Vne(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`||Pne(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(zne).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=Bne(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 Hne(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,hydrateSession:i,$fetch:a,atomListeners:o,$store:s}=Nne(e),c={};for(let[e,t]of Object.entries(r))c[`use${Fne(e)}`]=t;return Vne({...n,...c,hydrateSession:i,$fetch:a,$store:s},a,t,r,o)}var Wl=(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 Yc({optionsJSON:{...a.data,extensions:o},useBrowserAutofill:r?.autoFill})}catch(e){return{data:null,error:{code:e instanceof zc?e.code:`AUTH_CANCELLED`,message:jc.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:jc.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 Wc({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 zc?e.code===`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`?{data:null,error:{code:e.code,message:jc.PREVIOUSLY_REGISTERED.message,status:400,statusText:`BAD_REQUEST`}}:e.code===`ERROR_CEREMONY_ABORTED`?{data:null,error:{code:e.code,message:jc.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:jc.UNKNOWN_ERROR.message,status:500,statusText:`INTERNAL_SERVER_ERROR`}}}}},$Infer:{}}),Gl=()=>{let e=al();return{id:`passkey`,version:Mc,$InferServerPlugin:{},getActions:(t,n)=>Wl(t,{$listPasskeys:e,$store:n}),getAtoms(t){return{listPasskeys:Lte(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:jc}},Kl=Ac({OTP_EXPIRED:`OTP expired`,INVALID_OTP:`Invalid OTP`,TOO_MANY_ATTEMPTS:`Too many attempts`}),ql=()=>({id:`email-otp`,version:Xc,$InferServerPlugin:{},atomListeners:[{matcher:e=>e===`/email-otp/verify-email`||e===`/sign-in/email-otp`||e===`/email-otp/request-email-change`,signal:`$sessionSignal`}],$ERROR_CODES:Kl}),Jl=e=>{let t=e?.jwks?.jwksPath??`/jwks`;return{id:`better-auth-client`,version:Xc,$InferServerPlugin:{},pathMethods:{[t]:`GET`},getActions:(e,n,r)=>({jwks:async n=>await e(t,{method:`GET`,...n})})}},Yl=Ac({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`}),Xl=e=>({id:`two-factor`,version:Xc,$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`&&kl(e.twoFactorPage)&&(window.location.href=e.twoFactorPage)}}}}],$ERROR_CODES:Yl}),Zl=(e,t,n)=>Hne({baseURL:e,basePath:t,plugins:[Jl(),ql(),Xl(),Gl()],fetchOptions:{customFetchImpl:n}}),Ql=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):typeof e==`string`?JSON.parse(e):[],$l=e=>{let t=e.split(`,`);return t.includes(`owner`)?`owner`:t.includes(`admin`)?`admin`:`member`},eu=e=>({id:e.id,userId:e.userId,name:e.user.name||e.user.email,email:e.user.email,role:$l(e.role),appRoles:Ql(e.appRoles),createdAt:new Date(e.createdAt).toISOString()}),tu=e=>({id:e.id,email:e.email,role:$l(e.role),appRoles:Ql(e.appRoles),status:e.status,expiresAt:new Date(e.expiresAt).toISOString(),...e.organizationName&&{organizationName:e.organizationName}}),nu=(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 Oc(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(eu),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(tu),invite:async(e,t)=>{let r=await n(`/organization/invite-member`,`Could not send the invitation`,{body:{organizationId:e,...t}});return{invitation:tu(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:tu(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(tu),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}}))}},ru=(e,t)=>({current:async()=>{let{data:t,error:n}=await e.$fetch(`/role/current`,{method:`GET`});if(n)throw Oc(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 Oc(r,`Could not switch the role`);await t()}}),iu=20,au=e=>Array.isArray(e)?e:(e??``).split(`,`).map(e=>e.trim()).filter(Boolean),ou=e=>({id:e.id,name:e.name||e.email,email:e.email,roles:au(e.role),blocked:!!e.banned,createdAt:new Date(e.createdAt).toISOString()}),su=e=>({id:e.id,email:e.email,roles:e.roles,expiresAt:new Date(e.expiresAt).toISOString()}),cu=e=>({invitation:su(e),...e.link&&{link:e.link}}),lu=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 Oc(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(iu),sortBy:`createdAt`,sortDirection:`asc`,...n>0&&{offset:String(n)},...e&&{searchValue:e,searchField:`email`}}});return{users:r.users.map(ou),total:r.total}},create:async e=>ou((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=>cu(await t(`/users/invite`,`Could not send the invitation`,{body:e})),invitations:async()=>(await t(`/users/invitations`,`Could not read the invitations`)).invitations.map(su),revoke:e=>t(`/users/invitations/cancel`,`Could not revoke the invitation`,{body:{id:e}}),roles:()=>t(`/users/roles`,`Could not read the roles`)}},uu=(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 Oc(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 Oc(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 Oc(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 Oc(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 Oc(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 Oc(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 Oc(r.error,`Sign-in failed`);let{clientExtensionResults:i,...a}=await Yc({optionsJSON:r.data}).catch(e=>{throw new Dc(`Auth cancelled`,400,e instanceof zc?e.code:`AUTH_CANCELLED`)}),o=await e.$fetch(`/passkey/verify-authentication`,{method:`POST`,body:{response:a}});if(o.error||!o.data)throw Oc(o.error,`Sign-in failed`);return await t(),o.data.user},sendTwoFactorCode:async()=>{let{error:t}=await e.twoFactor.sendOtp();if(t)throw Oc(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 Oc(o,`The code did not work`);return await t(),a.user}}},du=e=>({read:async()=>{let{data:t,error:n}=await e.$fetch(`/policy/sign-in`);if(n||!t)throw Oc(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 Oc(r,`Could not save the sign-in policy`);return n}}),fu=e=>new Date(e).toISOString(),pu=({startedAt:e,expiresAt:t,endedAt:n,...r})=>({...r,startedAt:fu(e),expiresAt:fu(t),...n&&{endedAt:fu(n)}}),mu=e=>({start:async t=>{let{data:n,error:r}=await e.$fetch(`/staff/sign-in`,{method:`POST`,body:t});if(r||!n?.url)throw Oc(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 Oc(n,`Could not read the session`);return t.staff?pu(t.staff):void 0},stop:async()=>{let{error:t}=await e.$fetch(`/staff/stop`,{method:`POST`,body:{}});if(t)throw Oc(t,`Could not end the staff session`)},log:async()=>{let{data:t,error:n}=await e.$fetch(`/staff/sign-ins`);if(n||!t)throw Oc(n,`Could not read the staff sign-ins`);return t.signIns.map(pu)}}),hu=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},gu=(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=Zl(t,n,i),o=mu(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:hu(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 Dc(`This server has no sign-in. Is the API URL right?`,404);if(!e.ok)throw new Dc(`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.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},...uu(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 Oc(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 Oc(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 Oc(n,`Could not send the reset link`)},resetPassword:async(e,t)=>{let{error:n}=await a.resetPassword({token:e,newPassword:t});if(n)throw Oc(n,`Could not set the password`)},account:kc(a),organizations:nu(a,()=>p({refresh:!0})),roles:ru(a,()=>p({refresh:!0})),signInPolicy:du(a),users:lu(a),staff:{...o,stop:async()=>{d(),await o.stop()}}}},_u=e=>Math.min(3e4,1e3*2**e),vu=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),yu=`http://same-origin.invalid`,bu=(e,t)=>{let n=new URL(e,yu),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===yu?`${r.pathname}${r.search}`:r.href},xu=e=>{let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>fetch(e,t)),r=e.retryDelayMs??_u,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 Zs(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 Ir(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 vu(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=bu(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 Zs(c);return c}}},Su=e=>typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!==null&&`code`in e.error&&`message`in e.error,Cu=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.clone().json():void 0;return Su(t)?new qs({type:`urn:protobase:problem:${t.error.code}`,title:e.statusText||`Request failed`,status:e.status,detail:t.error.message}):Zs(e)},wu=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 Cu(o);return await o.json()};return{status:()=>r(``,`GET`),update:()=>r(`/update`,`POST`)}},Tu=e=>(0,I.useSyncExternalStore)(t=>{let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},()=>window.matchMedia(e).matches,()=>!1),Eu=()=>Tu(`(min-width: 768px)`),Du=()=>Tu(`not all and (min-width: 640px)`),Ou=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()}`}}),R=t(_(),1),ku=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Au=`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`,ju=({tabs:e,onNavigate:t,onMore:n,moreOpen:r,moreControls:i,sticky:a,ref:o})=>{let s=!e.some(e=>e.active);return(0,R.jsxs)(`nav`,{ref:o,"aria-label":Ou(`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,R.jsxs)(`a`,{href:e.href,"aria-current":e.active?`page`:void 0,...e.external?{target:`_blank`,rel:`noreferrer`}:{},onClick:n=>{!e.external&&t&&ku(n)&&(n.preventDefault(),t(e.href))},className:g(Au,e.active?`text-primary-text`:`text-muted-foreground`),children:[(0,R.jsx)(n,{className:`size-6`,strokeWidth:e.active?2.2:1.9,"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`max-w-full truncate px-0.5`,children:e.label})]},e.id)}),(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":i,"data-current":s||void 0,onClick:n,className:g(Au,s?`text-primary-text`:`text-muted-foreground`),children:[(0,R.jsx)(Yi,{className:`size-6`,strokeWidth:s?2.2:1.9,"aria-hidden":!0}),Ou(`more`)]})]})},Mu=`data-pb-scroll-locked`,Nu=()=>{let{body:e,documentElement:t}=document,n=e.style.overflow,r=t.hasAttribute(Mu);return window.innerWidth>t.clientWidth&&t.setAttribute(Mu,``),e.style.overflow=`hidden`,()=>{e.style.overflow=n,r||t.removeAttribute(Mu)}},Pu=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,Fu=[],Iu=(e,t,n)=>{let r=(0,I.useRef)(n);r.current=n,(0,I.useEffect)(()=>{if(!t||!e.current)return;let n=e.current,i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=Nu(),o={};Fu.push(o);let s=()=>[...n.querySelectorAll(Pu)];(s()[0]??n).focus();let c=e=>{if(Fu.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),Fu.splice(Fu.indexOf(o),1),a(),i?.focus()}},[t,e])},Lu=({id:e,open:t,onClose:n,children:r})=>{let i=(0,I.useRef)(null);return Iu(i,t,n),t?(0,R.jsxs)(`div`,{className:`fixed inset-0 z-50 md:hidden`,children:[(0,R.jsx)(`div`,{className:`absolute inset-0 bg-backdrop/40`,onClick:n,"aria-hidden":!0}),(0,R.jsx)(`div`,{ref:i,id:e,role:`dialog`,"aria-modal":`true`,"aria-label":Ou(`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},Ru=(0,I.createContext)(()=>{}),zu=e=>{let t=(0,I.useContext)(Ru);(0,I.useLayoutEffect)(()=>(t(e),()=>t(void 0)),[t,e])},Bu=e=>{(0,I.useLayoutEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`scrollbar-gutter`,`stable`),()=>{t.style.removeProperty(`scrollbar-gutter`)}},[e])},Vu=[`--pb-sticky-top`,`--pb-sticky-bottom`,`scroll-padding-top`,`scroll-padding-bottom`],Hu=(e,t,n,r)=>{(0,I.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 Vu)r.style.removeProperty(e)}},[e,t,n,r])},Uu=({className:e})=>(0,R.jsx)(`span`,{className:g(`block h-3 rounded bg-muted [animation:pb-shimmer_1.4s_ease-in-out_infinite]`,e)}),Wu=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Gu=({parts:e,onNavigate:t})=>(0,R.jsx)(`nav`,{"aria-label":Ou(`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,R.jsx)(Uu,{className:`w-24`}):a,l=g(`truncate`,i?`font-semibold`:`text-muted-foreground`);return(0,R.jsxs)(`span`,{className:g(`min-w-0 items-center gap-1.5`,i?`flex`:`hidden md:flex`),children:[r>0&&(0,R.jsx)(ki,{className:`hidden size-3.5 shrink-0 text-faint-foreground md:block`}),o?(0,R.jsx)(`a`,{href:o,"aria-current":i?`page`:void 0,"aria-label":s?a:void 0,"aria-busy":s||void 0,onClick:e=>{t&&Wu(e)&&(e.preventDefault(),t(o))},className:g(l,`rounded-sm hover:text-foreground hover:underline`),children:c}):(0,R.jsx)(`span`,{className:l,"aria-label":s?a:void 0,"aria-busy":s||void 0,children:c})]},`${r}-${a}`)})}),Ku=({to:e,onClick:t,...n})=>(0,R.jsx)(`a`,{href:e.href,onClick:n=>{t?.(n),!n.defaultPrevented&&Wu(n)&&(n.preventDefault(),e.onFollow())},...n}),qu=`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`,Ju=`fill-[#ff5a1f] dark:fill-[#ff6a33]`,Yu=`fill-[#14161a] dark:fill-[#f1f0ea]`,Xu=({className:e})=>(0,R.jsxs)(`svg`,{viewBox:`0 0 32 32`,className:g(`size-7 shrink-0`,e),"aria-hidden":!0,children:[(0,R.jsx)(`path`,{className:Ju,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,R.jsx)(`path`,{className:Yu,d:`M17 0h10a5 5 0 0 1 5 5v22a5 5 0 0 1-5 5H5a5 5 0 0 1-5-5V17h17z`})]}),Zu=({className:e})=>(0,R.jsx)(`svg`,{viewBox:`54.8 -720 3743.8 925`,className:g(`h-3.5 w-auto`,e),role:`img`,"aria-label":`Protobase`,children:(0,R.jsx)(`path`,{className:Yu,d:qu})}),Qu=`Protobase`,$u=({compact:e,workspace:t,appName:n,appIcon:r})=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5 overflow-hidden`,children:[r?(0,R.jsx)(`img`,{src:r,alt:``,className:`size-7 shrink-0 object-contain`}):(0,R.jsx)(Xu,{}),!e&&(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 leading-tight`,children:[r||n&&n!==Qu?(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:n??Qu}):(0,R.jsx)(Zu,{className:`self-start`}),t&&(0,R.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:t})]})]}),ed=[{label:`Sales`,items:[{id:`orders`,label:`Orders`,icon:Ao,count:12},{id:`customers`,label:`Customers`,icon:gi},{id:`invoices`,label:`Invoices`,icon:ra,count:3}]},{label:`Inventory`,items:[{id:`products`,label:`Products`,icon:Ja},{id:`stock-moves`,label:`Stock moves`,icon:mi},{id:`warehouses`,label:`Warehouses`,icon:cs},{id:`shipments`,label:`Shipments`,icon:es}]},{label:`Finance`,items:[{id:`payments`,label:`Payments`,icon:Hi},{id:`credit-notes`,label:`Credit notes`,icon:lo},{id:`reports`,label:`Reports`,icon:Iee}]},{label:`Admin`,items:[{id:`users`,label:`Users`,icon:as},{id:`settings`,label:`Settings`,icon:Eo}]}],td={xs:`size-5 text-[9px]`,sm:`size-6 text-[10px]`,md:`size-8 text-xs`},nd=({initials:e,hue:t,size:n=`sm`,className:r})=>(0,R.jsx)(`span`,{className:g(`inline-flex shrink-0 select-none items-center justify-center rounded-full font-semibold text-white ring-2 ring-background`,td[n],r),style:{background:`oklch(0.58 0.13 ${t})`},children:e}),rd=({people:e,size:t=`sm`})=>(0,R.jsx)(`span`,{className:`inline-flex -space-x-1`,children:e.map(e=>(0,R.jsx)(nd,{...e,size:t},e.initials))}),id=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},ad=`#ffffff`,od=`#111827`,sd=e=>{let t=id(e);return 1.05/(t+.05)>=(t+.05)/(id(od)+.05)?ad:od},cd={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`},ld={neutral:`bg-faint-foreground`,blue:`bg-primary`,green:`bg-success`,amber:`bg-warning`,red:`bg-danger`,violet:`bg-violet`},ud=`polygon(0 0, calc(100% - 0.625rem) 0, 100% 50%, calc(100% - 0.625rem) 100%, 0 100%)`,dd=({tone:e=`neutral`,dot:t=!0,color:n,shape:r,children:i,className:a})=>(0,R.jsxs)(`span`,{style:{...n!==void 0&&{backgroundColor:n,color:sd(n)},...r===`arrow`&&{clipPath:ud}},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&&cd[e],a),children:[t&&n===void 0&&r===void 0&&(0,R.jsx)(`span`,{className:g(`size-1.5 rounded-full`,ld[e])}),i]}),fd=({label:e,current:t,others:n,rowClassName:r,onSwitch:i})=>(0,R.jsxs)(`div`,{className:`border-b py-1`,role:`group`,"aria-label":e,children:[t&&(0,R.jsxs)(`div`,{className:g(r,`text-foreground hover:bg-transparent`),"aria-current":`true`,children:[(0,R.jsx)(Ci,{className:`size-4`}),(0,R.jsx)(`span`,{className:`truncate`,children:t.label})]}),n.map(e=>(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>i(e.id),className:r,children:[(0,R.jsx)(`span`,{className:`size-4`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))]}),pd=()=>[{value:`light`,label:Ou(`light`),icon:Ho},{value:`dark`,label:Ou(`dark`),icon:ote},{value:`system`,label:Ou(`system`),icon:Ua}],md=({theme:e,className:t})=>(0,R.jsxs)(`div`,{className:t,children:[(0,R.jsx)(Bo,{className:`size-4`}),(0,R.jsx)(`span`,{className:`flex-1`,children:Ou(`theme`)}),(0,R.jsx)(f,{label:Ou(`theme`),iconOnly:!0,value:e.preference,options:pd(),onChange:e.onChange})]}),hd=`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`,gd=({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,I.useState)(!1),f=n??u,p=(0,I.useRef)(null),[m,h]=(0,I.useState)();return(0,I.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,R.jsxs)(`div`,{ref:p,className:`relative`,children:[(0,R.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":Ou(`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,R.jsx)(nd,{initials:e.initials,hue:e.hue,size:`md`,className:`ring-0`}),!t&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 leading-tight`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,R.jsx)(dd,{tone:e.roleTone,dot:!1,className:`mt-0.5 h-4 px-1.5 text-[10px]`,children:e.role})]}),(0,R.jsx)(ji,{className:`size-3.5 shrink-0 text-faint-foreground`})]})]}),f&&(0,R.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,R.jsxs)(`div`,{className:`border-b px-3 pb-2 pt-1.5`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,R.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.email})]}),o&&(o.current||o.others.length>0)&&(0,R.jsx)(fd,{label:Ou(`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:hd,onSwitch:e=>{d(!1),o.onSwitch(e)}}),s&&s.roles.length>1&&(0,R.jsx)(fd,{label:Ou(`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:hd,onSwitch:e=>{d(!1),s.onSwitch(e)}}),r.length>0&&(0,R.jsx)(`div`,{className:g((c||a)&&`border-b`),children:r.map(e=>{let t=e.icon;return(0,R.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(hd,e.active&&`bg-muted text-foreground`),children:[(0,R.jsx)(t,{className:`size-4`}),e.label]},e.id)})}),c&&(0,R.jsx)(`div`,{className:g(a&&`border-b`),children:(0,R.jsx)(md,{theme:c,className:g(hd,`hover:bg-transparent`)})}),a&&(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:a,className:hd,children:[(0,R.jsx)(ate,{className:`size-4`}),Ou(`signOut`)]})]})]})},_d=`protobase:nav-open:`,vd=e=>`${_d}${e}`,yd=(e,t)=>u(()=>e.getItem(t)!==`false`,!0),bd=(e,t,n)=>u(()=>n?e.removeItem(t):e.setItem(t,`false`),void 0),xd=({label:e,side:t=`right`,visible:n,children:r})=>(0,R.jsxs)(`span`,{className:`group/tooltip relative inline-flex`,children:[r,(0,R.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})]}),Sd=e=>e===`text-large`||e===`text-small`||e===`icon-expand`,Cd=e=>e===`text-large`||e===`text-small`,wd={"text-large":`w-60`,"text-small":`w-52`,icon:`w-14`,"icon-label":`w-[76px]`,"icon-tooltip":`w-14`,"icon-expand":`w-14`},Td={"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`},Ed=({item:e,mode:t,active:n,onNavigate:r,className:i})=>{let a=e.icon,o=(0,R.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`,Td[t],n?`bg-primary-soft text-primary-text`:`text-muted-foreground hover:bg-muted hover:text-foreground`,i),children:[(0,R.jsx)(a,{className:g(`shrink-0`,t===`text-small`?`size-4`:`size-[18px]`),strokeWidth:n?2.2:1.9}),(Sd(t)||t===`icon-label`)&&(0,R.jsx)(`span`,{className:`whitespace-nowrap`,children:e.label}),Cd(t)&&e.count&&(0,R.jsx)(`span`,{className:`ml-auto rounded bg-muted px-1.5 text-[11px] tabular-nums text-muted-foreground`,children:e.count}),Cd(t)&&e.problem&&(0,R.jsx)(Qo,{"aria-hidden":!0,className:`ml-auto size-3.5 shrink-0 text-warning-text`})]});return t===`icon-tooltip`?(0,R.jsx)(xd,{label:e.label,children:o}):o},Dd={neutral:`bg-faint-foreground`,info:`bg-primary`,success:`bg-success`,warning:`bg-warning`,danger:`bg-danger`},Od=({tone:e,pulse:t=!1,className:n})=>(0,R.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,R.jsx)(`span`,{className:g(`absolute inset-0 animate-ping rounded-full opacity-60 motion-reduce:animate-none`,Dd[e])}),(0,R.jsx)(`span`,{className:g(`relative size-2 rounded-full`,Dd[e])})]}),kd={"text-large":`h-8 gap-2.5 px-2.5`,"text-small":`h-7 gap-2 px-2 text-body`},Ad={"text-large":`ml-[20px]`,"text-small":`ml-[17px]`},jd=({item:e,recent:t,mode:n,active:r,onNavigate:i})=>{let a=vd(e.id),[o,s]=(0,I.useState)(()=>yd(localStorage,a)),c=(0,I.useId)(),l=e.href??`#${e.id}`,u=()=>{bd(localStorage,a,!o),s(!o)},d=e=>({href:e,onClick:i&&(t=>{t.preventDefault(),i(e)})});return(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(Ed,{item:e,mode:n,active:r,onNavigate:i,className:`pr-8`}),(0,R.jsx)(`button`,{type:`button`,"aria-expanded":o,"aria-controls":c,"aria-label":Ou(`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,R.jsx)(ki,{className:g(`size-3.5 transition-transform`,o&&`rotate-90`)})})]}),o&&(0,R.jsxs)(`ul`,{id:c,"aria-label":Ou(`recent`,e.label.toLowerCase()),className:g(`flex flex-col gap-0.5 border-l pl-1.5`,Ad[n]),children:[t.state===`loading`&&(0,R.jsx)(`li`,{className:g(`flex items-center text-faint-foreground`,kd[n]),children:Ou(`loading`)}),t.state===`error`&&(0,R.jsx)(`li`,{className:g(`flex items-center text-faint-foreground`,kd[n]),children:Ou(`couldNotLoad`)}),t.state===`ready`&&t.records.map(e=>(0,R.jsx)(`li`,{children:(0,R.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`,kd[n],e.active?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,R.jsx)(Od,{tone:e.tone,pulse:e.pulse}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.id)),(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{...d(l),className:g(`flex items-center rounded-md text-faint-foreground transition-colors hover:bg-muted hover:text-foreground`,kd[n]),children:Ou(`viewAll`)})})]})]})},Md=({mode:e,activeItem:t,user:n,workspace:r,appName:i,appIcon:a,forceExpanded:o,profileMenuOpen:s,groups:c=ed,userMenu:l,onNavigate:u,onSignOut:d,signIn:f,organizations:p,roles:m,theme:h,sticky:_,logo:v=$u})=>{let y=e===`icon-expand`,b=y&&o,x=Cd(e)||y;return(0,R.jsx)(`nav`,{"aria-label":Ou(`resources`),className:g(_?`sticky top-0 h-dvh self-start`:`relative`,`z-30 shrink-0`,wd[e]),children:(0,R.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,R.jsx)(`div`,{className:g(`flex h-12 shrink-0 items-center px-3.5`,e===`icon-label`&&`justify-center px-0`),children:(0,R.jsx)(v,{compact:!x,workspace:r,appName:i,appIcon:a})}),(0,R.jsx)(`div`,{className:g(`flex-1 overflow-y-auto overflow-x-hidden pb-2`,`px-2`),children:c.map((n,r)=>(0,R.jsxs)(`div`,{className:g(`flex flex-col gap-0.5`,r>0&&`mt-3`),children:[x?(0,R.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,R.jsx)(`div`,{className:`mx-auto mb-1 h-px w-6 bg-border`}),n.items.map(n=>n.recent&&Cd(e)?(0,R.jsx)(jd,{item:n,recent:n.recent,mode:e,active:n.id===t,onNavigate:u},n.id):(0,R.jsx)(Ed,{item:n,mode:e,active:n.id===t,onNavigate:u},n.id))]},n.label))}),(0,R.jsx)(`div`,{className:g(`shrink-0 border-t p-2`,e!==`text-large`&&e!==`text-small`&&!y&&`flex justify-center`),children:n?(0,R.jsx)(gd,{user:n,compact:!x,open:s,items:l,onNavigate:u,onSignOut:d,organizations:p,roles:m,theme:h}):(0,R.jsxs)(R.Fragment,{children:[h&&x&&(0,R.jsx)(md,{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,R.jsxs)(Ku,{to:f,"aria-label":Ou(`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,R.jsx)(Aa,{className:`size-4 shrink-0`}),x&&(0,R.jsx)(`span`,{className:`whitespace-nowrap`,children:Ou(`signIn`)})]})]})})]})})},Nd=(0,I.createContext)(null),Pd=()=>(0,I.useContext)(Nd),Fd=e=>{let t=e.at(-2);if(typeof t==`object`&&t.href&&!t.loading)return{label:t.label,href:t.href}},Id=(0,I.createContext)(void 0),Ld=()=>{let e=(0,I.useContext)(Id);return e?{id:e.id,name:e.name,"aria-describedby":e.describedBy,"aria-invalid":e.invalid||void 0,"aria-required":e.required||void 0}:{}},Rd=({leading:e,trailing:t,invalid:n,className:r,wrapperClassName:i,...a})=>{let o=Ld();return(0,R.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,R.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]})},zd=({children:e})=>(0,R.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}),Bd=a({en:{close:`Close`,loading:`Loading`,remove:e=>`Remove ${e}`},nl:{close:`Sluiten`,loading:`Laden`,remove:e=>`${e} verwijderen`}}),Vd=({className:e})=>(0,R.jsx)(Da,{"aria-label":Bd(`loading`),className:g(`size-4 animate-spin`,e)}),Hd=(e,t,n)=>t===0?-1:e<0?n===1?0:t-1:(e+n+t)%t,Ud=e=>e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0,Wd=({search:e,className:t=`w-96`,autoFocus:n,showShortcut:r=!0,ref:i})=>{let a=(0,I.useId)(),o=(0,I.useRef)(null),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.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=>Hd(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,R.jsxs)(`div`,{className:g(`relative`,t),children:[(0,R.jsx)(Rd,{ref:m,wrapperClassName:`w-full bg-surface shadow-none`,leading:e.loading?(0,R.jsx)(Vd,{className:`size-4`}):(0,R.jsx)(vo,{className:`size-4`}),trailing:e.text?(0,R.jsx)(`button`,{type:`button`,"aria-label":Ou(`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,R.jsx)(ds,{className:`size-3.5`})}):r?(0,R.jsx)(`span`,{className:`hidden md:inline-flex`,children:(0,R.jsx)(zd,{children:`⌘K`})}):void 0,placeholder:e.placeholder,"aria-label":Ou(`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,R.jsxs)(`div`,{id:a,role:`listbox`,"aria-label":Ou(`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,R.jsx)(`p`,{className:`px-3 py-2 text-muted-foreground`,children:e.loading?Ou(`searching`):Ou(`noMatches`,e.query)}),e.groups.map(e=>(0,R.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,R.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,R.jsx)(`p`,{className:`px-3 py-1.5 text-danger-text`,children:Ou(`couldNotSearch`,e.label)}),e.hits.map(e=>{y+=1;let t=y;return(0,R.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=>{Ud(t)||(t.preventDefault(),h(e.href))},onMouseEnter:()=>u(t),children:[(0,R.jsx)(`span`,{className:`block truncate font-semibold`,children:e.title}),e.subtitle&&(0,R.jsx)(`span`,{className:g(`block truncate text-xs`,t===l?`text-primary-text/80`:`text-muted-foreground`),children:e.subtitle})]},e.id)})]},e.id))]})]})},Gd=({breadcrumb:e,onNavigate:t,actions:n,onMenu:r,menuOpen:i,menuControls:a,search:o,sticky:s,slotRef:c,ref:l})=>{let[u,d]=(0,I.useState)(!1),f=Fd(e),p=(0,I.useRef)(null);return(0,I.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,R.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,R.jsx)(`button`,{type:`button`,"aria-label":Ou(`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,R.jsx)(za,{className:`size-5`})}),f&&(0,R.jsx)(`a`,{href:f.href,"aria-label":Ou(`backTo`,f.label),onClick:e=>{t&&Wu(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,R.jsx)(Di,{className:`size-5`})}),(0,R.jsx)(Gu,{parts:e,onNavigate:t}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-1 md:gap-3`,children:[o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`hidden md:block`,children:(0,R.jsx)(Wd,{ref:p,search:o})}),(0,R.jsx)(`button`,{type:`button`,"aria-label":Ou(`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,R.jsx)(vo,{className:`size-5`})})]}),n,(0,R.jsx)(`div`,{ref:c,className:`contents md:hidden`})]}),o&&u&&(0,R.jsxs)(`div`,{className:`absolute inset-0 z-20 flex items-center gap-1 bg-background px-3 md:hidden`,children:[(0,R.jsx)(Wd,{className:`min-w-0 flex-1`,autoFocus:!0,showShortcut:!1,search:{...o,onSelect:e=>{o.onSelect(e),d(!1)}}}),(0,R.jsx)(`button`,{type:`button`,"aria-label":Ou(`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,R.jsx)(ds,{className:`size-5`})})]})]})},Kd=`app-drawer`,qd=({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=Eu(),[D,O]=(0,I.useState)(!1);(0,I.useEffect)(()=>{E&&O(!1)},[E]);let k=!E&&m&&m.length>0?m:void 0,[A,j]=(0,I.useState)(),M=A??C,N=(0,I.useRef)(null),[ee,te]=(0,I.useState)(null),ne=(0,I.useRef)(null);Hu(M,N,ne,!!k),Bu(M);let re=(e,n=!1)=>(0,R.jsx)(Md,{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,R.jsx)(Ru.Provider,{value:j,children:(0,R.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?re(e,M):(0,R.jsx)(Lu,{id:Kd,open:D,onClose:()=>O(!1),children:re(`text-large`)}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(Gd,{ref:N,slotRef:te,sticky:M,breadcrumb:n,onNavigate:h,actions:c,onMenu:E||k?void 0:()=>O(!0),menuOpen:D,menuControls:Kd,search:S}),(0,R.jsx)(`main`,{className:M?`flex flex-1 flex-col`:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(Nd.Provider,{value:ee,children:T})}),k&&(0,R.jsx)(ju,{ref:ne,sticky:M,tabs:k,onNavigate:h,onMore:()=>O(!0),moreOpen:D,moreControls:Kd})]}),l&&(0,R.jsx)(`div`,{className:M?`sticky top-0 flex h-dvh shrink-0 self-start`:`flex shrink-0`,children:l})]})})},Jd=({title:e,subtitle:t,actions:n})=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-x-4 gap-y-2 md:flex-row md:items-end md:justify-between`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 break-words md:flex-1`,children:[(0,R.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:e}),t&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:t})]}),n&&(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 md:justify-end`,children:n})]}),Yd=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.`}}),Xd=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.`}}),Zd={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`},Qd=(e,t)=>{let n=t?e[t]:void 0;return n&&Yd(n)},$d=e=>Qd(Zd,e.code),ef=e=>$d(e)??(e.status===429?Yd(`tooManyRequests`):e.message),tf=e=>$d(e)??(e.status===429?Yd(`tooManyRequests`):e.status===401?Yd(`wrongEmailOrPassword`):e.message),nf={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`},rf=e=>Qd(nf,typeof e==`string`?e:e.code)||(typeof e==`string`?Yd(`staffFailed`):e.status===429?Yd(`tooManyRequests`):e.message),af={signup_disabled:e=>Xd(`signupDisabled`,e),account_not_linked:e=>Xd(`notLinked`,e),account_already_linked_to_different_user:e=>Xd(`linkedToOther`,e),unable_to_link_account:e=>Xd(`couldNotLink`,e),access_denied:e=>Xd(`accessDenied`,e),EMAIL_DOMAIN_NOT_ALLOWED:e=>Xd(`domainNotAllowed`,e)},of=(e,t)=>af[e]?.(t)??Xd(`providerFailed`,t),sf=`sign-in`,cf=`error`,lf=e=>{let t=new URL(e).searchParams;if(!t.has(cf))return t.get(`sign-in`)||void 0},uf=e=>new URL(e).searchParams.get(cf)||void 0,df=e=>{let t=new URL(e);for(let e of[sf,cf])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},ff={github:`GitHub`,gitlab:`GitLab`,google:`Google`,microsoft:`Microsoft`,apple:`Apple`},pf=(e,t)=>t?.provider===e?t.name:ff[e]??e.charAt(0).toUpperCase()+e.slice(1),z=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`}}),mf=(0,I.createContext)(null),B=()=>{let e=(0,I.useContext)(mf);if(!e)throw Error(`useAuth must be used inside AuthProvider`);return e},hf=({session:e,origin:t,children:n})=>{let[r,i]=(0,I.useState)({kind:`loading`}),[a,o]=(0,I.useState)([`password`]),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)([]),[p,m]=(0,I.useState)([]),[h,g]=(0,I.useState)(),[_,v]=(0,I.useState)([]),[y,b]=(0,I.useState)(),[x,S]=(0,I.useState)(),[C,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)([]),[D,O]=(0,I.useState)(),k=(0,I.useCallback)(()=>C?{kind:`visitor`}:{kind:`signed-out`},[C]),A=(0,I.useCallback)(()=>i(e=>e.kind===`signed-in`?{kind:`signed-out`}:e),[]),j=(0,I.useRef)(A);j.current=A;let M=(0,I.useMemo)(()=>e??gu({...t&&{origin:t},onSignedOut:()=>j.current()}),[e,t]),N=(0,I.useCallback)(async e=>{let[{missing:t},n]=await Promise.all([M.account.signInMethods(),M.staff.current()]);i(t.length>0?{kind:`setup-required`,user:e,missing:t}:{kind:`signed-in`,user:e,...n&&{staff:n}})},[M]),ee=(0,I.useCallback)(async e=>e.kind===`two-factor`?i({kind:`two-factor`,methods:e.methods}):N(e.user),[N]),te=(0,I.useCallback)(()=>{i({kind:`loading`}),M.status().then(async e=>{if(o(e.signInMethods),c(e.passwordReset),u(!!e.signUp),f(e.passkeyDomains??[]),m(e.socialProviders),g(e.platformSignIn),v(e.samlProviders),b(e.staffSignIn),S(e.organizations),w(!!e.anonymous),E(e.plugins??[]),O(e.locale),e.needsAdmin)return i({kind:`needs-admin`});let t=await M.session();return t?N(t):i({kind:e.anonymous?`visitor`:`signed-out`})}).catch(e=>i({kind:`error`,message:e instanceof Error?e.message:z(`noAnswer`)}))},[M,N]);(0,I.useEffect)(te,[te]);let ne=(0,I.useMemo)(()=>({state:r,session:M,signInMethods:a,passwordReset:s,canSignUp:l,passkeyDomains:d,socialProviders:p,signInProviders:[...p.map(e=>({id:e,name:pf(e,h)})),..._],staffSignIn:y,...x&&{organizations:x},markSignedOut:A,recheck:te,beforeSignIn:T,locale:D,adoptSession:async()=>{let e=await M.session();return e?(await N(e),!0):!1},...C&&{browse:()=>{i(e=>e.kind===`signed-out`?{kind:`visitor`}:e)}},signIn:async(e,t)=>ee(await M.signIn(e,t)),sendSignInCode:e=>M.sendSignInCode(e),signInWithCode:async(e,t)=>ee(await M.signInWithCode(e,t)),sendSignUpCode:e=>M.sendSignUpCode(e),verifySignUpCode:(e,t)=>M.verifySignUpCode(e,t),signUp:async e=>N(await M.signUp(e)),signInWithPasskey:async e=>N(await M.signInWithPasskey(e)),verifyTwoFactor:async e=>N(await M.verifyTwoFactor(e)),signInSocial:async e=>{let t=new URL(df(window.location.href),window.location.href).href,n=_.some(t=>t.id===e);window.location.assign(await(n?M.signInSaml(e,t):M.signInSocial(e,t)))},linkProvider:async e=>{window.location.assign(await M.account.linkProvider(e,new URL(df(window.location.href),window.location.href).href))},stopStaffSession:async()=>{await M.staff.stop(),i(k())},signOut:async()=>{await M.signOut(),i(k())}}),[r,M,a,s,l,d,p,h,_,y,x,C,T,D,k,A,te,ee,N]);return(0,R.jsx)(mf.Provider,{value:ne,children:n})},gf=new Map,_f=(e,t)=>{let n=l(),r=`${n}|${e}`;return gf.has(r)||gf.set(r,t(n)),gf.get(r)},vf=(e,t)=>_f(`money:${e}:${t??``}`,n=>new Intl.NumberFormat(n,{style:`currency`,currency:e,...t!==void 0&&{minimumFractionDigits:t,maximumFractionDigits:t}})),yf=(e,t=`EUR`,n)=>vf(t,n).format(e/100),bf=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`}}),xf=()=>_f(`grouped`,e=>new Intl.NumberFormat(e)),Sf=e=>xf().format(e),Cf=e=>e>0?`+${xf().format(e)}`:xf().format(e).replace(`-`,`−`),wf=e=>`${e}%`,Tf=e=>{if(e<1e4)return bf(`rows`,Sf(e));let t=10**(Math.floor(Math.log10(e))-3);return bf(`aboutRows`,Sf(Math.round(e/t)*t))},Ef=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,Df=new Map,Of=e=>{let t=Df.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 Df.set(e,n),n},kf=(e,t)=>{let n=Object.fromEntries(Of(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)}},Af=(e,t)=>{let n=kf(e,t);return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-Math.floor(e/1e3)*1e3},jf=e=>String(e).padStart(2,`0`),Mf=(e,t)=>{let n=kf(e,t);return`${n.year}-${jf(n.month)}-${jf(n.day)}`},Nf=(e,t)=>e-Af(e-Af(e,t),t),Pf=(e,t)=>Nf(Date.parse(`${e}T00:00:00Z`),t),Ff=(e,t)=>{let n=_f(`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})`},If=(e,t)=>()=>_f(`date:${e}`,e=>new Intl.DateTimeFormat(e,{...t,timeZone:`UTC`})),Lf=If(`day`,{day:`numeric`,month:`short`,year:`numeric`}),Rf=If(`dayShort`,{day:`numeric`,month:`short`}),zf=If(`month`,{month:`long`,year:`numeric`}),Bf=If(`monthName`,{month:`long`}),Vf=If(`weekday`,{weekday:`short`}),Hf=If(`weekdayDate`,{weekday:`long`,day:`numeric`,month:`short`,year:`numeric`}),Uf=e=>Lf().format(e),Wf=e=>Rf().format(e),Gf=e=>_f(`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})})),Kf=(e,t=Ef())=>{let n=Gf(t);return`${n.day.format(e)}, ${n.time.format(e)}`},qf=e=>zf().format(e),Jf=e=>Bf().format(e),Yf=(e,t)=>zf().formatRange(e,t),Xf=e=>Vf().format(e),Zf=e=>Hf().format(e),Qf=(e,t)=>Lf().formatRange(e,t),$f=(e,t=Ef())=>Gf(t).time.format(e),ep=e=>e<60?bf(`secondsAgo`,e):e<3600?bf(`minutesAgo`,Math.floor(e/60)):e<86400?bf(`hoursAgo`,Math.floor(e/3600)):bf(`daysAgo`,Math.floor(e/86400)),tp=()=>_f(`relative`,e=>new Intl.RelativeTimeFormat(e,{numeric:`auto`})),np=[[`year`,31536e3],[`month`,2592e3],[`day`,86400],[`hour`,3600],[`minute`,60]],rp=e=>{let t=Math.abs(e),[n,r]=np.find(([,e])=>t>=e)??[`second`,1];return n===`second`&&t<45?bf(`justNow`):tp().format(-Math.sign(e)*Math.floor(t/r),n)},ip={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`},ap={sm:`h-7 px-2.5 text-body gap-1.5`,md:`h-8 px-3 text-body gap-2`},op=({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`,ip[e],ap[t]),V=({variant:e=`secondary`,size:t=`md`,loading:n,className:r,children:i,disabled:a,...o})=>(0,R.jsxs)(`button`,{type:`button`,disabled:a||n,className:g(op({variant:e,size:t}),r),...o,children:[n&&(0,R.jsx)(Vd,{className:`size-3.5`}),i]}),sp=({title:e,description:t,onClose:n,actions:r,children:i,wide:a=!1})=>{let o=(0,I.useRef)(null);return Iu(o,!0,n),(0,R.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,R.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,R.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:e}),t&&(0,R.jsx)(`p`,{className:`mt-1.5 text-muted-foreground`,children:t}),i&&(0,R.jsx)(`div`,{className:`mt-4`,children:i}),(0,R.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})]})})},cp=({title:e,status:t,description:n,children:r})=>(0,R.jsxs)(`section`,{"aria-label":e,className:`rounded-lg border bg-background p-4 sm:p-5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:e}),t]}),(0,R.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}),r&&(0,R.jsx)(`div`,{className:`mt-4`,children:r})]}),lp=({message:e})=>e?(0,R.jsx)(`p`,{role:`alert`,className:`mb-3 text-body font-medium text-danger-text`,children:e}):null,up={allowed:`passkeysAllowed`,required:`passkeysRequired`,forbidden:`passkeysForbidden`},dp=({rule:e,passkeys:t,onAdd:n,onRename:r,onRemove:i})=>{let[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(),[l,u]=(0,I.useState)(),[d,f]=(0,I.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 Dc))throw e;c(ef(e))}o(!1)};return(0,R.jsxs)(cp,{title:L(`passkeys`),status:e===`required`&&(0,R.jsx)(dd,{tone:`blue`,children:L(`required`)}),description:L(up[e]),children:[(0,R.jsx)(lp,{message:l?void 0:s}),t.length>0&&(0,R.jsx)(`ul`,{className:`mb-3 divide-y rounded-md border`,children:t.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,R.jsx)(pa,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium`,children:e.name??L(`passkey`)}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.createdAt?L(`addedOn`,Uf(Date.parse(e.createdAt))):L(`addedEarlier`),` · `,e.backedUp?L(`synced`):L(`oneDevice`)]})]}),(0,R.jsxs)(`span`,{className:`flex gap-1`,children:[(0,R.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>{f(e.name??``),u({kind:`rename`,passkey:e})},children:L(`rename`)}),(0,R.jsx)(V,{size:`sm`,variant:`ghost`,disabled:p,title:p?L(`keepLastPasskey`):void 0,onClick:()=>u({kind:`remove`,passkey:e}),children:L(`remove`)})]})]},e.id))}),e!==`forbidden`&&(0,R.jsxs)(V,{loading:a&&!l,onClick:()=>void m(n),children:[(0,R.jsx)(ro,{className:`size-3.5`}),L(`addPasskey`)]}),l?.kind===`rename`&&(0,R.jsxs)(sp,{title:L(`renamePasskey`),description:L(`renamePasskeyDescription`),onClose:()=>u(void 0),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:()=>u(void 0),children:L(`cancel`)}),(0,R.jsx)(V,{variant:`primary`,loading:a,disabled:!d.trim(),onClick:()=>void m(()=>r(l.passkey.id,d.trim())),children:L(`save`)})]}),children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[L(`name`),(0,R.jsx)(Rd,{autoFocus:!0,value:d,maxLength:60,onChange:e=>f(e.target.value)})]}),(0,R.jsx)(lp,{message:s})]}),l?.kind===`remove`&&(0,R.jsx)(sp,{title:L(`removePasskey`),description:L(`removePasskeyDescription`,l.passkey.name??L(`thisPasskey`)),onClose:()=>u(void 0),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:()=>u(void 0),children:L(`cancel`)}),(0,R.jsx)(V,{variant:`danger`,loading:a,onClick:()=>void m(()=>i(l.passkey.id)),children:L(`remove`)})]}),children:s&&(0,R.jsx)(lp,{message:s})})]})},fp=({providers:e,linked:t,onConnect:n,error:r})=>{let[i,a]=(0,I.useState)(),[o,s]=(0,I.useState)(r),c=async e=>{a(e),s(void 0);try{await n(e)}catch(e){if(!(e instanceof Dc))throw e;s(ef(e)),a(void 0)}};return(0,R.jsxs)(cp,{title:L(`connectedAccounts`),description:L(`connectedAccountsDescription`),children:[(0,R.jsx)(lp,{message:o}),(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3 py-2.5`,children:[(0,R.jsx)(rte,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),t.includes(e.id)?(0,R.jsx)(dd,{tone:`green`,children:L(`connected`)}):(0,R.jsx)(V,{size:`sm`,loading:i===e.id,disabled:i!==void 0,onClick:()=>void c(e.id),children:L(`connect`,e.name)})]},e.id))})]})},pp=(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)},mp=({codes:e})=>{let[t,n]=(0,I.useState)(!1),r=`${e.join(`
|
|
7
|
-
`)}\n`;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(`ul`,{"aria-label":L(`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,R.jsx)(`li`,{children:e},e))}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsxs)(V,{size:`sm`,onClick:()=>{navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},children:[t?(0,R.jsx)(Ci,{className:`size-3.5 text-success`}):(0,R.jsx)(zi,{className:`size-3.5`}),L(t?`copied`:`copy`)]}),(0,R.jsxs)(V,{size:`sm`,onClick:()=>pp(r,`backup-codes.txt`),children:[(0,R.jsx)(Gi,{className:`size-3.5`}),L(`download`)]})]})]})},hp=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:o})=>{let[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(),p=async()=>{u(!0),f(void 0);try{await a(i?s:void 0)}catch(e){if(!(e instanceof Dc))throw e;f(ef(e)),u(!1)}};return(0,R.jsxs)(sp,{title:e,description:t,onClose:o,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:o,children:L(`cancel`)}),(0,R.jsx)(V,{variant:r?`danger`:`primary`,loading:l,disabled:i&&!s,onClick:()=>void p(),children:n})]}),children:[i&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[L(`yourPassword`),(0,R.jsx)(Rd,{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,R.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:d})]})},gp=(e,t)=>e.replace(/\D/g,``).slice(0,t),_p=(e,t,n)=>{let r=gp(t??``,n);return r.length===n?r:gp(e,n)},vp=(e,t,n,r)=>{let i=t.replace(/\D/g,``);return i.length>=r?i.slice(0,r):gp(e.slice(0,n)+i+e.slice(n+i.length),r)},yp=({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,I.useRef)(null),[_,v]=(0,I.useState)(!1),[y,b]=(0,I.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,R.jsxs)(`div`,{className:g(`relative`,a&&`opacity-50`,o),children:[(0,R.jsx)(`div`,{"aria-hidden":!0,className:`flex justify-center gap-2`,children:Array.from({length:r},(e,t)=>{let n=_&&t===S;return(0,R.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,R.jsx)(`span`,{className:`h-6 w-px animate-pulse bg-foreground`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-border-strong`}))},t)})}),(0,R.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(_p(e.target.value,t??n?.getData(`text/plain`),r))},onPaste:e=>{if(p?.(e),e.defaultPrevented)return;e.preventDefault();let t=e.currentTarget,n=vp(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)}})]})},bp=(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))(bp||{}),xp=[0,1],Sp=[1,0],Cp=[2,3],wp=[3,2],Tp={L:xp,M:Sp,Q:Cp,H:wp},Ep=/^\d*$/,Dp=/^[A-Z0-9 $%*+./:-]*$/,Op=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,kp=1,Ap=40,jp=3,Mp=3,Np=40,Pp=10,Fp=[[-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]],Ip=[[-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]],Lp=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<kp||e>Ap)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,bp.Timing),this.setFunctionModule(e,6,e%2==0,bp.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,zp(r,e));this.setFunctionModule(8,7,zp(r,6)),this.setFunctionModule(8,8,zp(r,7)),this.setFunctionModule(7,8,zp(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,zp(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,zp(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,zp(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=zp(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,bp.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,bp.Alignment)}setFunctionModule(e,t,n,r=bp.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==em(t,n))throw RangeError(`Invalid argument`);let r=Ip[n[0]][t],i=Fp[n[0]][t],a=Math.floor($p(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=tm(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=nm(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($p(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]=zp(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+=jp:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Np),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Np}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+=jp:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Np),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Np}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+=Mp)}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*Pp,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 Rp(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 zp(e,t){return!!(e>>>t&1)}var Bp=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()}},Vp=[1,10,12,14],Hp=[2,9,11,13],Up=[4,8,16,16];function Wp(e,t){return e[Math.floor((t+7)/17)+1]}function Gp(e){let t=[];for(let n of e)Rp(n,8,t);return new Bp(Up,e.length,t)}function Kp(e){if(!Yp(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);Rp(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new Bp(Vp,e.length,t)}function qp(e){if(!Xp(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Op.indexOf(e.charAt(n))*45;r+=Op.indexOf(e.charAt(n+1)),Rp(r,11,t)}return n<e.length&&Rp(Op.indexOf(e.charAt(n)),6,t),new Bp(Hp,e.length,t)}function Jp(e){return e===``?[]:Yp(e)?[Kp(e)]:Xp(e)?[qp(e)]:[Gp(Qp(e))]}function Yp(e){return Ep.test(e)}function Xp(e){return Dp.test(e)}function Zp(e,t){let n=0;for(let r of e){let e=Wp(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function Qp(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 $p(e){if(e<kp||e>Ap)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 em(e,t){return Math.floor($p(e)/8)-Fp[t[0]][e]*Ip[t[0]][e]}function tm(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]=rm(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=rm(n,2)}return t}function nm(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]^=rm(t,e))}return n}function rm(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 im(e,t,n=1,r=40,i=-1,a=!0){if(!(kp<=n&&n<=r&&r<=Ap)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=em(o,t)*8,i=Zp(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Sp,Cp,wp])a&&s<=em(o,e)*8&&(t=e);let c=[];for(let t of e){Rp(t.mode[0],4,c),Rp(t.numChars,Wp(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=em(o,t)*8;Rp(0,Math.min(4,l-c.length),c),Rp(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Rp(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 Lp(o,t,u,i)}function am(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`?Jp(e):Array.isArray(e)?[Gp(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=im(c,Tp[n],i,a,o,r),u=om({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 om(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=bp.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 sm=({uri:e,className:t})=>{let{size:n,path:r}=(0,I.useMemo)(()=>{let t=am(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,R.jsxs)(`svg`,{viewBox:`0 0 ${n} ${n}`,role:`img`,"aria-label":L(`qrCode`),shapeRendering:`crispEdges`,className:t,children:[(0,R.jsx)(`rect`,{width:n,height:n,fill:`#fff`}),(0,R.jsx)(`path`,{d:r,fill:`#000`})]})},cm=e=>(new URL(e).searchParams.get(`secret`)??``).replace(/(.{4})(?=.)/g,`$1 `),lm=()=>[{value:`app`,label:L(`authenticatorApp`),description:L(`authenticatorAppDescription`)},{value:`email`,label:L(`emailedCode`),description:L(`emailedCodeDescription`)}],um=({offerEmailedCodes:e,needsPassword:t,onStartApp:n,onConfirmApp:r,onEmailedCodes:i,onDone:a,onCancel:o})=>{let[s,c]=(0,I.useState)({kind:`choose`}),[l,u]=(0,I.useState)(`app`),[d,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(``),[h,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)(),b=e?lm():lm().filter(e=>e.value===`app`),x=async e=>{_(!0),y(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;y(ef(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,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:v});return s.kind===`backup-codes`?(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:L(`twoFactorIsOn`)}),(0,R.jsx)(mp,{codes:s.codes}),(0,R.jsx)(V,{variant:`primary`,onClick:a,className:`min-h-10`,children:L(`savedCodes`)})]}):s.kind===`scan`?(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),C(s.setup)},children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:L(`scanCode`)}),(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,R.jsx)(sm,{uri:s.setup.totpURI,className:`size-44 rounded-md border`}),(0,R.jsxs)(`p`,{className:`text-center text-xs text-muted-foreground`,children:[L(`cannotScan`),(0,R.jsx)(`span`,{className:`mt-1 block break-all font-mono text-body text-foreground`,children:cm(s.setup.totpURI)})]})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[L(`codeFromApp`),(0,R.jsx)(yp,{name:`code`,required:!0,autoFocus:!0,value:p,invalid:!!v,onChange:m,onComplete:e=>!h&&void C(s.setup,e)})]}),w,(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:L(`turnOn`)}),o&&(0,R.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:L(`cancel`)})]}):(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":L(`secondStep`),className:`flex flex-col gap-2`,children:b.map(e=>(0,R.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,R.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,R.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted-foreground`,children:e.description})]},e.value))}),t&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[L(`yourPassword`),(0,R.jsx)(Rd,{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,R.jsx)(V,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:L(`continue`)}),o&&(0,R.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:L(`cancel`)})]})},dm={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},fm=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,I.useState)(),d=()=>u(void 0),f=n?(0,R.jsx)(dd,{tone:`green`,children:L(`on`)}):t===`required`?(0,R.jsx)(dd,{tone:`amber`,children:L(`required`)}):(0,R.jsx)(dd,{children:L(`off`)}),p=L(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:dm[t]);return l?.kind===`setup`?(0,R.jsx)(cp,{title:L(`twoFactor`),status:f,description:p,children:(0,R.jsx)(`div`,{className:`max-w-sm`,children:(0,R.jsx)(um,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,R.jsxs)(cp,{title:L(`twoFactor`),status:f,description:p,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,R.jsx)(V,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:L(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,R.jsx)(V,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:L(`addAuthenticator`)}),n&&r&&(0,R.jsx)(V,{onClick:()=>u({kind:`new-codes`}),children:L(`newBackupCodes`)}),n&&(0,R.jsx)(V,{variant:`danger`,disabled:t===`required`,title:t===`required`?L(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:L(`turnOff`)})]}),l?.kind===`turn-off`&&(0,R.jsx)(hp,{title:L(`turnOffTitle`),description:L(`turnOffDescription`),confirmLabel:L(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,R.jsx)(hp,{title:L(`newCodesTitle`),description:L(`newCodesDescription`),confirmLabel:L(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,R.jsx)(sp,{title:L(`yourNewCodes`),description:L(`keepCodesSafe`),onClose:d,actions:(0,R.jsx)(V,{variant:`primary`,onClick:d,children:L(`savedCodes`)}),children:(0,R.jsx)(mp,{codes:l.codes})})]})},pm=()=>{let e=uf(window.location.href);return e&&window.history.replaceState(window.history.state,``,df(window.location.href)),e},mm=({email:e})=>{let{session:t,signInProviders:n,socialProviders:r,linkProvider:i}=B(),a=n.filter(e=>r.includes(e.id)),{account:o}=t,[s,c]=(0,I.useState)(),[l,u]=(0,I.useState)(),[d]=(0,I.useState)(pm),f=(0,I.useCallback)(()=>{Promise.all([o.signInMethods(),o.passkeys(),o.linkedProviders()]).then(([e,t,n])=>c({methods:e,passkeys:t,linked:n}),e=>u(e instanceof Dc?ef(e):L(`couldNotReadMethods`)))},[o]);(0,I.useEffect)(f,[f]);let p=e=>e.then(e=>(f(),e));return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,R.jsx)(Jd,{title:L(`signInSecurity`),subtitle:e}),s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(dp,{rule:s.methods.policy.passkey,passkeys:s.passkeys,onAdd:()=>p(o.addPasskey()),onRename:(e,t)=>p(o.renamePasskey(e,t)),onRemove:e=>p(o.removePasskey(e))}),(0,R.jsx)(fm,{rule:s.methods.policy.twoFactor,enabled:s.methods.account.twoFactor,authenticatorApp:s.methods.account.authenticatorApp,mail:s.methods.mail,needsPassword:s.methods.account.password,onStartApp:e=>o.startAuthenticatorApp(e),onConfirmApp:e=>o.confirmAuthenticatorApp(e),onEmailedCodes:e=>o.turnOnEmailedCodes(e),onTurnOff:e=>o.turnOffTwoFactor(e),onNewBackupCodes:e=>o.newBackupCodes(e),onChanged:f}),a.length>0&&(0,R.jsx)(fp,{providers:a,linked:s.linked,onConnect:i,error:d&&of(d,a.length===1?a[0].name:L(`theProvider`))})]}):l?(0,R.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:l}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,L(`loading`)]})]})},hm=()=>[{value:`allowed`,label:L(`on`)},{value:`forbidden`,label:L(`off`)}],gm=()=>[{value:`allowed`,label:L(`optional`)},{value:`required`,label:L(`required`)},{value:`forbidden`,label:L(`off`)}],_m=()=>[{method:`password`,label:L(`password`),description:L(`passwordDescription`),rules:hm()},{method:`emailCode`,label:L(`emailedSignInCode`),description:L(`emailedSignInCodeDescription`),rules:hm()},{method:`passkey`,label:L(`passkeys`),description:L(`passkeysPolicyDescription`),rules:gm()},{method:`twoFactor`,label:L(`twoFactor`),description:L(`twoFactorPolicyDescription`),rules:gm()},{method:`staffAccess`,label:L(`staffAccess`),description:L(`staffAccessDescription`),rules:[{value:`allowed`,label:L(`on`)},{value:`notify`,label:L(`emailThePerson`)},{value:`forbidden`,label:L(`off`)}]},{method:`platformSignIn`,label:L(`platformSignIn`),description:L(`platformSignInDescription`),rules:hm()}],vm=(e,t)=>{let n=_m().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},ym=({row:e,value:t,onChange:n})=>(0,R.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,R.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))}),bm=({method:e},t,{mail:n,effective:r,policy:i})=>{if(e===`emailCode`&&!n)return L(`codeNeedsMail`);if(e===`password`&&!n&&t.password===`forbidden`)return L(`passwordStaysOn`);if(e===`staffAccess`&&!n&&t.staffAccess===`notify`)return L(`staffNeedsMail`);if(e===`platformSignIn`&&t.platformSignIn===`allowed`&&(t.passkey===`required`||t.twoFactor===`required`))return L(`platformOff`);if(t[e]===i[e]&&r[e]!==i[e])return L(`appliesAs`,vm(e,r[e]))},xm=({operator:e,platformSignIn:t})=>_m().flatMap(n=>n.method===`staffAccess`&&!e?[]:n.method===`platformSignIn`?t?[{...n,label:L(`platformSignInWith`,t)}]:[]:[n]),Sm=({state:e,onSave:t,busy:n,error:r,notice:i})=>{let[a,o]=(0,I.useState)(e.policy),s=xm(e),c=s.some(({method:t})=>a[t]!==e.policy[t]);return(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t(a)},children:[(0,R.jsx)(`ul`,{className:`divide-y rounded-lg border bg-background`,children:s.map(t=>{let n=bm(t,a,e);return(0,R.jsxs)(`li`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h2`,{className:`font-semibold`,children:t.label}),(0,R.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t.description}),n&&(0,R.jsx)(`p`,{className:`mt-1.5 text-xs font-medium text-warning-text`,children:n})]}),(0,R.jsx)(ym,{row:t,value:a[t.method],onChange:e=>o({...a,[t.method]:e})})]},t.method)})}),r&&(0,R.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,R.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.savedAt?e.savedBy?L(`lastSavedBy`,e.savedBy,Kf(Date.parse(e.savedAt))):L(`lastSaved`,Kf(Date.parse(e.savedAt))):L(`neverChanged`)}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[c&&(0,R.jsx)(V,{onClick:()=>o(e.policy),children:L(`reset`)}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:n,disabled:!c,children:L(`save`)})]})]})]})},Cm=(e,t)=>e.endedAt?(0,R.jsx)(dd,{tone:`neutral`,children:L(`stopped`,Kf(Date.parse(e.endedAt)))}):Date.parse(e.expiresAt)<=t?(0,R.jsx)(dd,{tone:`neutral`,children:L(`ended`,Kf(Date.parse(e.expiresAt)))}):(0,R.jsx)(dd,{tone:`amber`,children:L(`signedInUntil`,Kf(Date.parse(e.expiresAt)))}),wm=({signIns:e,operator:t,error:n,now:r=Date.now()})=>(0,R.jsxs)(cp,{title:L(`staffSignIns`),description:L(`staffSignInsDescription`,t),children:[(0,R.jsx)(lp,{message:n}),e&&e.length===0&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:L(`noStaffSignIns`)}),e&&e.length>0&&(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-col gap-1.5 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,R.jsx)(`span`,{className:`font-medium break-all`,children:e.staffName?`${e.staffName} (${e.staff})`:e.staff}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:L(`as`)}),(0,R.jsx)(`span`,{className:`font-medium break-all`,children:e.user})]}),(0,R.jsx)(`p`,{className:`break-words`,children:e.reason}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:Kf(Date.parse(e.startedAt))}),Cm(e,r)]})]},e.id))})]}),Tm=({operator:e})=>{let{session:t}=B(),[n,r]=(0,I.useState)(),[i,a]=(0,I.useState)();return(0,I.useEffect)(()=>{t.staff.log().then(r,e=>a(e instanceof Dc?ef(e):L(`couldNotReadStaffSignIns`)))},[t]),(0,R.jsx)(wm,{operator:e,signIns:n,error:i})},Em=()=>{let{session:e}=B(),[t,n]=(0,I.useState)(),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(),[s,c]=(0,I.useState)();(0,I.useEffect)(()=>{e.signInPolicy.read().then(n,e=>o(e instanceof Dc?ef(e):L(`couldNotReadPolicy`)))},[e]);let l=async t=>{i(!0),o(void 0),c(void 0);try{n(await e.signInPolicy.save(t)),c(L(`policySaved`))}catch(e){if(!(e instanceof Dc))throw e;o(ef(e))}i(!1)};return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,R.jsx)(Jd,{title:L(`signInPolicy`),subtitle:L(`policySubtitle`)}),t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Sm,{state:t,busy:r,error:a,notice:s,onSave:e=>void l(e)},t.savedAt??`default`),t.operator&&(0,R.jsx)(Tm,{operator:t.operator})]}):a?(0,R.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:a}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,L(`loading`)]})]})},Dm=I.createContext(void 0),Om=e=>{let t=I.useContext(Dm);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},km=({client:e,children:t})=>(I.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,R.jsx)(Dm.Provider,{value:e,children:t})),Am={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},jm=new class{#e=Am;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 Une(e){setTimeout(e,0)}var Wne=typeof window>`u`||`Deno`in globalThis;function Mm(){}function Gne(e,t){return typeof e==`function`?e(t):e}function Nm(e){return typeof e==`number`&&e>=0&&e!==1/0}function Pm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Fm(e,t){return typeof e==`function`?e(t):e}function Im(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Rm(o,t.options))return!1}else if(!Bm(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 Lm(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(zm(t.options.mutationKey)!==zm(a))return!1}else if(!Bm(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Rm(e,t){return(t?.queryKeyHashFn||zm)(e)}function zm(e){return JSON.stringify(e,(e,t)=>Wm(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Bm(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(!Bm(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Bm(e[r],t[r]))return!1;return!0}return!1}var Kne=Object.prototype.hasOwnProperty;function Vm(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Um(e)&&Um(t);if(!r&&!(Wm(e)&&Wm(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:Kne.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Vm(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Hm(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 Um(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Wm(e){if(!Gm(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!(!Gm(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function Gm(e){return Object.prototype.toString.call(e)===`[object Object]`}function qne(e){return new Promise(t=>{jm.setTimeout(t,e)})}function Km(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Vm(e,t)}function qm(e){return e}function Jne(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Yne(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Jm=Symbol();function Ym(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Jm?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Xm(e,t){return typeof e==`function`?e(...t):!!e}function Xne(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 Zne=()=>Wne,Zm=()=>Zne(),Qm=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(){}},$m=new class extends Qm{#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`}},Qne=Une;function $ne(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Qne,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 eh=$ne(),th=new class extends Qm{#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 ere(e){return Math.min(1e3*2**e,3e4)}function nh(e){return(e??`online`)!==`online`||th.isOnline()}var rh=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ih(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(Mm);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new rh(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>$m.isFocused()&&(e.networkMode===`always`||th.isOnline())&&e.canRun(),p=()=>nh(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??(Zm()?0:3),a=e.retryDelay??ere,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),qne(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 ah=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Nm(this.gcTime)&&(this.#e=jm.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Zm()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(jm.clearTimeout(this.#e),this.#e=void 0)}};function tre(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=>{Xne(e,()=>t.signal,()=>n=!0)},u=Ym(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?Yne:Jne;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?sh:oh,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:oh(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 oh(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 sh(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function nre(e,t){return t?oh(e,t)!=null:!1}function rre(e,t){return!t||!e.getPreviousPageParam?!1:sh(e,t)!=null}var ire=class extends ah{#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=uh(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=uh(this.options);e.data!==void 0&&(this.setState(lh(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Km(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(Mm).catch(Mm):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=>Fm(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Jm||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Fm(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:!Pm(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=Ym(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`?tre(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=ih({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof rh&&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 rh){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,...ch(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...lh(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),eh.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function ch(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:nh(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function lh(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function uh(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 Qm{#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),fh(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ph(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ph(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 Fm(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&&!Hm(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&mh(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||Fm(this.options.enabled,this.#t)!==Fm(t.enabled,this.#t)||Fm(this.options.staleTime,this.#t)!==Fm(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Fm(this.options.enabled,this.#t)!==Fm(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 Hm(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(Mm)),t}#h(e){return!Zm()&&Fm(this.options.enabled,this.#t)!==!1&&Nm(e)}#g(){this.#b();let e=Fm(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=Pm(this.#r.dataUpdatedAt,e)+1;this.#u=jm.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return Fm(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=jm.setInterval(()=>{(this.options.refetchIntervalInBackground||$m.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(jm.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(jm.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&&fh(e,t),o=i&&mh(e,n,t,r);(a||o)&&(l={...l,...ch(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=Km(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=Km(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:hh(e,t),refetch:this.refetch,isEnabled:Fm(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),Hm(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)})})();eh.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 are(e,t){return Fm(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Fm(t.retryOnMount,e)!==!1)}function fh(e,t){return are(e,t)||e.state.data!==void 0&&ph(e,t,t.refetchOnMount)}function ph(e,t,n){if(Fm(t.enabled,e)!==!1&&Fm(t.staleTime,e)!==`static`){let r=Fm(n,e);return r===`always`||r!==!1&&hh(e,t)}return!1}function mh(e,t,n,r){return(e!==t||Fm(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&hh(e,n)}function hh(e,t){return Fm(t.enabled,e)!==!1&&e.isStaleByTime(Fm(t.staleTime,e))}var ore=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:nre(t,n.data),hasPreviousPage:rre(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},sre=class extends ah{#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||gh(),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=ih({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),eh.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function gh(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var cre=class extends Qm{#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 sre({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=_h(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=_h(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=_h(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=_h(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){eh.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=>Lm(t,e))}findAll(e={}){return this.getAll().filter(t=>Lm(e,t))}notify(e){eh.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return eh.batch(()=>Promise.all(e.map(e=>e.continue().catch(Mm))))}};function _h(e){return e.options.scope?.id}var lre=class extends Qm{#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),Hm(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&zm(t.mutationKey)!==zm(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??gh();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){eh.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 vh(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var ure=class extends Qm{#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,eh.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||!Hm(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(vh(e,n).forEach(e=>{e.destroy()}),vh(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=Vm(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)&&eh.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},dre=class extends Qm{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??Rm(r,t),a=this.get(i);return a||(a=new ire({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(){eh.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=>Im(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Im(e,t)):t}notify(e){eh.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){eh.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){eh.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},fre=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new dre,this.#t=e.mutationCache||new cre,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=$m.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=th.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(Fm(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=Gne(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return eh.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;eh.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return eh.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=eh.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Mm).catch(Mm)}invalidateQueries(e,t={}){return eh.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=eh.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(Mm)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Mm)}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(Fm(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(Fm(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Mm).catch(Mm)}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(Mm).catch(Mm)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return th.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(zm(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Bm(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(zm(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Bm(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||=Rm(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===Jm&&(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()}},yh=I.createContext(!1),bh=()=>I.useContext(yh);yh.Provider;function pre(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var mre=I.createContext(pre()),xh=()=>I.useContext(mre),Sh=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Xm(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},Ch=e=>{I.useEffect(()=>{e.clearReset()},[e])},wh=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Xm(n,[e.error,r])),Th=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))}},Eh=(e,t)=>e?.suspense&&t.isPending,Dh=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Oh({queries:e,...t},n){let r=Om(n),i=bh(),a=xh(),o=t.subscribed!==!1,s=I.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=>{Th(e);let t=r.getQueryCache().get(e.queryHash);Sh(e,a,t)}),Ch(a);let[c]=I.useState(()=>new ure(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;I.useSyncExternalStore(I.useCallback(e=>f?c.subscribe(eh.batchCalls(e)):Mm,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),I.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>Eh(s[t],e))?l.flatMap((e,t)=>{let n=s[t];return n&&Eh(n,e)?Dh(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&&wh({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 kh(e,t,n){let r=bh(),i=xh(),a=Om(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Th(o),Sh(o,i,s),Ch(i);let[l]=I.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(I.useSyncExternalStore(I.useCallback(e=>{let t=d?l.subscribe(eh.batchCalls(e)):Mm;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),I.useEffect(()=>{l.setOptions(o)},[o,l]),Eh(o,u))throw Dh(o,l,i);if(wh({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function Ah(e,t){return kh(e,dh,t)}function jh(e,t){let n=Om(t),[r]=I.useState(()=>new lre(n,e));I.useEffect(()=>{r.setOptions(e)},[r,e]);let i=I.useSyncExternalStore(I.useCallback(e=>r.subscribe(eh.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=I.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(Mm)},[r]);if(i.error&&Xm(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Mh(e,t){return kh(e,ore,t)}var hre=()=>{let e=0;return{refetchOnWindowFocus:()=>e>0?!1:`always`,paused:()=>e>0,pause:()=>{e+=1;let t=!1;return()=>{t||(t=!0,--e)}}}},Nh=(0,I.createContext)(null),gre=e=>{let t=(0,I.useContext)(Nh);(0,I.useEffect)(()=>e&&t?t.pause():void 0,[e,t])},_re=e=>{let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),window.addEventListener(`focus`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t),window.removeEventListener(`focus`,t)}},H={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]},Ph=(0,I.createContext)(null),Fh=(0,I.createContext)(null),Ih=(0,I.createContext)(null),U=()=>{let e=(0,I.useContext)(Ph);if(!e)throw Error(`useClient must be used inside ApiProvider`);return e},Lh=e=>{let t=U();return(0,I.useContext)(Ih)?.(e)??t},vre=()=>{let e=U(),t=(0,I.useContext)(Ih);return(0,I.useCallback)(n=>t?.(n)??e,[e,t])},yre=()=>{let e=(0,I.useContext)(Fh);if(!e)throw Error(`useSourceClients must be used inside ApiProvider`);return e},bre=({client:e,resourceClient:t,children:n})=>(0,R.jsx)(Ph.Provider,{value:e,children:(0,R.jsx)(Ih.Provider,{value:t,children:n})}),Rh=({baseUrl:e,client:t,sources:n,fetch:r,queryClient:i,token:a,onUnauthenticated:o,children:s})=>{let[c]=(0,I.useState)(hre),[l]=(0,I.useState)(()=>i??new fre({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:c.refetchOnWindowFocus}}}));(0,I.useEffect)(()=>$m.setEventListener(_re),[]);let u=(0,I.useRef)(void 0),d=(0,I.useMemo)(()=>t??dc({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:H.meta},{cancelRefetch:!1})}}),[t,e,r,l,a,o]),f=(0,I.useMemo)(()=>{let e=new Map;return t=>{let i=n?.[t.url]??e.get(t.url);if(i)return i;let o,s=dc({baseUrl:t.url,fetch:r,token:a,onMetaVersion:e=>{let n=o;o=e,n!==void 0&&n!==e&&l.invalidateQueries({queryKey:H.sourceMetas(t.url)},{cancelRefetch:!1})}});return e.set(t.url,s),s}},[n,r,a,l]);return(0,R.jsx)(km,{client:l,children:(0,R.jsx)(Ph.Provider,{value:d,children:(0,R.jsx)(Fh.Provider,{value:f,children:(0,R.jsx)(Nh.Provider,{value:c,children:s})})})})},W=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`}}),zh=(0,I.createContext)(null),Bh=()=>{let e=(0,I.useContext)(zh);if(!e)throw Error(`useRouter must be used inside Router`);return e},Vh=()=>`${window.location.pathname}${window.location.search}`,Hh=e=>new URL(e,`http://local`).pathname,Uh=()=>window.history.state??{},Wh=()=>Uh().protobaseIndex??0,Gh=()=>Math.random().toString(36).slice(2),Kh=()=>{let e=Uh();if(e.protobaseEntry)return e.protobaseEntry;let t=Gh();return window.history.replaceState({...e,protobaseEntry:t},``),t},xre=({basePath:e=``,initialUrl:t,children:n})=>{let r=t!==void 0,[i,a]=(0,I.useState)(()=>({url:t??Vh(),entry:r?Gh():Kh()})),o=(0,I.useRef)(new Set),s=(0,I.useRef)(i);s.current=i;let c=(0,I.useRef)(r?0:Wh()),l=(0,I.useRef)(!1),u=(0,I.useRef)(!1),d=(0,I.useRef)(void 0),[f,p]=(0,I.useState)();(0,I.useEffect)(()=>{if(r)return;window.history.replaceState({protobaseIndex:c.current,protobaseEntry:s.current.entry},``);let e=()=>{let e=Wh();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=Hh(Vh())!==Hh(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:Vh(),entry:Kh()})};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[r]);let m=(0,I.useCallback)((e,t)=>{let n=t?s.current.entry:Gh();r||(c.current+=+!t,window.history[t?`replaceState`:`pushState`]({protobaseIndex:c.current,protobaseEntry:n},``,e)),a({url:e,entry:n})},[r]),h=(0,I.useCallback)((t,{replace:n=!1}={})=>{let r=`${e}${t}`;if(Hh(r)!==Hh(s.current.url)&&o.current.size>0)return p({kind:`link`,full:r,replace:n});m(r,n)},[e,m]),g=(0,I.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,I.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,R.jsxs)(zh.Provider,{value:v,children:[n,f&&(0,R.jsx)(sp,{title:W(`leaveTitle`),description:W(`leaveDescription`),onClose:()=>p(void 0),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:()=>p(void 0),children:W(`stay`)}),(0,R.jsx)(V,{variant:`primary`,onClick:_,children:W(`leave`)})]})})]})},Sre=({to:e,replace:t,...n})=>{let{navigate:r,basePath:i}=Bh();return(0,R.jsx)(Ku,{to:{href:`${i}${e}`,onFollow:()=>r(e,{replace:t})},...n})},Cre=e=>{let{registerGuard:t}=Bh();(0,I.useEffect)(()=>e?t():void 0,[e,t]),(0,I.useEffect)(()=>{if(!e)return;let t=e=>e.preventDefault();return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e])},qh=({title:e,description:t,size:n=`sm`,children:r})=>(0,R.jsx)(`div`,{className:`flex min-h-full w-full items-center justify-center bg-surface px-4 py-10`,children:(0,R.jsxs)(`div`,{className:g(`w-full`,n===`sm`?`max-w-sm`:`max-w-lg`),children:[(0,R.jsxs)(`div`,{className:`mb-6 flex flex-col items-center text-center`,children:[(0,R.jsx)(Xu,{className:`size-10`}),(0,R.jsx)(`h1`,{className:`mt-4 text-xl font-semibold tracking-tight`,children:e}),t&&(0,R.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]}),(0,R.jsx)(`div`,{className:`rounded-lg border bg-background p-5 shadow-sm`,children:r})]})}),Jh=({onResend:e,cooldown:t=30,disabled:n})=>{let[r,i]=(0,I.useState)(()=>Date.now()+t*1e3),[a,o]=(0,I.useState)(()=>Date.now()),s=Math.max(0,Math.ceil((r-a)/1e3));return(0,I.useEffect)(()=>{if(s===0)return;let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[s]),(0,R.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?z(`sendNewCodeIn`,s):z(`sendNewCode`)})},Yh=({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,I.useState)(``);return(0,R.jsxs)(qh,{title:e,description:t,children:[(0,R.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:n}),u&&(0,R.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,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),i(f)},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`code`),(0,R.jsx)(yp,{name:`code`,required:!0,autoFocus:!0,value:f,invalid:!!l,onChange:p,onComplete:e=>!c&&i(e)})]}),l&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:l}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:c,className:`min-h-10`,children:r}),(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-x-2 sm:justify-between`,children:[(0,R.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:s}),(0,R.jsx)(Jh,{onResend:a,disabled:c,cooldown:d})]})]})]})},Xh=(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,R.jsx)(R.Fragment,{children:n.map((e,n)=>(0,R.jsxs)(I.Fragment,{children:[e,n<t.length&&t[n]]},n))})},wre=({email:e,onBack:t,...n})=>(0,R.jsx)(Yh,{title:z(`checkEmail`),description:z(`signInCodeDescription`),explanation:(0,R.jsx)(R.Fragment,{children:Xh(z(`signInCodeSent`),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),submitLabel:z(`signIn`),onChangeAddress:t,changeAddressLabel:z(`backToSignIn`),...n}),Tre=({email:e,onBack:t})=>{let{signInWithCode:n,sendSignInCode:r}=B(),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(),[c,l]=(0,I.useState)(),u=async e=>{a(!0),s(void 0),l(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;s(ef(e))}a(!1)};return(0,R.jsx)(wre,{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(z(`newCodeSent`))})})},Ere=`protobase users create you@example.com`,Dre=({command:e=Ere,onCheckAgain:t,busy:n})=>{let[r,i]=(0,I.useState)(!1);return(0,R.jsxs)(qh,{title:z(`noAdminTitle`),description:z(`noAdminDescription`),children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`noAdminExplanation`)}),(0,R.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,R.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-xs`,children:e}),(0,R.jsx)(`button`,{type:`button`,"aria-label":z(`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,R.jsx)(Ci,{className:`size-4 text-success`}):(0,R.jsx)(zi,{className:`size-4`})})]}),(0,R.jsx)(V,{variant:`primary`,className:`mt-4 min-h-10 w-full`,loading:n,onClick:t,children:z(`reload`)})]})},Ore=({onSubmit:e,back:t,busy:n,error:r,sentTo:i})=>{let[a,o]=(0,I.useState)(``);return i?(0,R.jsxs)(qh,{title:z(`checkEmail`),children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Xh(z(`resetSent`),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:i}))}),(0,R.jsx)(Ku,{to:t,className:g(op({variant:`primary`}),`mt-4 min-h-10 w-full`),children:z(`backToSignIn`)})]}):(0,R.jsx)(qh,{title:z(`resetTitle`),description:z(`resetDescription`),children:(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(a.trim())},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`email`),(0,R.jsx)(Rd,{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,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:r}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:n,className:`min-h-10`,children:z(`sendResetLink`)}),(0,R.jsx)(Ku,{to:t,className:g(op({variant:`ghost`}),`min-h-10`),children:z(`backToSignIn`)})]})})},Zh=`password-reset`,kre=e=>{let t=new URL(e);return`${t.origin}${t.pathname}?${Zh}`},Are=e=>{let t=new URL(e).searchParams;if(t.has(`password-reset`))return{token:t.get(`token`)||void 0}},jre=e=>{let t=new URL(e);for(let e of[Zh,`token`,`error`])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},Mre=({back:e})=>{let{session:t}=B(),[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(),[o,s]=(0,I.useState)(),c=async e=>{r(!0),a(void 0);try{await t.requestPasswordReset(e,kre(window.location.href)),s(e)}catch(e){if(!(e instanceof Dc))throw e;a(e.status===429?z(`tooManyRequests`):e.message)}r(!1)};return(0,R.jsx)(Ore,{busy:n,error:i,sentTo:o,back:e,onSubmit:e=>void c(e)})},Nre=({name:e,workspace:t})=>(0,R.jsx)(qh,{title:z(`signingInWith`,e),description:t,children:(0,R.jsxs)(`p`,{role:`status`,className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,z(`takingYouTo`,e)]})}),Pre=({provider:e,workspace:t,onFailed:n})=>{let{signInProviders:r,signInSocial:i}=B(),a=r.find(t=>t.id===e),o=a?.name??pf(e),s=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{if(!s.current){if(s.current=!0,!a)return n(z(`providerNotOffered`,o));i(e).catch(e=>{if(!(e instanceof Dc))throw e;n(tf(e))})}},[a,o,e,i,n]),(0,R.jsx)(Nre,{name:o,workspace:t})},Fre=({onSubmit:e,invalidLink:t,onRequestNewLink:n,onBack:r,busy:i,error:a})=>{let[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(!1);if(t)return(0,R.jsxs)(qh,{title:z(`linkExpiredTitle`),children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`linkExpiredExplanation`)}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[n&&(0,R.jsx)(V,{variant:`primary`,className:`min-h-10`,onClick:n,children:z(`sendNewLink`)}),(0,R.jsx)(V,{variant:n?`ghost`:`primary`,className:`min-h-10`,onClick:r,children:z(`backToSignIn`)})]})]});let f=u?z(`passwordsDiffer`):a;return(0,R.jsx)(qh,{title:z(`choosePassword`),description:z(`atLeast`,12),children:(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),d(o!==c),o===c&&e(o)},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`newPassword`),(0,R.jsx)(Rd,{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,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`repeatPassword`),(0,R.jsx)(Rd,{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,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:z(`setPassword`)})]})})},Ire=e=>e.status===429?z(`tooManyAttempts`):e.code===`PASSWORD_TOO_SHORT`?z(`useAtLeast`,12):e.code===`PASSWORD_TOO_LONG`?z(`passwordTooLong`):e.message,Lre=({token:e,onDone:t,onRequestNewLink:n,onBack:r})=>{let{session:i}=B(),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(),[l,u]=(0,I.useState)(!e),d=async n=>{o(!0),c(void 0);try{await i.resetPassword(e,n),t()}catch(e){if(!(e instanceof Dc))throw e;e.code===`INVALID_TOKEN`?u(!0):c(Ire(e)),o(!1)}};return(0,R.jsx)(Fre,{busy:a,error:s,invalidLink:l,onRequestNewLink:n,onBack:r,onSubmit:e=>void d(e)})},Rre=e=>z(e===`twoFactor`?`turnOnTwoFactor`:`addPasskey`),zre=({step:e,twoFactor:t,onAddPasskey:n,busy:r,error:i,onSignOut:a})=>(0,R.jsxs)(qh,{title:Rre(e),description:z(`requiredForEveryAccount`),children:[e===`twoFactor`?(0,R.jsx)(um,{...t}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`passkeyExplanation`)}),i&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,R.jsxs)(V,{variant:`primary`,loading:r,onClick:n,className:`min-h-10`,children:[(0,R.jsx)(pa,{className:`size-4`}),z(`addPasskey`)]})]}),(0,R.jsx)(`button`,{type:`button`,onClick:a,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:underline`,children:z(`signOut`)})]}),Bre=({missing:e})=>{let{session:t,recheck:n,signOut:r}=B(),[i,a]=(0,I.useState)(),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)();(0,I.useEffect)(()=>{t.account.signInMethods().then(a,e=>l(e instanceof Dc?ef(e):z(`couldNotReadAccount`)))},[t]);let u=async()=>{s(!0),l(void 0);try{await t.account.addPasskey(),n()}catch(e){if(!(e instanceof Dc))throw e;l(ef(e)),s(!1)}};return!i&&!c?(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,z(`loading`)]}):(0,R.jsx)(zre,{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}})},Vre=({className:e})=>(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:g(`size-4 shrink-0`,e),"aria-hidden":!0,children:(0,R.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`})}),Hre=({id:e,className:t})=>e===`github`?(0,R.jsx)(Vre,{className:t}):null,Ure=()=>(0,R.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`h-px flex-1 bg-border`}),z(`or`),(0,R.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),Wre=({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,I.useState)(``),[g,_]=(0,I.useState)(``),v=(0,I.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,R.jsxs)(qh,{title:z(`signInTitle`),description:r,children:[i&&(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[S.map(e=>(0,R.jsxs)(V,{onClick:()=>d?.(e.id),disabled:t,className:`min-h-10 w-full`,children:[(0,R.jsx)(Hre,{id:e.id}),z(`continueWith`,e.name)]},e.id)),x&&(0,R.jsxs)(V,{onClick:()=>s?.(),disabled:t,className:`min-h-10 w-full`,children:[(0,R.jsx)(pa,{className:`size-4`}),z(`signInWithPasskey`)]}),x&&c.slice(1).map(e=>(0,R.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>s?.(e),disabled:t,className:`w-full`,children:z(`passkeyFor`,e)},e))]}),y||b?(0,R.jsx)(Ure,{}):n&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-4 text-body font-medium text-danger-text`,children:n})]}),(y||b)&&(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),y?e(m.trim(),g):C()},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`email`),(0,R.jsx)(Rd,{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,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`password`),(0,R.jsx)(Rd,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:g,invalid:!!n,onChange:e=>_(e.target.value),className:`min-h-6`})]}),n&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:n}),y&&(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:t,className:`min-h-10`,children:z(`signIn`)}),b&&(0,R.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,R.jsx)(Na,{className:`size-4`}),z(`emailSignInCode`)]}),y&&l&&(0,R.jsx)(Ku,{to:l,className:`self-center font-medium text-primary-text hover:underline`,children:z(`forgotPassword`)})]}),f&&(0,R.jsxs)(`p`,{className:`mt-4 text-center text-muted-foreground`,children:[z(`newHere`),` `,(0,R.jsx)(Ku,{to:f,className:`font-medium text-primary-text hover:underline`,children:z(`createAnAccount`)})]}),p&&(0,R.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:z(`browse`)})]})},Gre=({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}=B(),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(o),v=async(e,t)=>{h(!0),_(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;_(t(e)),h(!1)}};return(0,R.jsx)(Wre,{busy:m,error:g,workspace:e,notice:t,methods:u,forgotPassword:n,signUp:r,onBrowse:i,providers:l,onContinueWith:e=>void v(()=>c(e),tf),passkeyDomains:d,onPasskey:e=>void v(()=>p(e),ef),onSendCode:e=>void v(async()=>{await f(e),a(e)},ef),onSubmit:(e,t)=>void v(()=>s(e,t),tf)})},Kre=({email:e,onBack:t,...n})=>(0,R.jsx)(Yh,{title:z(`checkEmail`),description:z(`signUpCodeDescription`),explanation:(0,R.jsx)(R.Fragment,{children:Xh(z(`signUpCodeSent`),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),submitLabel:z(`continue`),onChangeAddress:t,changeAddressLabel:z(`useAnotherAddress`),...n}),qre=({email:e,onSubmit:t,onBack:n,methods:r,busy:i,error:a})=>{let[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),u=(0,I.useId)(),d=r.includes(`password`),f=r.includes(`emailCode`);return(0,R.jsxs)(qh,{title:z(`detailsTitle`),description:z(`detailsDescription`),children:[(0,R.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:Xh(z(`codeWasRight`),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({name:o.trim(),...d&&c&&{password:c}})},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`yourName`),(0,R.jsx)(Rd,{name:`name`,autoComplete:`name`,required:!0,autoFocus:!0,maxLength:200,value:o,onChange:e=>s(e.target.value),className:`min-h-6`})]}),d&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(f?`passwordOptional`:`password`),(0,R.jsx)(Rd,{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,R.jsxs)(`p`,{id:u,className:`text-xs text-muted-foreground`,children:[z(`atLeast`,12),f&&z(`withoutPassword`)]})]}),a&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:z(`createAccount`)}),(0,R.jsx)(V,{variant:`ghost`,onClick:n,className:`min-h-10`,children:z(`useAnotherAddress`)})]})]})},Jre=({onSubmit:e,onSignIn:t,onBrowse:n,busy:r,error:i,workspace:a})=>{let[o,s]=(0,I.useState)(``);return(0,R.jsxs)(qh,{title:z(`createAnAccount`),description:a,children:[(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(o.trim())},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`email`),(0,R.jsx)(Rd,{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,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`codeToConfirm`)}),i&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,R.jsxs)(V,{variant:`primary`,type:`submit`,loading:r,className:`min-h-10`,children:[(0,R.jsx)(Na,{className:`size-4`}),z(`emailCode`)]}),(0,R.jsxs)(`p`,{className:`text-center text-muted-foreground`,children:[z(`haveAccount`),` `,(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`font-medium text-primary-text hover:underline`,children:z(`signIn`)})]})]}),n&&(0,R.jsx)(`button`,{type:`button`,onClick:n,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:z(`browseWithoutAccount`)})]})},Yre=({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}=B(),[f,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(),[g,_]=(0,I.useState)(),v=async e=>{p(!0),h(void 0),_(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;h(ef(e))}p(!1)};return t===void 0?(0,R.jsx)(Jre,{workspace:e,busy:f,error:m,onSignIn:o,onBrowse:s,onSubmit:e=>void v(async()=>{await l(e),r(e)})}):n===void 0?(0,R.jsx)(Kre,{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),_(z(`newCodeSent`))})}):(0,R.jsx)(qre,{email:t,methods:c,busy:f,error:m,onBack:a,onSubmit:e=>void v(()=>d({ticket:n,...e}))})},Qh=`staff-sign-in`,$h=`staff-error`,Xre=e=>{let t=new URL(e).searchParams,n=t.get($h);if(!t.has(`staff-sign-in`)&&!n)return;let r=t.has(Qh);return{email:r&&t.get(`email`)||``,reason:r&&t.get(`reason`)||``,...n&&{error:n}}},eg=e=>{let t=new URL(e);if(t.searchParams.has(`staff-sign-in`))for(let e of[Qh,`email`,`reason`])t.searchParams.delete(e);return t.searchParams.delete($h),`${t.pathname}${t.search}${t.hash}`},Zre=10,Qre=({operator:e,email:t=``,reason:n=``,onSubmit:r,onBack:i,busy:a,error:o})=>{let[s,c]=(0,I.useState)(t),[l,u]=(0,I.useState)(n);return e?(0,R.jsx)(qh,{title:z(`signInAsPerson`),description:z(`forStaffOf`,e),children:(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),r(s.trim(),l.trim())},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`theirEmail`),(0,R.jsx)(Rd,{type:`email`,name:`email`,required:!0,autoFocus:!t,value:s,onChange:e=>c(e.target.value),className:`min-h-6`})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`reason`),(0,R.jsx)(`textarea`,{name:`reason`,required:!0,minLength:Zre,rows:3,value:l,placeholder:z(`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,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:z(`staffExplanation`,e)}),o&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:o}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:a,className:`min-h-10`,children:z(`continueWith`,e)}),(0,R.jsx)(V,{variant:`ghost`,onClick:i,className:`min-h-10`,children:z(`backToSignIn`)})]})}):(0,R.jsxs)(qh,{title:z(`staffTitle`),description:z(`staffUnavailable`),children:[o&&(0,R.jsx)(`p`,{role:`alert`,className:`mb-4 text-body font-medium text-danger-text`,children:o}),(0,R.jsx)(V,{variant:`primary`,className:`min-h-10 w-full`,onClick:i,children:z(`backToSignIn`)})]})},$re=({link:e,onBack:t})=>{let{session:n,staffSignIn:r}=B(),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(e.error&&rf(e.error)),c=async(e,t)=>{a(!0),s(void 0);try{let r=`${window.location.origin}${eg(window.location.href)}`;window.location.assign(await n.staff.start({email:e,reason:t,callbackURL:r}))}catch(e){if(!(e instanceof Dc))throw e;s(rf(e)),a(!1)}};return(0,R.jsx)(Qre,{operator:r,email:e.email,reason:e.reason,busy:i,error:o,onBack:t,onSubmit:(e,t)=>void c(e,t)})},tg=({checked:e,indeterminate:t,onChange:n,label:r,disabled:i,className:a})=>(0,R.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,R.jsx)(Va,{className:`size-3`,strokeWidth:3}):e&&(0,R.jsx)(Ci,{className:`size-3`,strokeWidth:3})}),eie={totp:`totpInstruction`,otp:`otpInstruction`,backup:`backupInstruction`},tie=({methods:e,onVerify:t,onSendCode:n,onBack:r,busy:i,error:a,codeSent:o,initialStep:s})=>{let[c,l]=(0,I.useState)(s??(e.includes(`totp`)?`totp`:`otp`)),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(!1),m=c===`otp`&&!o,h=e=>{l(e),d(``),e===`otp`&&!o&&n()};return(0,R.jsxs)(qh,{title:z(`twoFactorTitle`),description:z(`twoFactorDescription`),children:[m?(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`codeToFinish`)}),a&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,R.jsx)(V,{variant:`primary`,loading:i,onClick:n,className:`min-h-10`,children:z(`emailCode`)})]}):(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({method:c,code:u.trim(),trustDevice:f})},children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(eie[c])}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(c===`backup`?`backupCode`:`code`),c===`backup`?(0,R.jsx)(Rd,{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,R.jsx)(yp,{name:`code`,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:d})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(tg,{checked:f,onChange:p,label:z(`trustBrowser`)}),z(`trustBrowserFor`)]}),a&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:z(`verify`)})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-col items-center gap-2 border-t pt-4`,children:[c!==`totp`&&e.includes(`totp`)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(`totp`),className:`font-medium text-primary-text hover:underline`,children:z(`useAuthenticator`)}),c!==`otp`&&e.includes(`otp`)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(`otp`),className:`font-medium text-primary-text hover:underline`,children:z(`emailCodeInstead`)}),c!==`backup`&&e.includes(`totp`)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(`backup`),className:`font-medium text-primary-text hover:underline`,children:z(`useBackupCode`)}),(0,R.jsx)(`button`,{type:`button`,onClick:r,className:`font-medium text-muted-foreground hover:underline`,children:z(`backToSignIn`)})]})]})},nie=({methods:e,onBack:t})=>{let{verifyTwoFactor:n,session:r}=B(),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(),[c,l]=(0,I.useState)(!1),u=async e=>{a(!0),s(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;s(ef(e))}a(!1)};return(0,R.jsx)(tie,{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)})})},ng=()=>{let{path:e,params:t,basePath:n,navigate:r}=Bh(),i=(0,I.useMemo)(()=>Fs(e,t),[e,t]),a=df(new URL(t.size>0?`${e}?${t}`:e,`http://local`).href),o=i?i.next:a,s=(0,I.useCallback)((e=`sign-in`,t)=>r(Ps({step:e,next:o}),t),[r,o]);return{address:i,next:o,open:s,link:(0,I.useCallback)((e=`sign-in`,t)=>({href:`${n}${Ps({step:e,next:o})}`,onFollow:()=>s(e,t)}),[n,o,s]),leave:(0,I.useCallback)(()=>r(o??`/`,{replace:!0}),[r,o])}},rie=e=>{let t=new URL(e),n=t.searchParams.get(`token`);return t.pathname.endsWith(`/-/invitation`)&&n?{token:n}:void 0},iie=e=>`${new URL(e).pathname.slice(0,-13)}/`,G=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`}}),rg=`/-/organizations`,ig=`/-/organization`,ag=`/-/organization/members`,og=`/-/organization/invitations`,aie={[rg]:`organizations`,[ig]:`organization`,[ag]:`members`,[og]:`invitations`},oie=e=>{let t=aie[e];return t&&G(t)},sg=e=>G(e),cg=(e,t)=>e.find(e=>e.name===t)?.label??t,lg=e=>e?.role===`owner`||e?.role===`admin`,sie=(e,t,n)=>{let r=(n,r,i,a)=>({id:n,label:r,icon:i,href:`${e}${a}`,active:t===a});return[r(`organizations`,G(`organizations`),Ka,rg),...n?.organization?[r(`organization`,G(`organization`),gi,ig)]:[],...lg(n)?[r(`members`,G(`members`),as,ag),r(`invitations`,G(`invitations`),Na,og)]:[]]},ug=(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)))},dg=()=>{let[e,t]=(0,I.useState)(!1),[n,r]=(0,I.useState)();return{busy:e,error:n,run:async e=>{t(!0),r(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;r(ef(e))}t(!1)},setError:r}},fg=({token:e,preview:t,joins:n,onDone:r})=>{let{session:i,signInMethods:a,recheck:o}=B(),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(``),{busy:d,error:f,run:p}=dg(),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,R.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:G(n?`makeAccountToJoin`:`makeAccount`,t.email)}),f&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,R.jsx)(Rd,{"aria-label":G(`yourName`),placeholder:G(`yourName`),autoComplete:`name`,value:s,onChange:e=>c(e.target.value)}),m&&(0,R.jsx)(Rd,{"aria-label":G(`password`),type:`password`,autoComplete:`new-password`,placeholder:G(h?`passwordOptional`:`passwordRequired`,12),value:l,onChange:e=>u(e.target.value)}),(0,R.jsx)(V,{type:`submit`,variant:`primary`,loading:d,disabled:!s.trim()||m&&!h&&l.length<12,children:G(n?`createAndJoin`:`createYourAccount`)})]})},cie=({token:e,onDone:t,signIn:n})=>{let{session:r,state:i,signOut:a,organizations:o}=B(),[s,c]=(0,I.useState)(),[l,u]=(0,I.useState)(),{busy:d,error:f,run:p}=dg();if((0,I.useEffect)(()=>{r.organizations.invitation(e).then(c,e=>u(e instanceof Dc?ef(e):G(`invalidLink`)))},[r,e]),l)return(0,R.jsx)(qh,{title:G(`invitation`),description:l,children:(0,R.jsx)(V,{className:`w-full`,onClick:t,children:G(`goToApp`)})});if(!s)return(0,R.jsx)(qh,{title:G(`invitation`),children:(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,G(`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=G(`invitesToApp`,s.inviter.name,r);return(0,R.jsx)(qh,{title:G(`join`,r),description:i,children:s.hasAccount?m&&h?(0,R.jsx)(V,{variant:`primary`,className:`w-full`,onClick:t,children:G(`goToApp`)}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:G(`hasAccount`,s.email)}),m?(0,R.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:G(`signOut`)}):(0,R.jsx)(Ku,{to:n,className:g(op({variant:`primary`}),`w-full`),children:G(`signInAs`,s.email)})]}):m?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:G(`otherAddress`,s.email,m.email)}),(0,R.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:G(`signOutToAccept`)})]}):(0,R.jsx)(fg,{token:e,preview:s,joins:!1,onDone:t})})}let _=s.organization,v=s.appRoles.map(e=>cg(o?.roles??[],e)),y=sg(s.role).toLowerCase(),b=v.length>0?G(`invitesToWith`,s.inviter.name,_.name,y,v.join(`, `)):G(`invitesTo`,s.inviter.name,_.name,y);return m&&!h?(0,R.jsxs)(qh,{title:G(`join`,_.name),description:b,children:[(0,R.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:G(`otherAddress`,s.email,m.email)}),(0,R.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:G(`signOutToAccept`)})]}):(0,R.jsx)(qh,{title:G(`join`,_.name),description:b,children:m?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,R.jsx)(V,{variant:`primary`,className:`w-full`,loading:d,onClick:()=>void p(async()=>{await r.organizations.accept(e),t()}),children:G(`join`,_.name)})]}):s.hasAccount?(0,R.jsx)(Ku,{to:n,className:g(op({variant:`primary`}),`w-full`),children:G(`signInAsToJoin`,s.email)}):(0,R.jsx)(fg,{token:e,preview:s,joins:!0,onDone:t})})},pg,mg,lie=({dsn:e,environment:t})=>(pg??=m(()=>import(`./prod-YZ9ZMG1O.js`).then(n=>{n.init({dsn:e,...t&&{environment:t},integrations:e=>e.filter(e=>e.name!==`BrowserSession`),beforeSend:e=>Er(e)}),mg=(e,t)=>n.captureException(e,t?{contexts:{react:{componentStack:t}}}:void 0)}),[]),pg),hg=(e,t)=>mg?.(e,t??void 0),gg=({children:e})=>(0,R.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-dashed border-warning bg-warning-soft p-3 text-warning-text`,children:e}),_g=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`}}),vg=class extends I.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){hg(e,t.componentStack)}render(){return this.state.failed?this.props.fallback===void 0?(0,R.jsx)(gg,{children:Xh(_g(`couldNotDraw`),this.props.name)}):this.props.fallback:this.props.children}},uie=/^[A-Z][A-Za-z0-9]*$/,die=e=>typeof e==`function`||typeof e==`object`&&!!e&&`$$typeof`in e,yg=e=>{let t=e.default??{},n=Object.entries(e).filter(e=>e[0]!=="default"&&uie.test(e[0])&&die(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)}}},bg=class extends Error{name=`UiConflictError`},fie=e=>Object.keys(e).some(e=>e==="default"||/^[A-Z]/.test(e))?yg(e):e,xg=(e,t)=>[...(e.extends??[]).map(fie).flatMap((e,n)=>xg(e,e.name??`${t} extends[${n}]`)),{ui:e,label:t}],Sg=(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 bg(`${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},Cg=e=>e.length<=1?e[0]:()=>e.map((e,t)=>(0,R.jsx)(e,{},t)),pie=e=>e.length<=1?e[0]:({children:t,...n})=>e.reduceRight((e,t)=>(0,R.jsx)(t,{...n,children:e}),t),wg=(...e)=>{let t=e.flatMap((e,t)=>xg(e,e.name??`UI config ${t+1}`)),n=Sg(`The component`,t,e=>e.components),r=Sg(`The action handler`,t,e=>e.actions),i=Sg(`The field type`,t,e=>e.fields),a=Sg(`The drop rule`,t,e=>e.dropRules),o=Sg(`The board drop`,t,e=>e.boardDrops),s=Cg(t.flatMap(({ui:e})=>e.shell?.actions?[e.shell.actions]:[])),c=Cg(t.flatMap(({ui:e})=>e.shell?.rightPanel?[e.shell.rightPanel]:[])),l=t.findLast(({ui:e})=>e.shell?.logo)?.ui.shell?.logo,u=pie(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}}},Tg=(e,t)=>{let n=wg(e??{}),r=[],i=[];for(let e of t){if(e.kind===`off`){i.push(e);continue}try{wg(...r,e.ui,n),r.push(e.ui)}catch(t){if(!(t instanceof bg))throw t;i.push({kind:`off`,url:e.plugin.url,name:e.plugin.name,reason:t.message})}}return{ui:r.length===0?n:wg(...r,n),off:i}},Eg=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`}}),Dg=e=>typeof e==`string`&&e.trim()!==``,mie=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return{problem:Eg(`notObject`)};let{name:t,version:n,api:r,protobase:i,entry:a,css:o}=e;return Dg(t)?Number.isInteger(r)?Dg(i)?Dg(a)?o!==void 0&&!Dg(o)?{problem:Eg(`badStylesheet`)}:n!==void 0&&!Dg(n)?{problem:Eg(`badVersion`)}:{manifest:{name:t,api:r,protobase:i,entry:a,...n!==void 0&&{version:n},...o!==void 0&&{css:o}}}:{problem:Eg(`noModule`)}:{problem:Eg(`noVersions`)}:{problem:Eg(`noApi`)}:{problem:Eg(`noName`)}},Og=(0,I.createContext)(null),hie=Og.Provider,gie=()=>{let e=(0,I.useContext)(Og);if(!e)throw Error(`usePlugin is for the components of a plugin the app loaded`);return e},kg=(e,t,n)=>{let r=n=>(0,R.jsx)(hie,{value:e,children:(0,R.jsx)(t,{...n})});return r.displayName=`${e.name}:${n}`,r},_ie=(e,t,n)=>({of:n.of,display:kg(e,n.display,`fields.${t}.display`),...n.editor&&{editor:kg(e,n.editor,`fields.${t}.editor`)},...n.cell&&{cell:kg(e,n.cell,`fields.${t}.cell`)}}),vie=(e,t)=>{let n=wg({...yg(t),name:e.name}),r=Object.fromEntries(Object.entries(n.components??{}).map(([t,n])=>[t,kg(e,n,t)])),i=n.fields&&Object.fromEntries(Object.entries(n.fields).map(([t,n])=>[t,_ie(e,t,n)])),a=n.shell&&{...n.shell.actions&&{actions:kg(e,n.shell.actions,`shell.actions`)},...n.shell.rightPanel&&{rightPanel:kg(e,n.shell.rightPanel,`shell.rightPanel`)},...n.shell.logo&&{logo:kg(e,n.shell.logo,`shell.logo`)}},o=n.beforeSignIn&&kg(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}}},Ag={name:`@protobase/ui`,version:`0.28.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`,prepack:`tsdown && protobase build-shell dist/shell`},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`}},jg=Ag.protobase.pluginApi,Mg=Ag.version,yie={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),[])},bie={api:jg,version:Mg},xie=e=>e instanceof Error?e.message:String(e),Sie=async(e,t,n,r=bie)=>{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(Eg(`answered`,n.status));let s=mie(n.json);if(`problem`in s)return a(s.problem);let{manifest:c}=s;o=c.name;let l=_r(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:vie(d,u)}}catch(e){return a(Eg(`couldNotLoad`,xie(e)),o)}},Cie=e=>{let t=new Map;return{load:n=>{let r=JSON.stringify(n),i=t.get(r);if(i)return i;let a=Sie(n,e,window.location.href);return t.set(r,a),a}}},Ng=(0,I.createContext)(null),wie=({loader:e=yie,children:t})=>{let n=(0,I.useMemo)(()=>Cie(e),[e]);return(0,R.jsx)(Ng.Provider,{value:n,children:t})},Pg=()=>{let e=(0,I.useContext)(Ng);if(!e)throw Error(`usePluginSource must be used inside PluginSourceProvider`);return e},Tie=1e4,Fg=[],Ig=(e,t)=>{let n=JSON.stringify(e),[r,i]=(0,I.useState)({key:`[]`,loads:Fg,settled:!0});return(0,I.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()},Tie);return e.forEach((e,n)=>{t.load(e).then(e=>{o[n]=e,s()})}),()=>{r=!1,clearTimeout(c)}},[n,t]),e.length===0?{loads:Fg,settled:!0}:r.key===n?r:{loads:Fg,settled:!1}},Eie=({children:e})=>{let{state:t,beforeSignIn:n,adoptSession:r}=B(),{path:i,params:a,navigate:o}=Bh(),{loads:s,settled:c}=Ig(n,Pg()),l=(0,I.useMemo)(()=>Tg(void 0,s).ui.beforeSignIn,[s]),u=(0,I.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,R.jsx)(vg,{name:`beforeSignIn`,fallback:e,children:(0,R.jsx)(l,{signedIn:r,params:a,removeParams:u,children:e})}):e:(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,Eg(`loading`)]})},Die=()=>{let e=window.location.href,t=Are(e);if(t)return{kind:`reset-password`,token:t.token};let n=Xre(e);if(n)return{kind:`staff-sign-in`,link:n};let r=rie(e);if(r)return{kind:`invitation`,token:r.token};let i=lf(e);if(i)return{kind:`provider-sign-in`,provider:i};let a=uf(e);return a?{kind:`sign-in`,providerError:a}:{kind:`sign-in`}},Lg=({to:e})=>{let{navigate:t}=Bh();return(0,I.useEffect)(()=>t(e,{replace:!0}),[t,e]),null},Oie=({workspace:e,children:t})=>{let n=kie(e,t);return(0,R.jsx)(Eie,{children:n})},kie=(e,t)=>{let{state:n,recheck:r,passwordReset:i,signOut:a,signInProviders:o,canSignUp:s,browse:c}=B(),{path:l,params:u,basePath:d,navigate:f}=Bh(),{address:p,next:m,open:h,link:g,leave:_}=ng(),[v,y]=(0,I.useState)(Die),[b,x]=(0,I.useState)(),[S,C]=(0,I.useState)(),[w,T]=(0,I.useState)(),E=new URL(`${d}${l}${u.size>0?`?${u}`:``}`,window.location.origin).href,D=(0,I.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,I.useEffect)(()=>{O&&(v.kind===`provider-sign-in`&&D(df),(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&&uf(E)!==void 0;(0,I.useEffect)(()=>{!O&&v.kind===`sign-in`&&v.providerError&&k&&D(df)},[O,v,k,D]);let A=(0,I.useCallback)(e=>y({kind:`sign-in`,error:e}),[]),j=e=>{D(jre),y(e)},M=async()=>{n.kind===`signed-in`&&await a(),j({kind:`sign-in`,notice:z(`passwordChanged`)})},N=()=>{y({kind:`sign-in`}),a().then(()=>h(`sign-in`,{replace:!0}))};switch(n.kind){case`loading`:return(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,z(`loading`)]});case`error`:return(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`cannotReach`,n.message)}),(0,R.jsx)(V,{onClick:r,children:z(`tryAgain`)})]});case`needs-admin`:return(0,R.jsx)(Dre,{onCheckAgain:r})}if(n.kind===`signed-in`&&p)return(0,R.jsx)(Lg,{to:m??`/`});if(v.kind===`reset-password`)return(0,R.jsx)(Lre,{token:v.token,onDone:()=>void M(),onRequestNewLink:i?()=>{y({kind:`sign-in`}),f(Ps({step:`forgot-password`}),{replace:!0})}:void 0,onBack:()=>j({kind:`sign-in`})});if(v.kind===`staff-sign-in`)return(0,R.jsx)($re,{link:v.link,onBack:()=>{D(eg),y({kind:`sign-in`})}});let ee=n.kind===`signed-out`||n.kind===`visitor`;if(v.kind===`invitation`&&(n.kind===`signed-in`||ee&&!p))return(0,R.jsx)(cie,{token:v.token,onDone:()=>{D(iie),y({kind:`sign-in`})},signIn:g()});if(n.kind===`signed-in`)return t;if(n.kind===`two-factor`)return(0,R.jsx)(nie,{methods:n.methods,onBack:N});if(n.kind===`setup-required`)return(0,R.jsx)(Bre,{missing:n.missing},n.missing.join());if(v.kind===`provider-sign-in`)return(0,R.jsx)(Pre,{provider:v.provider,workspace:e,onFailed:A});let te=v.kind===`sign-in`?v:{kind:`sign-in`};if(!p){let e=te.notice||te.error||te.providerError;return n.kind===`visitor`&&!e?t:(0,R.jsx)(Lg,{to:Ps({next:m})})}let ne={"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`,re=e=>()=>h(e,{replace:!0}),ie=c&&(()=>{c(),_()});if(ne===`forgot-password`)return(0,R.jsx)(Mre,{back:g(`sign-in`,{replace:!0})});if(ne===`email-code`)return(0,R.jsx)(Tre,{email:b,onBack:re(`sign-in`)});if(ne===`sign-up`||ne===`sign-up-code`||ne===`sign-up-details`)return(0,R.jsx)(Yre,{workspace:e,email:ne===`sign-up`?void 0:S,ticket:ne===`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:re(`sign-up`),onSignIn:()=>h(`sign-in`),onBrowse:ie},ne);let ae=te.providerError&&of(te.providerError,o.length===1?o[0].name:`the provider`),oe=te.error??ae;return(0,R.jsx)(Gre,{workspace:e,notice:te.notice,error:oe,forgotPassword:i?g(`forgot-password`):void 0,onCodeSent:e=>{x(e),h(`email-code`)},signUp:s?g(`sign-up`):void 0,onBrowse:ie},oe)},Rg=e=>[...e].reduce((e,t)=>(e*31+t.charCodeAt(0))%360,7),zg=e=>e.split(/[\s@.]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join(``),Bg=e=>(e.role??`user`).split(`,`).map(e=>e.trim()),Vg=e=>Bg(e).includes(`admin`),Aie=e=>{let t=Bg(e),n=t.includes(`admin`);return{name:e.name||e.email,email:e.email,initials:zg(e.name||e.email)||`?`,hue:Rg(e.id||e.email),role:n?z(`admin`):(t[0]??`user`).replace(/^./,e=>e.toUpperCase()),roleTone:n?`violet`:`blue`}},jie=3e4,Mie=(e,t=Date.now())=>Math.max(1e3,hu(e)-t-jie),Hg=()=>{let{state:e,session:t}=B(),n=e.kind===`signed-in`,[r,i]=(0,I.useState)();return(0,I.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),Mie(s))))};return a(),()=>{e=!1,clearTimeout(r)}},[t,n]),n?r:void 0},Ug=({locale:e,children:t})=>{h(e);let n=p();return(0,I.useEffect)(()=>{document.documentElement.lang=n},[n]),(0,R.jsx)(I.Fragment,{children:t},n)},Nie=({children:e})=>(0,R.jsx)(Ug,{locale:B().locale,children:e}),Pie=(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)}},Fie=(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}},Wg=(e,t)=>e.sources?.find(e=>e.source.resources.includes(t)),Iie=e=>{let t=U(),n=Om(),r=(0,I.useContext)(Nh),i=(0,I.useMemo)(()=>Object.values(e.resources).filter(t=>t.live&&!Wg(e,t.name)).map(e=>e.name).sort().join(`,`),[e]);(0,I.useEffect)(()=>{if(!i)return;let e=Pie(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])},Gg=(e,t,n=!0)=>{let r=U(),i=ur(t);return Ah({queryKey:H.record(e,i),enabled:n,queryFn:()=>r.get(e,t)})},Kg=(e,t,n=!0)=>{let r=U(),i=Om(),a=ur(t);return Ah({queryKey:H.record(e,a),enabled:n,queryFn:()=>r.get(e,t),placeholderData:()=>i.getQueryData(H.recordPreview(e,a))})},Lie=e=>e.charAt(0).toUpperCase()+e.slice(1),K=e=>Lie(e.replace(/(Id|Code|_id|_code)$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/_+/g,` `).trim().toLowerCase()||e);function Rie(){var e=[...arguments];return(0,I.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var qg=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Jg(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Yg(e){return`nodeType`in e}function Xg(e){return e?Jg(e)?e:Yg(e)?e.ownerDocument?.defaultView??window:window:window}function Zg(e){let{Document:t}=Xg(e);return e instanceof t}function Qg(e){return!Jg(e)&&e instanceof Xg(e).HTMLElement}function $g(e){return e instanceof Xg(e).SVGElement}function e_(e){return e?Jg(e)?e.document:Yg(e)?Zg(e)?e:Qg(e)||$g(e)?e.ownerDocument:document:document:document}var t_=qg?I.useLayoutEffect:I.useEffect;function n_(e){let t=(0,I.useRef)(e);return t_(()=>{t.current=e}),(0,I.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function zie(){let e=(0,I.useRef)(null);return[(0,I.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,I.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function r_(e,t){t===void 0&&(t=[e]);let n=(0,I.useRef)(e);return t_(()=>{n.current!==e&&(n.current=e)},t),n}function i_(e,t){let n=(0,I.useRef)();return(0,I.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function a_(e){let t=n_(e),n=(0,I.useRef)(null);return[n,(0,I.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function o_(e){let t=(0,I.useRef)();return(0,I.useEffect)(()=>{t.current=e},[e]),t.current}var s_={};function c_(e,t){return(0,I.useMemo)(()=>{if(t)return t;let n=s_[e]==null?0:s_[e]+1;return s_[e]=n,e+`-`+n},[e,t])}function l_(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 u_=l_(1),d_=l_(-1);function Bie(e){return`clientX`in e&&`clientY`in e}function f_(e){if(!e)return!1;let{KeyboardEvent:t}=Xg(e.target);return t&&e instanceof t}function Vie(e){if(!e)return!1;let{TouchEvent:t}=Xg(e.target);return t&&e instanceof t}function p_(e){if(Vie(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 Bie(e)?{x:e.clientX,y:e.clientY}:null}var m_=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[m_.Translate.toString(e),m_.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),h_=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Hie(e){return e.matches(h_)?e:e.querySelector(h_)}var g_={display:`none`};function __(e){let{id:t,value:n}=e;return I.createElement(`div`,{id:t,style:g_},n)}function v_(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return I.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 y_(){let[e,t]=(0,I.useState)(``);return{announce:(0,I.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var b_=(0,I.createContext)(null);function Uie(e){let t=(0,I.useContext)(b_);(0,I.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Wie(){let[e]=(0,I.useState)(()=>new Set),t=(0,I.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,I.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Gie={draggable:`
|
|
7
|
+
`)}\n`;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(`ul`,{"aria-label":L(`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,R.jsx)(`li`,{children:e},e))}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsxs)(V,{size:`sm`,onClick:()=>{navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},children:[t?(0,R.jsx)(Ci,{className:`size-3.5 text-success`}):(0,R.jsx)(zi,{className:`size-3.5`}),L(t?`copied`:`copy`)]}),(0,R.jsxs)(V,{size:`sm`,onClick:()=>pp(r,`backup-codes.txt`),children:[(0,R.jsx)(Gi,{className:`size-3.5`}),L(`download`)]})]})]})},hp=({title:e,description:t,confirmLabel:n,danger:r,needsPassword:i,onConfirm:a,onClose:o})=>{let[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(),p=async()=>{u(!0),f(void 0);try{await a(i?s:void 0)}catch(e){if(!(e instanceof Dc))throw e;f(ef(e)),u(!1)}};return(0,R.jsxs)(sp,{title:e,description:t,onClose:o,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:o,children:L(`cancel`)}),(0,R.jsx)(V,{variant:r?`danger`:`primary`,loading:l,disabled:i&&!s,onClick:()=>void p(),children:n})]}),children:[i&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[L(`yourPassword`),(0,R.jsx)(Rd,{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,R.jsx)(`p`,{role:`alert`,className:`mt-2 text-body font-medium text-danger-text`,children:d})]})},gp=(e,t)=>e.replace(/\D/g,``).slice(0,t),_p=(e,t,n)=>{let r=gp(t??``,n);return r.length===n?r:gp(e,n)},vp=(e,t,n,r)=>{let i=t.replace(/\D/g,``);return i.length>=r?i.slice(0,r):gp(e.slice(0,n)+i+e.slice(n+i.length),r)},yp=({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,I.useRef)(null),[_,v]=(0,I.useState)(!1),[y,b]=(0,I.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,R.jsxs)(`div`,{className:g(`relative`,a&&`opacity-50`,o),children:[(0,R.jsx)(`div`,{"aria-hidden":!0,className:`flex justify-center gap-2`,children:Array.from({length:r},(e,t)=>{let n=_&&t===S;return(0,R.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,R.jsx)(`span`,{className:`h-6 w-px animate-pulse bg-foreground`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-border-strong`}))},t)})}),(0,R.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(_p(e.target.value,t??n?.getData(`text/plain`),r))},onPaste:e=>{if(p?.(e),e.defaultPrevented)return;e.preventDefault();let t=e.currentTarget,n=vp(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)}})]})},bp=(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))(bp||{}),xp=[0,1],Sp=[1,0],Cp=[2,3],wp=[3,2],Tp={L:xp,M:Sp,Q:Cp,H:wp},Ep=/^\d*$/,Dp=/^[A-Z0-9 $%*+./:-]*$/,Op=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,kp=1,Ap=40,jp=3,Mp=3,Np=40,Pp=10,Fp=[[-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]],Ip=[[-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]],Lp=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<kp||e>Ap)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,bp.Timing),this.setFunctionModule(e,6,e%2==0,bp.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,zp(r,e));this.setFunctionModule(8,7,zp(r,6)),this.setFunctionModule(8,8,zp(r,7)),this.setFunctionModule(7,8,zp(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,zp(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,zp(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,zp(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=zp(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,bp.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,bp.Alignment)}setFunctionModule(e,t,n,r=bp.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==em(t,n))throw RangeError(`Invalid argument`);let r=Ip[n[0]][t],i=Fp[n[0]][t],a=Math.floor($p(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=tm(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=nm(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($p(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]=zp(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+=jp:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Np),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Np}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+=jp:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Np),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Np}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+=Mp)}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*Pp,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 Rp(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 zp(e,t){return!!(e>>>t&1)}var Bp=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()}},Vp=[1,10,12,14],Hp=[2,9,11,13],Up=[4,8,16,16];function Wp(e,t){return e[Math.floor((t+7)/17)+1]}function Gp(e){let t=[];for(let n of e)Rp(n,8,t);return new Bp(Up,e.length,t)}function Kp(e){if(!Yp(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);Rp(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new Bp(Vp,e.length,t)}function qp(e){if(!Xp(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Op.indexOf(e.charAt(n))*45;r+=Op.indexOf(e.charAt(n+1)),Rp(r,11,t)}return n<e.length&&Rp(Op.indexOf(e.charAt(n)),6,t),new Bp(Hp,e.length,t)}function Jp(e){return e===``?[]:Yp(e)?[Kp(e)]:Xp(e)?[qp(e)]:[Gp(Qp(e))]}function Yp(e){return Ep.test(e)}function Xp(e){return Dp.test(e)}function Zp(e,t){let n=0;for(let r of e){let e=Wp(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function Qp(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 $p(e){if(e<kp||e>Ap)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 em(e,t){return Math.floor($p(e)/8)-Fp[t[0]][e]*Ip[t[0]][e]}function tm(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]=rm(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=rm(n,2)}return t}function nm(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]^=rm(t,e))}return n}function rm(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 im(e,t,n=1,r=40,i=-1,a=!0){if(!(kp<=n&&n<=r&&r<=Ap)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=em(o,t)*8,i=Zp(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Sp,Cp,wp])a&&s<=em(o,e)*8&&(t=e);let c=[];for(let t of e){Rp(t.mode[0],4,c),Rp(t.numChars,Wp(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=em(o,t)*8;Rp(0,Math.min(4,l-c.length),c),Rp(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Rp(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 Lp(o,t,u,i)}function am(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`?Jp(e):Array.isArray(e)?[Gp(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=im(c,Tp[n],i,a,o,r),u=om({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 om(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=bp.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 sm=({uri:e,className:t})=>{let{size:n,path:r}=(0,I.useMemo)(()=>{let t=am(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,R.jsxs)(`svg`,{viewBox:`0 0 ${n} ${n}`,role:`img`,"aria-label":L(`qrCode`),shapeRendering:`crispEdges`,className:t,children:[(0,R.jsx)(`rect`,{width:n,height:n,fill:`#fff`}),(0,R.jsx)(`path`,{d:r,fill:`#000`})]})},cm=e=>(new URL(e).searchParams.get(`secret`)??``).replace(/(.{4})(?=.)/g,`$1 `),lm=()=>[{value:`app`,label:L(`authenticatorApp`),description:L(`authenticatorAppDescription`)},{value:`email`,label:L(`emailedCode`),description:L(`emailedCodeDescription`)}],um=({offerEmailedCodes:e,needsPassword:t,onStartApp:n,onConfirmApp:r,onEmailedCodes:i,onDone:a,onCancel:o})=>{let[s,c]=(0,I.useState)({kind:`choose`}),[l,u]=(0,I.useState)(`app`),[d,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(``),[h,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)(),b=e?lm():lm().filter(e=>e.value===`app`),x=async e=>{_(!0),y(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;y(ef(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,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:v});return s.kind===`backup-codes`?(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:L(`twoFactorIsOn`)}),(0,R.jsx)(mp,{codes:s.codes}),(0,R.jsx)(V,{variant:`primary`,onClick:a,className:`min-h-10`,children:L(`savedCodes`)})]}):s.kind===`scan`?(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),C(s.setup)},children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:L(`scanCode`)}),(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,R.jsx)(sm,{uri:s.setup.totpURI,className:`size-44 rounded-md border`}),(0,R.jsxs)(`p`,{className:`text-center text-xs text-muted-foreground`,children:[L(`cannotScan`),(0,R.jsx)(`span`,{className:`mt-1 block break-all font-mono text-body text-foreground`,children:cm(s.setup.totpURI)})]})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[L(`codeFromApp`),(0,R.jsx)(yp,{name:`code`,required:!0,autoFocus:!0,value:p,invalid:!!v,onChange:m,onComplete:e=>!h&&void C(s.setup,e)})]}),w,(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:L(`turnOn`)}),o&&(0,R.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:L(`cancel`)})]}):(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":L(`secondStep`),className:`flex flex-col gap-2`,children:b.map(e=>(0,R.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,R.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,R.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted-foreground`,children:e.description})]},e.value))}),t&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[L(`yourPassword`),(0,R.jsx)(Rd,{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,R.jsx)(V,{variant:`primary`,type:`submit`,loading:h,className:`min-h-10`,children:L(`continue`)}),o&&(0,R.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:L(`cancel`)})]})},dm={allowed:`twoFactorAllowed`,required:`twoFactorRequired`,forbidden:`twoFactorForbidden`},fm=e=>{let{rule:t,enabled:n,authenticatorApp:r,mail:i,needsPassword:a,onTurnOff:o,onNewBackupCodes:s,onChanged:c}=e,[l,u]=(0,I.useState)(),d=()=>u(void 0),f=n?(0,R.jsx)(dd,{tone:`green`,children:L(`on`)}):t===`required`?(0,R.jsx)(dd,{tone:`amber`,children:L(`required`)}):(0,R.jsx)(dd,{children:L(`off`)}),p=L(n?r?i?`twoFactorOnWithAppOrMail`:`twoFactorOnWithApp`:`twoFactorOnWithMail`:dm[t]);return l?.kind===`setup`?(0,R.jsx)(cp,{title:L(`twoFactor`),status:f,description:p,children:(0,R.jsx)(`div`,{className:`max-w-sm`,children:(0,R.jsx)(um,{offerEmailedCodes:i&&!l.appOnly,needsPassword:a,onStartApp:e.onStartApp,onConfirmApp:e.onConfirmApp,onEmailedCodes:e.onEmailedCodes,onCancel:d,onDone:()=>{d(),c()}})})}):(0,R.jsxs)(cp,{title:L(`twoFactor`),status:f,description:p,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&t!==`forbidden`&&(0,R.jsx)(V,{variant:`primary`,onClick:()=>u({kind:`setup`,appOnly:!1}),children:L(`turnOn`)}),n&&!r&&t!==`forbidden`&&(0,R.jsx)(V,{onClick:()=>u({kind:`setup`,appOnly:!0}),children:L(`addAuthenticator`)}),n&&r&&(0,R.jsx)(V,{onClick:()=>u({kind:`new-codes`}),children:L(`newBackupCodes`)}),n&&(0,R.jsx)(V,{variant:`danger`,disabled:t===`required`,title:t===`required`?L(`twoFactorIsRequired`):void 0,onClick:()=>u({kind:`turn-off`}),children:L(`turnOff`)})]}),l?.kind===`turn-off`&&(0,R.jsx)(hp,{title:L(`turnOffTitle`),description:L(`turnOffDescription`),confirmLabel:L(`turnOff`),danger:!0,needsPassword:a,onClose:d,onConfirm:async e=>{await o(e),d(),c()}}),l?.kind===`new-codes`&&(0,R.jsx)(hp,{title:L(`newCodesTitle`),description:L(`newCodesDescription`),confirmLabel:L(`makeNewCodes`),needsPassword:a,onClose:d,onConfirm:async e=>u({kind:`codes`,codes:await s(e)})}),l?.kind===`codes`&&(0,R.jsx)(sp,{title:L(`yourNewCodes`),description:L(`keepCodesSafe`),onClose:d,actions:(0,R.jsx)(V,{variant:`primary`,onClick:d,children:L(`savedCodes`)}),children:(0,R.jsx)(mp,{codes:l.codes})})]})},pm=()=>{let e=uf(window.location.href);return e&&window.history.replaceState(window.history.state,``,df(window.location.href)),e},mm=({email:e})=>{let{session:t,signInProviders:n,socialProviders:r,linkProvider:i}=B(),a=n.filter(e=>r.includes(e.id)),{account:o}=t,[s,c]=(0,I.useState)(),[l,u]=(0,I.useState)(),[d]=(0,I.useState)(pm),f=(0,I.useCallback)(()=>{Promise.all([o.signInMethods(),o.passkeys(),o.linkedProviders()]).then(([e,t,n])=>c({methods:e,passkeys:t,linked:n}),e=>u(e instanceof Dc?ef(e):L(`couldNotReadMethods`)))},[o]);(0,I.useEffect)(f,[f]);let p=e=>e.then(e=>(f(),e));return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,R.jsx)(Jd,{title:L(`signInSecurity`),subtitle:e}),s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(dp,{rule:s.methods.policy.passkey,passkeys:s.passkeys,onAdd:()=>p(o.addPasskey()),onRename:(e,t)=>p(o.renamePasskey(e,t)),onRemove:e=>p(o.removePasskey(e))}),(0,R.jsx)(fm,{rule:s.methods.policy.twoFactor,enabled:s.methods.account.twoFactor,authenticatorApp:s.methods.account.authenticatorApp,mail:s.methods.mail,needsPassword:s.methods.account.password,onStartApp:e=>o.startAuthenticatorApp(e),onConfirmApp:e=>o.confirmAuthenticatorApp(e),onEmailedCodes:e=>o.turnOnEmailedCodes(e),onTurnOff:e=>o.turnOffTwoFactor(e),onNewBackupCodes:e=>o.newBackupCodes(e),onChanged:f}),a.length>0&&(0,R.jsx)(fp,{providers:a,linked:s.linked,onConnect:i,error:d&&of(d,a.length===1?a[0].name:L(`theProvider`))})]}):l?(0,R.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:l}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,L(`loading`)]})]})},hm=()=>[{value:`allowed`,label:L(`on`)},{value:`forbidden`,label:L(`off`)}],gm=()=>[{value:`allowed`,label:L(`optional`)},{value:`required`,label:L(`required`)},{value:`forbidden`,label:L(`off`)}],_m=()=>[{method:`password`,label:L(`password`),description:L(`passwordDescription`),rules:hm()},{method:`emailCode`,label:L(`emailedSignInCode`),description:L(`emailedSignInCodeDescription`),rules:hm()},{method:`passkey`,label:L(`passkeys`),description:L(`passkeysPolicyDescription`),rules:gm()},{method:`twoFactor`,label:L(`twoFactor`),description:L(`twoFactorPolicyDescription`),rules:gm()},{method:`staffAccess`,label:L(`staffAccess`),description:L(`staffAccessDescription`),rules:[{value:`allowed`,label:L(`on`)},{value:`notify`,label:L(`emailThePerson`)},{value:`forbidden`,label:L(`off`)}]},{method:`platformSignIn`,label:L(`platformSignIn`),description:L(`platformSignInDescription`),rules:hm()}],vm=(e,t)=>{let n=_m().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},ym=({row:e,value:t,onChange:n})=>(0,R.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,R.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))}),bm=({method:e},t,{mail:n,effective:r,policy:i})=>{if(e===`emailCode`&&!n)return L(`codeNeedsMail`);if(e===`password`&&!n&&t.password===`forbidden`)return L(`passwordStaysOn`);if(e===`staffAccess`&&!n&&t.staffAccess===`notify`)return L(`staffNeedsMail`);if(e===`platformSignIn`&&t.platformSignIn===`allowed`&&(t.passkey===`required`||t.twoFactor===`required`))return L(`platformOff`);if(t[e]===i[e]&&r[e]!==i[e])return L(`appliesAs`,vm(e,r[e]))},xm=({operator:e,platformSignIn:t})=>_m().flatMap(n=>n.method===`staffAccess`&&!e?[]:n.method===`platformSignIn`?t?[{...n,label:L(`platformSignInWith`,t)}]:[]:[n]),Sm=({state:e,onSave:t,busy:n,error:r,notice:i})=>{let[a,o]=(0,I.useState)(e.policy),s=xm(e),c=s.some(({method:t})=>a[t]!==e.policy[t]);return(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t(a)},children:[(0,R.jsx)(`ul`,{className:`divide-y rounded-lg border bg-background`,children:s.map(t=>{let n=bm(t,a,e);return(0,R.jsxs)(`li`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h2`,{className:`font-semibold`,children:t.label}),(0,R.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t.description}),n&&(0,R.jsx)(`p`,{className:`mt-1.5 text-xs font-medium text-warning-text`,children:n})]}),(0,R.jsx)(ym,{row:t,value:a[t.method],onChange:e=>o({...a,[t.method]:e})})]},t.method)})}),r&&(0,R.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,R.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.savedAt?e.savedBy?L(`lastSavedBy`,e.savedBy,Kf(Date.parse(e.savedAt))):L(`lastSaved`,Kf(Date.parse(e.savedAt))):L(`neverChanged`)}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[c&&(0,R.jsx)(V,{onClick:()=>o(e.policy),children:L(`reset`)}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:n,disabled:!c,children:L(`save`)})]})]})]})},Cm=(e,t)=>e.endedAt?(0,R.jsx)(dd,{tone:`neutral`,children:L(`stopped`,Kf(Date.parse(e.endedAt)))}):Date.parse(e.expiresAt)<=t?(0,R.jsx)(dd,{tone:`neutral`,children:L(`ended`,Kf(Date.parse(e.expiresAt)))}):(0,R.jsx)(dd,{tone:`amber`,children:L(`signedInUntil`,Kf(Date.parse(e.expiresAt)))}),wm=({signIns:e,operator:t,error:n,now:r=Date.now()})=>(0,R.jsxs)(cp,{title:L(`staffSignIns`),description:L(`staffSignInsDescription`,t),children:[(0,R.jsx)(lp,{message:n}),e&&e.length===0&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:L(`noStaffSignIns`)}),e&&e.length>0&&(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-col gap-1.5 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,R.jsx)(`span`,{className:`font-medium break-all`,children:e.staffName?`${e.staffName} (${e.staff})`:e.staff}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:L(`as`)}),(0,R.jsx)(`span`,{className:`font-medium break-all`,children:e.user})]}),(0,R.jsx)(`p`,{className:`break-words`,children:e.reason}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:Kf(Date.parse(e.startedAt))}),Cm(e,r)]})]},e.id))})]}),Tm=({operator:e})=>{let{session:t}=B(),[n,r]=(0,I.useState)(),[i,a]=(0,I.useState)();return(0,I.useEffect)(()=>{t.staff.log().then(r,e=>a(e instanceof Dc?ef(e):L(`couldNotReadStaffSignIns`)))},[t]),(0,R.jsx)(wm,{operator:e,signIns:n,error:i})},Em=()=>{let{session:e}=B(),[t,n]=(0,I.useState)(),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(),[s,c]=(0,I.useState)();(0,I.useEffect)(()=>{e.signInPolicy.read().then(n,e=>o(e instanceof Dc?ef(e):L(`couldNotReadPolicy`)))},[e]);let l=async t=>{i(!0),o(void 0),c(void 0);try{n(await e.signInPolicy.save(t)),c(L(`policySaved`))}catch(e){if(!(e instanceof Dc))throw e;o(ef(e))}i(!1)};return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,R.jsx)(Jd,{title:L(`signInPolicy`),subtitle:L(`policySubtitle`)}),t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Sm,{state:t,busy:r,error:a,notice:s,onSave:e=>void l(e)},t.savedAt??`default`),t.operator&&(0,R.jsx)(Tm,{operator:t.operator})]}):a?(0,R.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:a}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,L(`loading`)]})]})},Dm=I.createContext(void 0),Om=e=>{let t=I.useContext(Dm);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},km=({client:e,children:t})=>(I.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,R.jsx)(Dm.Provider,{value:e,children:t})),Am={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},jm=new class{#e=Am;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 Une(e){setTimeout(e,0)}var Wne=typeof window>`u`||`Deno`in globalThis;function Mm(){}function Gne(e,t){return typeof e==`function`?e(t):e}function Nm(e){return typeof e==`number`&&e>=0&&e!==1/0}function Pm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Fm(e,t){return typeof e==`function`?e(t):e}function Im(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Rm(o,t.options))return!1}else if(!Bm(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 Lm(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(zm(t.options.mutationKey)!==zm(a))return!1}else if(!Bm(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Rm(e,t){return(t?.queryKeyHashFn||zm)(e)}function zm(e){return JSON.stringify(e,(e,t)=>Wm(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Bm(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(!Bm(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Bm(e[r],t[r]))return!1;return!0}return!1}var Kne=Object.prototype.hasOwnProperty;function Vm(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Um(e)&&Um(t);if(!r&&!(Wm(e)&&Wm(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:Kne.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Vm(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Hm(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 Um(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Wm(e){if(!Gm(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!(!Gm(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function Gm(e){return Object.prototype.toString.call(e)===`[object Object]`}function qne(e){return new Promise(t=>{jm.setTimeout(t,e)})}function Km(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Vm(e,t)}function qm(e){return e}function Jne(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Yne(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Jm=Symbol();function Ym(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Jm?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Xm(e,t){return typeof e==`function`?e(...t):!!e}function Xne(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 Zne=()=>Wne,Zm=()=>Zne(),Qm=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(){}},$m=new class extends Qm{#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`}},Qne=Une;function $ne(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Qne,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 eh=$ne(),th=new class extends Qm{#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 ere(e){return Math.min(1e3*2**e,3e4)}function nh(e){return(e??`online`)!==`online`||th.isOnline()}var rh=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ih(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(Mm);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new rh(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>$m.isFocused()&&(e.networkMode===`always`||th.isOnline())&&e.canRun(),p=()=>nh(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??(Zm()?0:3),a=e.retryDelay??ere,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),qne(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 ah=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Nm(this.gcTime)&&(this.#e=jm.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Zm()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(jm.clearTimeout(this.#e),this.#e=void 0)}};function tre(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=>{Xne(e,()=>t.signal,()=>n=!0)},u=Ym(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?Yne:Jne;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?sh:oh,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:oh(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 oh(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 sh(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function nre(e,t){return t?oh(e,t)!=null:!1}function rre(e,t){return!t||!e.getPreviousPageParam?!1:sh(e,t)!=null}var ire=class extends ah{#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=uh(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=uh(this.options);e.data!==void 0&&(this.setState(lh(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Km(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(Mm).catch(Mm):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=>Fm(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Jm||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Fm(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:!Pm(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=Ym(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`?tre(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=ih({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof rh&&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 rh){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,...ch(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...lh(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),eh.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function ch(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:nh(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function lh(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function uh(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 Qm{#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),fh(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ph(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ph(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 Fm(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&&!Hm(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&mh(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||Fm(this.options.enabled,this.#t)!==Fm(t.enabled,this.#t)||Fm(this.options.staleTime,this.#t)!==Fm(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Fm(this.options.enabled,this.#t)!==Fm(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 Hm(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(Mm)),t}#h(e){return!Zm()&&Fm(this.options.enabled,this.#t)!==!1&&Nm(e)}#g(){this.#b();let e=Fm(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=Pm(this.#r.dataUpdatedAt,e)+1;this.#u=jm.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return Fm(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=jm.setInterval(()=>{(this.options.refetchIntervalInBackground||$m.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(jm.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(jm.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&&fh(e,t),o=i&&mh(e,n,t,r);(a||o)&&(l={...l,...ch(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=Km(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=Km(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:hh(e,t),refetch:this.refetch,isEnabled:Fm(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),Hm(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)})})();eh.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 are(e,t){return Fm(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Fm(t.retryOnMount,e)!==!1)}function fh(e,t){return are(e,t)||e.state.data!==void 0&&ph(e,t,t.refetchOnMount)}function ph(e,t,n){if(Fm(t.enabled,e)!==!1&&Fm(t.staleTime,e)!==`static`){let r=Fm(n,e);return r===`always`||r!==!1&&hh(e,t)}return!1}function mh(e,t,n,r){return(e!==t||Fm(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&hh(e,n)}function hh(e,t){return Fm(t.enabled,e)!==!1&&e.isStaleByTime(Fm(t.staleTime,e))}var ore=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:nre(t,n.data),hasPreviousPage:rre(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},sre=class extends ah{#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||gh(),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=ih({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),eh.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function gh(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var cre=class extends Qm{#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 sre({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=_h(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=_h(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=_h(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=_h(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){eh.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=>Lm(t,e))}findAll(e={}){return this.getAll().filter(t=>Lm(e,t))}notify(e){eh.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return eh.batch(()=>Promise.all(e.map(e=>e.continue().catch(Mm))))}};function _h(e){return e.options.scope?.id}var lre=class extends Qm{#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),Hm(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&zm(t.mutationKey)!==zm(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??gh();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){eh.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 vh(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var ure=class extends Qm{#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,eh.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||!Hm(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(vh(e,n).forEach(e=>{e.destroy()}),vh(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=Vm(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)&&eh.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},dre=class extends Qm{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??Rm(r,t),a=this.get(i);return a||(a=new ire({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(){eh.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=>Im(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Im(e,t)):t}notify(e){eh.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){eh.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){eh.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},fre=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new dre,this.#t=e.mutationCache||new cre,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=$m.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=th.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(Fm(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=Gne(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return eh.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;eh.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return eh.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=eh.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Mm).catch(Mm)}invalidateQueries(e,t={}){return eh.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=eh.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(Mm)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Mm)}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(Fm(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(Fm(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Mm).catch(Mm)}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(Mm).catch(Mm)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return th.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(zm(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Bm(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(zm(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Bm(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||=Rm(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===Jm&&(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()}},yh=I.createContext(!1),bh=()=>I.useContext(yh);yh.Provider;function pre(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var mre=I.createContext(pre()),xh=()=>I.useContext(mre),Sh=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Xm(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},Ch=e=>{I.useEffect(()=>{e.clearReset()},[e])},wh=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Xm(n,[e.error,r])),Th=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))}},Eh=(e,t)=>e?.suspense&&t.isPending,Dh=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Oh({queries:e,...t},n){let r=Om(n),i=bh(),a=xh(),o=t.subscribed!==!1,s=I.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=>{Th(e);let t=r.getQueryCache().get(e.queryHash);Sh(e,a,t)}),Ch(a);let[c]=I.useState(()=>new ure(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;I.useSyncExternalStore(I.useCallback(e=>f?c.subscribe(eh.batchCalls(e)):Mm,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),I.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>Eh(s[t],e))?l.flatMap((e,t)=>{let n=s[t];return n&&Eh(n,e)?Dh(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&&wh({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 kh(e,t,n){let r=bh(),i=xh(),a=Om(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Th(o),Sh(o,i,s),Ch(i);let[l]=I.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(I.useSyncExternalStore(I.useCallback(e=>{let t=d?l.subscribe(eh.batchCalls(e)):Mm;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),I.useEffect(()=>{l.setOptions(o)},[o,l]),Eh(o,u))throw Dh(o,l,i);if(wh({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function Ah(e,t){return kh(e,dh,t)}function jh(e,t){let n=Om(t),[r]=I.useState(()=>new lre(n,e));I.useEffect(()=>{r.setOptions(e)},[r,e]);let i=I.useSyncExternalStore(I.useCallback(e=>r.subscribe(eh.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=I.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(Mm)},[r]);if(i.error&&Xm(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Mh(e,t){return kh(e,ore,t)}var hre=()=>{let e=0;return{refetchOnWindowFocus:()=>e>0?!1:`always`,paused:()=>e>0,pause:()=>{e+=1;let t=!1;return()=>{t||(t=!0,--e)}}}},Nh=(0,I.createContext)(null),gre=e=>{let t=(0,I.useContext)(Nh);(0,I.useEffect)(()=>e&&t?t.pause():void 0,[e,t])},_re=e=>{let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),window.addEventListener(`focus`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t),window.removeEventListener(`focus`,t)}},H={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]},Ph=(0,I.createContext)(null),Fh=(0,I.createContext)(null),Ih=(0,I.createContext)(null),U=()=>{let e=(0,I.useContext)(Ph);if(!e)throw Error(`useClient must be used inside ApiProvider`);return e},Lh=e=>{let t=U();return(0,I.useContext)(Ih)?.(e)??t},vre=()=>{let e=U(),t=(0,I.useContext)(Ih);return(0,I.useCallback)(n=>t?.(n)??e,[e,t])},yre=()=>{let e=(0,I.useContext)(Fh);if(!e)throw Error(`useSourceClients must be used inside ApiProvider`);return e},bre=({client:e,resourceClient:t,children:n})=>(0,R.jsx)(Ph.Provider,{value:e,children:(0,R.jsx)(Ih.Provider,{value:t,children:n})}),Rh=({baseUrl:e,client:t,sources:n,fetch:r,queryClient:i,token:a,onUnauthenticated:o,children:s})=>{let[c]=(0,I.useState)(hre),[l]=(0,I.useState)(()=>i??new fre({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:c.refetchOnWindowFocus}}}));(0,I.useEffect)(()=>$m.setEventListener(_re),[]);let u=(0,I.useRef)(void 0),d=(0,I.useMemo)(()=>t??dc({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:H.meta},{cancelRefetch:!1})}}),[t,e,r,l,a,o]),f=(0,I.useMemo)(()=>{let e=new Map;return t=>{let i=n?.[t.url]??e.get(t.url);if(i)return i;let o,s=dc({baseUrl:t.url,fetch:r,token:a,onMetaVersion:e=>{let n=o;o=e,n!==void 0&&n!==e&&l.invalidateQueries({queryKey:H.sourceMetas(t.url)},{cancelRefetch:!1})}});return e.set(t.url,s),s}},[n,r,a,l]);return(0,R.jsx)(km,{client:l,children:(0,R.jsx)(Ph.Provider,{value:d,children:(0,R.jsx)(Fh.Provider,{value:f,children:(0,R.jsx)(Nh.Provider,{value:c,children:s})})})})},W=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`}}),zh=(0,I.createContext)(null),Bh=()=>{let e=(0,I.useContext)(zh);if(!e)throw Error(`useRouter must be used inside Router`);return e},Vh=()=>`${window.location.pathname}${window.location.search}`,Hh=e=>new URL(e,`http://local`).pathname,Uh=()=>window.history.state??{},Wh=()=>Uh().protobaseIndex??0,Gh=()=>Math.random().toString(36).slice(2),Kh=()=>{let e=Uh();if(e.protobaseEntry)return e.protobaseEntry;let t=Gh();return window.history.replaceState({...e,protobaseEntry:t},``),t},xre=({basePath:e=``,initialUrl:t,children:n})=>{let r=t!==void 0,[i,a]=(0,I.useState)(()=>({url:t??Vh(),entry:r?Gh():Kh()})),o=(0,I.useRef)(new Set),s=(0,I.useRef)(i);s.current=i;let c=(0,I.useRef)(r?0:Wh()),l=(0,I.useRef)(!1),u=(0,I.useRef)(!1),d=(0,I.useRef)(void 0),[f,p]=(0,I.useState)();(0,I.useEffect)(()=>{if(r)return;window.history.replaceState({protobaseIndex:c.current,protobaseEntry:s.current.entry},``);let e=()=>{let e=Wh();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=Hh(Vh())!==Hh(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:Vh(),entry:Kh()})};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[r]);let m=(0,I.useCallback)((e,t)=>{let n=t?s.current.entry:Gh();r||(c.current+=+!t,window.history[t?`replaceState`:`pushState`]({protobaseIndex:c.current,protobaseEntry:n},``,e)),a({url:e,entry:n})},[r]),h=(0,I.useCallback)((t,{replace:n=!1}={})=>{let r=`${e}${t}`;if(Hh(r)!==Hh(s.current.url)&&o.current.size>0)return p({kind:`link`,full:r,replace:n});m(r,n)},[e,m]),g=(0,I.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,I.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,R.jsxs)(zh.Provider,{value:v,children:[n,f&&(0,R.jsx)(sp,{title:W(`leaveTitle`),description:W(`leaveDescription`),onClose:()=>p(void 0),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:()=>p(void 0),children:W(`stay`)}),(0,R.jsx)(V,{variant:`primary`,onClick:_,children:W(`leave`)})]})})]})},Sre=({to:e,replace:t,...n})=>{let{navigate:r,basePath:i}=Bh();return(0,R.jsx)(Ku,{to:{href:`${i}${e}`,onFollow:()=>r(e,{replace:t})},...n})},Cre=e=>{let{registerGuard:t}=Bh();(0,I.useEffect)(()=>e?t():void 0,[e,t]),(0,I.useEffect)(()=>{if(!e)return;let t=e=>e.preventDefault();return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e])},qh=({title:e,description:t,size:n=`sm`,children:r})=>(0,R.jsx)(`div`,{className:`flex min-h-full w-full items-center justify-center bg-surface px-4 py-10`,children:(0,R.jsxs)(`div`,{className:g(`w-full`,n===`sm`?`max-w-sm`:`max-w-lg`),children:[(0,R.jsxs)(`div`,{className:`mb-6 flex flex-col items-center text-center`,children:[(0,R.jsx)(Xu,{className:`size-10`}),(0,R.jsx)(`h1`,{className:`mt-4 text-xl font-semibold tracking-tight`,children:e}),t&&(0,R.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t})]}),(0,R.jsx)(`div`,{className:`rounded-lg border bg-background p-5 shadow-sm`,children:r})]})}),Jh=({onResend:e,cooldown:t=30,disabled:n})=>{let[r,i]=(0,I.useState)(()=>Date.now()+t*1e3),[a,o]=(0,I.useState)(()=>Date.now()),s=Math.max(0,Math.ceil((r-a)/1e3));return(0,I.useEffect)(()=>{if(s===0)return;let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[s]),(0,R.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?z(`sendNewCodeIn`,s):z(`sendNewCode`)})},Yh=({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,I.useState)(``);return(0,R.jsxs)(qh,{title:e,description:t,children:[(0,R.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:n}),u&&(0,R.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,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),i(f)},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`code`),(0,R.jsx)(yp,{name:`code`,required:!0,autoFocus:!0,value:f,invalid:!!l,onChange:p,onComplete:e=>!c&&i(e)})]}),l&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:l}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:c,className:`min-h-10`,children:r}),(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-x-2 sm:justify-between`,children:[(0,R.jsx)(V,{variant:`ghost`,onClick:o,className:`min-h-10`,children:s}),(0,R.jsx)(Jh,{onResend:a,disabled:c,cooldown:d})]})]})]})},Xh=(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,R.jsx)(R.Fragment,{children:n.map((e,n)=>(0,R.jsxs)(I.Fragment,{children:[e,n<t.length&&t[n]]},n))})},wre=({email:e,onBack:t,...n})=>(0,R.jsx)(Yh,{title:z(`checkEmail`),description:z(`signInCodeDescription`),explanation:(0,R.jsx)(R.Fragment,{children:Xh(z(`signInCodeSent`),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),submitLabel:z(`signIn`),onChangeAddress:t,changeAddressLabel:z(`backToSignIn`),...n}),Tre=({email:e,onBack:t})=>{let{signInWithCode:n,sendSignInCode:r}=B(),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(),[c,l]=(0,I.useState)(),u=async e=>{a(!0),s(void 0),l(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;s(ef(e))}a(!1)};return(0,R.jsx)(wre,{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(z(`newCodeSent`))})})},Ere=`protobase users create you@example.com`,Dre=({command:e=Ere,onCheckAgain:t,busy:n})=>{let[r,i]=(0,I.useState)(!1);return(0,R.jsxs)(qh,{title:z(`noAdminTitle`),description:z(`noAdminDescription`),children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`noAdminExplanation`)}),(0,R.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,R.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-xs`,children:e}),(0,R.jsx)(`button`,{type:`button`,"aria-label":z(`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,R.jsx)(Ci,{className:`size-4 text-success`}):(0,R.jsx)(zi,{className:`size-4`})})]}),(0,R.jsx)(V,{variant:`primary`,className:`mt-4 min-h-10 w-full`,loading:n,onClick:t,children:z(`reload`)})]})},Ore=({onSubmit:e,back:t,busy:n,error:r,sentTo:i})=>{let[a,o]=(0,I.useState)(``);return i?(0,R.jsxs)(qh,{title:z(`checkEmail`),children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Xh(z(`resetSent`),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:i}))}),(0,R.jsx)(Ku,{to:t,className:g(op({variant:`primary`}),`mt-4 min-h-10 w-full`),children:z(`backToSignIn`)})]}):(0,R.jsx)(qh,{title:z(`resetTitle`),description:z(`resetDescription`),children:(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(a.trim())},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`email`),(0,R.jsx)(Rd,{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,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:r}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:n,className:`min-h-10`,children:z(`sendResetLink`)}),(0,R.jsx)(Ku,{to:t,className:g(op({variant:`ghost`}),`min-h-10`),children:z(`backToSignIn`)})]})})},Zh=`password-reset`,kre=e=>{let t=new URL(e);return`${t.origin}${t.pathname}?${Zh}`},Are=e=>{let t=new URL(e).searchParams;if(t.has(`password-reset`))return{token:t.get(`token`)||void 0}},jre=e=>{let t=new URL(e);for(let e of[Zh,`token`,`error`])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`},Mre=({back:e})=>{let{session:t}=B(),[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(),[o,s]=(0,I.useState)(),c=async e=>{r(!0),a(void 0);try{await t.requestPasswordReset(e,kre(window.location.href)),s(e)}catch(e){if(!(e instanceof Dc))throw e;a(e.status===429?z(`tooManyRequests`):e.message)}r(!1)};return(0,R.jsx)(Ore,{busy:n,error:i,sentTo:o,back:e,onSubmit:e=>void c(e)})},Nre=({name:e,workspace:t})=>(0,R.jsx)(qh,{title:z(`signingInWith`,e),description:t,children:(0,R.jsxs)(`p`,{role:`status`,className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,z(`takingYouTo`,e)]})}),Pre=({provider:e,workspace:t,onFailed:n})=>{let{signInProviders:r,signInSocial:i}=B(),a=r.find(t=>t.id===e),o=a?.name??pf(e),s=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{if(!s.current){if(s.current=!0,!a)return n(z(`providerNotOffered`,o));i(e).catch(e=>{if(!(e instanceof Dc))throw e;n(tf(e))})}},[a,o,e,i,n]),(0,R.jsx)(Nre,{name:o,workspace:t})},Fre=({onSubmit:e,invalidLink:t,onRequestNewLink:n,onBack:r,busy:i,error:a})=>{let[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(!1);if(t)return(0,R.jsxs)(qh,{title:z(`linkExpiredTitle`),children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`linkExpiredExplanation`)}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[n&&(0,R.jsx)(V,{variant:`primary`,className:`min-h-10`,onClick:n,children:z(`sendNewLink`)}),(0,R.jsx)(V,{variant:n?`ghost`:`primary`,className:`min-h-10`,onClick:r,children:z(`backToSignIn`)})]})]});let f=u?z(`passwordsDiffer`):a;return(0,R.jsx)(qh,{title:z(`choosePassword`),description:z(`atLeast`,12),children:(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),d(o!==c),o===c&&e(o)},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`newPassword`),(0,R.jsx)(Rd,{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,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`repeatPassword`),(0,R.jsx)(Rd,{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,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:z(`setPassword`)})]})})},Ire=e=>e.status===429?z(`tooManyAttempts`):e.code===`PASSWORD_TOO_SHORT`?z(`useAtLeast`,12):e.code===`PASSWORD_TOO_LONG`?z(`passwordTooLong`):e.message,Lre=({token:e,onDone:t,onRequestNewLink:n,onBack:r})=>{let{session:i}=B(),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(),[l,u]=(0,I.useState)(!e),d=async n=>{o(!0),c(void 0);try{await i.resetPassword(e,n),t()}catch(e){if(!(e instanceof Dc))throw e;e.code===`INVALID_TOKEN`?u(!0):c(Ire(e)),o(!1)}};return(0,R.jsx)(Fre,{busy:a,error:s,invalidLink:l,onRequestNewLink:n,onBack:r,onSubmit:e=>void d(e)})},Rre=e=>z(e===`twoFactor`?`turnOnTwoFactor`:`addPasskey`),zre=({step:e,twoFactor:t,onAddPasskey:n,busy:r,error:i,onSignOut:a})=>(0,R.jsxs)(qh,{title:Rre(e),description:z(`requiredForEveryAccount`),children:[e===`twoFactor`?(0,R.jsx)(um,{...t}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`passkeyExplanation`)}),i&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,R.jsxs)(V,{variant:`primary`,loading:r,onClick:n,className:`min-h-10`,children:[(0,R.jsx)(pa,{className:`size-4`}),z(`addPasskey`)]})]}),(0,R.jsx)(`button`,{type:`button`,onClick:a,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:underline`,children:z(`signOut`)})]}),Bre=({missing:e})=>{let{session:t,recheck:n,signOut:r}=B(),[i,a]=(0,I.useState)(),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)();(0,I.useEffect)(()=>{t.account.signInMethods().then(a,e=>l(e instanceof Dc?ef(e):z(`couldNotReadAccount`)))},[t]);let u=async()=>{s(!0),l(void 0);try{await t.account.addPasskey(),n()}catch(e){if(!(e instanceof Dc))throw e;l(ef(e)),s(!1)}};return!i&&!c?(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,z(`loading`)]}):(0,R.jsx)(zre,{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}})},Vre=({className:e})=>(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:g(`size-4 shrink-0`,e),"aria-hidden":!0,children:(0,R.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`})}),Hre=({id:e,className:t})=>e===`github`?(0,R.jsx)(Vre,{className:t}):null,Ure=()=>(0,R.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`h-px flex-1 bg-border`}),z(`or`),(0,R.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),Wre=({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,I.useState)(``),[g,_]=(0,I.useState)(``),v=(0,I.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,R.jsxs)(qh,{title:z(`signInTitle`),description:r,children:[i&&(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[S.map(e=>(0,R.jsxs)(V,{onClick:()=>d?.(e.id),disabled:t,className:`min-h-10 w-full`,children:[(0,R.jsx)(Hre,{id:e.id}),z(`continueWith`,e.name)]},e.id)),x&&(0,R.jsxs)(V,{onClick:()=>s?.(),disabled:t,className:`min-h-10 w-full`,children:[(0,R.jsx)(pa,{className:`size-4`}),z(`signInWithPasskey`)]}),x&&c.slice(1).map(e=>(0,R.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>s?.(e),disabled:t,className:`w-full`,children:z(`passkeyFor`,e)},e))]}),y||b?(0,R.jsx)(Ure,{}):n&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-4 text-body font-medium text-danger-text`,children:n})]}),(y||b)&&(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),y?e(m.trim(),g):C()},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`email`),(0,R.jsx)(Rd,{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,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`password`),(0,R.jsx)(Rd,{type:`password`,name:`password`,autoComplete:`current-password`,required:!0,value:g,invalid:!!n,onChange:e=>_(e.target.value),className:`min-h-6`})]}),n&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:n}),y&&(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:t,className:`min-h-10`,children:z(`signIn`)}),b&&(0,R.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,R.jsx)(Na,{className:`size-4`}),z(`emailSignInCode`)]}),y&&l&&(0,R.jsx)(Ku,{to:l,className:`self-center font-medium text-primary-text hover:underline`,children:z(`forgotPassword`)})]}),f&&(0,R.jsxs)(`p`,{className:`mt-4 text-center text-muted-foreground`,children:[z(`newHere`),` `,(0,R.jsx)(Ku,{to:f,className:`font-medium text-primary-text hover:underline`,children:z(`createAnAccount`)})]}),p&&(0,R.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:z(`browse`)})]})},Gre=({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}=B(),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(o),v=async(e,t)=>{h(!0),_(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;_(t(e)),h(!1)}};return(0,R.jsx)(Wre,{busy:m,error:g,workspace:e,notice:t,methods:u,forgotPassword:n,signUp:r,onBrowse:i,providers:l,onContinueWith:e=>void v(()=>c(e),tf),passkeyDomains:d,onPasskey:e=>void v(()=>p(e),ef),onSendCode:e=>void v(async()=>{await f(e),a(e)},ef),onSubmit:(e,t)=>void v(()=>s(e,t),tf)})},Kre=({email:e,onBack:t,...n})=>(0,R.jsx)(Yh,{title:z(`checkEmail`),description:z(`signUpCodeDescription`),explanation:(0,R.jsx)(R.Fragment,{children:Xh(z(`signUpCodeSent`),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),submitLabel:z(`continue`),onChangeAddress:t,changeAddressLabel:z(`useAnotherAddress`),...n}),qre=({email:e,onSubmit:t,onBack:n,methods:r,busy:i,error:a})=>{let[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),u=(0,I.useId)(),d=r.includes(`password`),f=r.includes(`emailCode`);return(0,R.jsxs)(qh,{title:z(`detailsTitle`),description:z(`detailsDescription`),children:[(0,R.jsx)(`p`,{className:`mb-4 text-muted-foreground`,children:Xh(z(`codeWasRight`),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e}))}),(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({name:o.trim(),...d&&c&&{password:c}})},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`yourName`),(0,R.jsx)(Rd,{name:`name`,autoComplete:`name`,required:!0,autoFocus:!0,maxLength:200,value:o,onChange:e=>s(e.target.value),className:`min-h-6`})]}),d&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(f?`passwordOptional`:`password`),(0,R.jsx)(Rd,{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,R.jsxs)(`p`,{id:u,className:`text-xs text-muted-foreground`,children:[z(`atLeast`,12),f&&z(`withoutPassword`)]})]}),a&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:z(`createAccount`)}),(0,R.jsx)(V,{variant:`ghost`,onClick:n,className:`min-h-10`,children:z(`useAnotherAddress`)})]})]})},Jre=({onSubmit:e,onSignIn:t,onBrowse:n,busy:r,error:i,workspace:a})=>{let[o,s]=(0,I.useState)(``);return(0,R.jsxs)(qh,{title:z(`createAnAccount`),description:a,children:[(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:t=>{t.preventDefault(),e(o.trim())},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`email`),(0,R.jsx)(Rd,{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,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`codeToConfirm`)}),i&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,R.jsxs)(V,{variant:`primary`,type:`submit`,loading:r,className:`min-h-10`,children:[(0,R.jsx)(Na,{className:`size-4`}),z(`emailCode`)]}),(0,R.jsxs)(`p`,{className:`text-center text-muted-foreground`,children:[z(`haveAccount`),` `,(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`font-medium text-primary-text hover:underline`,children:z(`signIn`)})]})]}),n&&(0,R.jsx)(`button`,{type:`button`,onClick:n,className:`mt-4 w-full text-center font-medium text-muted-foreground hover:text-foreground hover:underline`,children:z(`browseWithoutAccount`)})]})},Yre=({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}=B(),[f,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(),[g,_]=(0,I.useState)(),v=async e=>{p(!0),h(void 0),_(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;h(ef(e))}p(!1)};return t===void 0?(0,R.jsx)(Jre,{workspace:e,busy:f,error:m,onSignIn:o,onBrowse:s,onSubmit:e=>void v(async()=>{await l(e),r(e)})}):n===void 0?(0,R.jsx)(Kre,{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),_(z(`newCodeSent`))})}):(0,R.jsx)(qre,{email:t,methods:c,busy:f,error:m,onBack:a,onSubmit:e=>void v(()=>d({ticket:n,...e}))})},Qh=`staff-sign-in`,$h=`staff-error`,Xre=e=>{let t=new URL(e).searchParams,n=t.get($h);if(!t.has(`staff-sign-in`)&&!n)return;let r=t.has(Qh);return{email:r&&t.get(`email`)||``,reason:r&&t.get(`reason`)||``,...n&&{error:n}}},eg=e=>{let t=new URL(e);if(t.searchParams.has(`staff-sign-in`))for(let e of[Qh,`email`,`reason`])t.searchParams.delete(e);return t.searchParams.delete($h),`${t.pathname}${t.search}${t.hash}`},Zre=10,Qre=({operator:e,email:t=``,reason:n=``,onSubmit:r,onBack:i,busy:a,error:o})=>{let[s,c]=(0,I.useState)(t),[l,u]=(0,I.useState)(n);return e?(0,R.jsx)(qh,{title:z(`signInAsPerson`),description:z(`forStaffOf`,e),children:(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),r(s.trim(),l.trim())},children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`theirEmail`),(0,R.jsx)(Rd,{type:`email`,name:`email`,required:!0,autoFocus:!t,value:s,onChange:e=>c(e.target.value),className:`min-h-6`})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(`reason`),(0,R.jsx)(`textarea`,{name:`reason`,required:!0,minLength:Zre,rows:3,value:l,placeholder:z(`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,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:z(`staffExplanation`,e)}),o&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:o}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:a,className:`min-h-10`,children:z(`continueWith`,e)}),(0,R.jsx)(V,{variant:`ghost`,onClick:i,className:`min-h-10`,children:z(`backToSignIn`)})]})}):(0,R.jsxs)(qh,{title:z(`staffTitle`),description:z(`staffUnavailable`),children:[o&&(0,R.jsx)(`p`,{role:`alert`,className:`mb-4 text-body font-medium text-danger-text`,children:o}),(0,R.jsx)(V,{variant:`primary`,className:`min-h-10 w-full`,onClick:i,children:z(`backToSignIn`)})]})},$re=({link:e,onBack:t})=>{let{session:n,staffSignIn:r}=B(),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(e.error&&rf(e.error)),c=async(e,t)=>{a(!0),s(void 0);try{let r=`${window.location.origin}${eg(window.location.href)}`;window.location.assign(await n.staff.start({email:e,reason:t,callbackURL:r}))}catch(e){if(!(e instanceof Dc))throw e;s(rf(e)),a(!1)}};return(0,R.jsx)(Qre,{operator:r,email:e.email,reason:e.reason,busy:i,error:o,onBack:t,onSubmit:(e,t)=>void c(e,t)})},tg=({checked:e,indeterminate:t,onChange:n,label:r,disabled:i,className:a})=>(0,R.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,R.jsx)(Va,{className:`size-3`,strokeWidth:3}):e&&(0,R.jsx)(Ci,{className:`size-3`,strokeWidth:3})}),eie={totp:`totpInstruction`,otp:`otpInstruction`,backup:`backupInstruction`},tie=({methods:e,onVerify:t,onSendCode:n,onBack:r,busy:i,error:a,codeSent:o,initialStep:s})=>{let[c,l]=(0,I.useState)(s??(e.includes(`totp`)?`totp`:`otp`)),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(!1),m=c===`otp`&&!o,h=e=>{l(e),d(``),e===`otp`&&!o&&n()};return(0,R.jsxs)(qh,{title:z(`twoFactorTitle`),description:z(`twoFactorDescription`),children:[m?(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`codeToFinish`)}),a&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,R.jsx)(V,{variant:`primary`,loading:i,onClick:n,className:`min-h-10`,children:z(`emailCode`)})]}):(0,R.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t({method:c,code:u.trim(),trustDevice:f})},children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(eie[c])}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 font-medium`,children:[z(c===`backup`?`backupCode`:`code`),c===`backup`?(0,R.jsx)(Rd,{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,R.jsx)(yp,{name:`code`,required:!0,autoFocus:!0,value:u,invalid:!!a,onChange:d})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(tg,{checked:f,onChange:p,label:z(`trustBrowser`)}),z(`trustBrowserFor`)]}),a&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:a}),(0,R.jsx)(V,{variant:`primary`,type:`submit`,loading:i,className:`min-h-10`,children:z(`verify`)})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-col items-center gap-2 border-t pt-4`,children:[c!==`totp`&&e.includes(`totp`)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(`totp`),className:`font-medium text-primary-text hover:underline`,children:z(`useAuthenticator`)}),c!==`otp`&&e.includes(`otp`)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(`otp`),className:`font-medium text-primary-text hover:underline`,children:z(`emailCodeInstead`)}),c!==`backup`&&e.includes(`totp`)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(`backup`),className:`font-medium text-primary-text hover:underline`,children:z(`useBackupCode`)}),(0,R.jsx)(`button`,{type:`button`,onClick:r,className:`font-medium text-muted-foreground hover:underline`,children:z(`backToSignIn`)})]})]})},nie=({methods:e,onBack:t})=>{let{verifyTwoFactor:n,session:r}=B(),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(),[c,l]=(0,I.useState)(!1),u=async e=>{a(!0),s(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;s(ef(e))}a(!1)};return(0,R.jsx)(tie,{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)})})},ng=()=>{let{path:e,params:t,basePath:n,navigate:r}=Bh(),i=(0,I.useMemo)(()=>Fs(e,t),[e,t]),a=df(new URL(t.size>0?`${e}?${t}`:e,`http://local`).href),o=i?i.next:a,s=(0,I.useCallback)((e=`sign-in`,t)=>r(Ps({step:e,next:o}),t),[r,o]);return{address:i,next:o,open:s,link:(0,I.useCallback)((e=`sign-in`,t)=>({href:`${n}${Ps({step:e,next:o})}`,onFollow:()=>s(e,t)}),[n,o,s]),leave:(0,I.useCallback)(()=>r(o??`/`,{replace:!0}),[r,o])}},rie=e=>{let t=new URL(e),n=t.searchParams.get(`token`);return t.pathname.endsWith(`/-/invitation`)&&n?{token:n}:void 0},iie=e=>`${new URL(e).pathname.slice(0,-13)}/`,G=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`}}),rg=`/-/organizations`,ig=`/-/organization`,ag=`/-/organization/members`,og=`/-/organization/invitations`,aie={[rg]:`organizations`,[ig]:`organization`,[ag]:`members`,[og]:`invitations`},oie=e=>{let t=aie[e];return t&&G(t)},sg=e=>G(e),cg=(e,t)=>e.find(e=>e.name===t)?.label??t,lg=e=>e?.role===`owner`||e?.role===`admin`,sie=(e,t,n)=>{let r=(n,r,i,a)=>({id:n,label:r,icon:i,href:`${e}${a}`,active:t===a});return[r(`organizations`,G(`organizations`),Ka,rg),...n?.organization?[r(`organization`,G(`organization`),gi,ig)]:[],...lg(n)?[r(`members`,G(`members`),as,ag),r(`invitations`,G(`invitations`),Na,og)]:[]]},ug=(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)))},dg=()=>{let[e,t]=(0,I.useState)(!1),[n,r]=(0,I.useState)();return{busy:e,error:n,run:async e=>{t(!0),r(void 0);try{await e()}catch(e){if(!(e instanceof Dc))throw e;r(ef(e))}t(!1)},setError:r}},fg=({token:e,preview:t,joins:n,onDone:r})=>{let{session:i,signInMethods:a,recheck:o}=B(),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(``),{busy:d,error:f,run:p}=dg(),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,R.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:G(n?`makeAccountToJoin`:`makeAccount`,t.email)}),f&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,R.jsx)(Rd,{"aria-label":G(`yourName`),placeholder:G(`yourName`),autoComplete:`name`,value:s,onChange:e=>c(e.target.value)}),m&&(0,R.jsx)(Rd,{"aria-label":G(`password`),type:`password`,autoComplete:`new-password`,placeholder:G(h?`passwordOptional`:`passwordRequired`,12),value:l,onChange:e=>u(e.target.value)}),(0,R.jsx)(V,{type:`submit`,variant:`primary`,loading:d,disabled:!s.trim()||m&&!h&&l.length<12,children:G(n?`createAndJoin`:`createYourAccount`)})]})},cie=({token:e,onDone:t,signIn:n})=>{let{session:r,state:i,signOut:a,organizations:o}=B(),[s,c]=(0,I.useState)(),[l,u]=(0,I.useState)(),{busy:d,error:f,run:p}=dg();if((0,I.useEffect)(()=>{r.organizations.invitation(e).then(c,e=>u(e instanceof Dc?ef(e):G(`invalidLink`)))},[r,e]),l)return(0,R.jsx)(qh,{title:G(`invitation`),description:l,children:(0,R.jsx)(V,{className:`w-full`,onClick:t,children:G(`goToApp`)})});if(!s)return(0,R.jsx)(qh,{title:G(`invitation`),children:(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,G(`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=G(`invitesToApp`,s.inviter.name,r);return(0,R.jsx)(qh,{title:G(`join`,r),description:i,children:s.hasAccount?m&&h?(0,R.jsx)(V,{variant:`primary`,className:`w-full`,onClick:t,children:G(`goToApp`)}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:G(`hasAccount`,s.email)}),m?(0,R.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:G(`signOut`)}):(0,R.jsx)(Ku,{to:n,className:g(op({variant:`primary`}),`w-full`),children:G(`signInAs`,s.email)})]}):m?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:G(`otherAddress`,s.email,m.email)}),(0,R.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:G(`signOutToAccept`)})]}):(0,R.jsx)(fg,{token:e,preview:s,joins:!1,onDone:t})})}let _=s.organization,v=s.appRoles.map(e=>cg(o?.roles??[],e)),y=sg(s.role).toLowerCase(),b=v.length>0?G(`invitesToWith`,s.inviter.name,_.name,y,v.join(`, `)):G(`invitesTo`,s.inviter.name,_.name,y);return m&&!h?(0,R.jsxs)(qh,{title:G(`join`,_.name),description:b,children:[(0,R.jsx)(`p`,{className:`mb-3 text-muted-foreground`,children:G(`otherAddress`,s.email,m.email)}),(0,R.jsx)(V,{className:`w-full`,onClick:()=>void a(),children:G(`signOutToAccept`)})]}):(0,R.jsx)(qh,{title:G(`join`,_.name),description:b,children:m?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:f}),(0,R.jsx)(V,{variant:`primary`,className:`w-full`,loading:d,onClick:()=>void p(async()=>{await r.organizations.accept(e),t()}),children:G(`join`,_.name)})]}):s.hasAccount?(0,R.jsx)(Ku,{to:n,className:g(op({variant:`primary`}),`w-full`),children:G(`signInAsToJoin`,s.email)}):(0,R.jsx)(fg,{token:e,preview:s,joins:!0,onDone:t})})},pg,mg,lie=({dsn:e,environment:t})=>(pg??=m(()=>import(`./prod-YZ9ZMG1O.js`).then(n=>{n.init({dsn:e,...t&&{environment:t},integrations:e=>e.filter(e=>e.name!==`BrowserSession`),beforeSend:e=>Er(e)}),mg=(e,t)=>n.captureException(e,t?{contexts:{react:{componentStack:t}}}:void 0)}),[]),pg),hg=(e,t)=>mg?.(e,t??void 0),gg=({children:e})=>(0,R.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-dashed border-warning bg-warning-soft p-3 text-warning-text`,children:e}),_g=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`}}),vg=class extends I.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){hg(e,t.componentStack)}render(){return this.state.failed?this.props.fallback===void 0?(0,R.jsx)(gg,{children:Xh(_g(`couldNotDraw`),this.props.name)}):this.props.fallback:this.props.children}},uie=/^[A-Z][A-Za-z0-9]*$/,die=e=>typeof e==`function`||typeof e==`object`&&!!e&&`$$typeof`in e,yg=e=>{let t=e.default??{},n=Object.entries(e).filter(e=>e[0]!=="default"&&uie.test(e[0])&&die(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)}}},bg=class extends Error{name=`UiConflictError`},fie=e=>Object.keys(e).some(e=>e==="default"||/^[A-Z]/.test(e))?yg(e):e,xg=(e,t)=>[...(e.extends??[]).map(fie).flatMap((e,n)=>xg(e,e.name??`${t} extends[${n}]`)),{ui:e,label:t}],Sg=(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 bg(`${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},Cg=e=>e.length<=1?e[0]:()=>e.map((e,t)=>(0,R.jsx)(e,{},t)),pie=e=>e.length<=1?e[0]:({children:t,...n})=>e.reduceRight((e,t)=>(0,R.jsx)(t,{...n,children:e}),t),wg=(...e)=>{let t=e.flatMap((e,t)=>xg(e,e.name??`UI config ${t+1}`)),n=Sg(`The component`,t,e=>e.components),r=Sg(`The action handler`,t,e=>e.actions),i=Sg(`The field type`,t,e=>e.fields),a=Sg(`The drop rule`,t,e=>e.dropRules),o=Sg(`The board drop`,t,e=>e.boardDrops),s=Cg(t.flatMap(({ui:e})=>e.shell?.actions?[e.shell.actions]:[])),c=Cg(t.flatMap(({ui:e})=>e.shell?.rightPanel?[e.shell.rightPanel]:[])),l=t.findLast(({ui:e})=>e.shell?.logo)?.ui.shell?.logo,u=pie(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}}},Tg=(e,t)=>{let n=wg(e??{}),r=[],i=[];for(let e of t){if(e.kind===`off`){i.push(e);continue}try{wg(...r,e.ui,n),r.push(e.ui)}catch(t){if(!(t instanceof bg))throw t;i.push({kind:`off`,url:e.plugin.url,name:e.plugin.name,reason:t.message})}}return{ui:r.length===0?n:wg(...r,n),off:i}},Eg=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`}}),Dg=e=>typeof e==`string`&&e.trim()!==``,mie=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return{problem:Eg(`notObject`)};let{name:t,version:n,api:r,protobase:i,entry:a,css:o}=e;return Dg(t)?Number.isInteger(r)?Dg(i)?Dg(a)?o!==void 0&&!Dg(o)?{problem:Eg(`badStylesheet`)}:n!==void 0&&!Dg(n)?{problem:Eg(`badVersion`)}:{manifest:{name:t,api:r,protobase:i,entry:a,...n!==void 0&&{version:n},...o!==void 0&&{css:o}}}:{problem:Eg(`noModule`)}:{problem:Eg(`noVersions`)}:{problem:Eg(`noApi`)}:{problem:Eg(`noName`)}},Og=(0,I.createContext)(null),hie=Og.Provider,gie=()=>{let e=(0,I.useContext)(Og);if(!e)throw Error(`usePlugin is for the components of a plugin the app loaded`);return e},kg=(e,t,n)=>{let r=n=>(0,R.jsx)(hie,{value:e,children:(0,R.jsx)(t,{...n})});return r.displayName=`${e.name}:${n}`,r},_ie=(e,t,n)=>({of:n.of,display:kg(e,n.display,`fields.${t}.display`),...n.editor&&{editor:kg(e,n.editor,`fields.${t}.editor`)},...n.cell&&{cell:kg(e,n.cell,`fields.${t}.cell`)}}),vie=(e,t)=>{let n=wg({...yg(t),name:e.name}),r=Object.fromEntries(Object.entries(n.components??{}).map(([t,n])=>[t,kg(e,n,t)])),i=n.fields&&Object.fromEntries(Object.entries(n.fields).map(([t,n])=>[t,_ie(e,t,n)])),a=n.shell&&{...n.shell.actions&&{actions:kg(e,n.shell.actions,`shell.actions`)},...n.shell.rightPanel&&{rightPanel:kg(e,n.shell.rightPanel,`shell.rightPanel`)},...n.shell.logo&&{logo:kg(e,n.shell.logo,`shell.logo`)}},o=n.beforeSignIn&&kg(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}}},Ag={name:`@protobase/ui`,version:`0.28.4`,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`,prepack:`tsdown && protobase build-shell dist/shell`},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`}},jg=Ag.protobase.pluginApi,Mg=Ag.version,yie={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),[])},bie={api:jg,version:Mg},xie=e=>e instanceof Error?e.message:String(e),Sie=async(e,t,n,r=bie)=>{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(Eg(`answered`,n.status));let s=mie(n.json);if(`problem`in s)return a(s.problem);let{manifest:c}=s;o=c.name;let l=_r(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:vie(d,u)}}catch(e){return a(Eg(`couldNotLoad`,xie(e)),o)}},Cie=e=>{let t=new Map;return{load:n=>{let r=JSON.stringify(n),i=t.get(r);if(i)return i;let a=Sie(n,e,window.location.href);return t.set(r,a),a}}},Ng=(0,I.createContext)(null),wie=({loader:e=yie,children:t})=>{let n=(0,I.useMemo)(()=>Cie(e),[e]);return(0,R.jsx)(Ng.Provider,{value:n,children:t})},Pg=()=>{let e=(0,I.useContext)(Ng);if(!e)throw Error(`usePluginSource must be used inside PluginSourceProvider`);return e},Tie=1e4,Fg=[],Ig=(e,t)=>{let n=JSON.stringify(e),[r,i]=(0,I.useState)({key:`[]`,loads:Fg,settled:!0});return(0,I.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()},Tie);return e.forEach((e,n)=>{t.load(e).then(e=>{o[n]=e,s()})}),()=>{r=!1,clearTimeout(c)}},[n,t]),e.length===0?{loads:Fg,settled:!0}:r.key===n?r:{loads:Fg,settled:!1}},Eie=({children:e})=>{let{state:t,beforeSignIn:n,adoptSession:r}=B(),{path:i,params:a,navigate:o}=Bh(),{loads:s,settled:c}=Ig(n,Pg()),l=(0,I.useMemo)(()=>Tg(void 0,s).ui.beforeSignIn,[s]),u=(0,I.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,R.jsx)(vg,{name:`beforeSignIn`,fallback:e,children:(0,R.jsx)(l,{signedIn:r,params:a,removeParams:u,children:e})}):e:(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,Eg(`loading`)]})},Die=()=>{let e=window.location.href,t=Are(e);if(t)return{kind:`reset-password`,token:t.token};let n=Xre(e);if(n)return{kind:`staff-sign-in`,link:n};let r=rie(e);if(r)return{kind:`invitation`,token:r.token};let i=lf(e);if(i)return{kind:`provider-sign-in`,provider:i};let a=uf(e);return a?{kind:`sign-in`,providerError:a}:{kind:`sign-in`}},Lg=({to:e})=>{let{navigate:t}=Bh();return(0,I.useEffect)(()=>t(e,{replace:!0}),[t,e]),null},Oie=({workspace:e,children:t})=>{let n=kie(e,t);return(0,R.jsx)(Eie,{children:n})},kie=(e,t)=>{let{state:n,recheck:r,passwordReset:i,signOut:a,signInProviders:o,canSignUp:s,browse:c}=B(),{path:l,params:u,basePath:d,navigate:f}=Bh(),{address:p,next:m,open:h,link:g,leave:_}=ng(),[v,y]=(0,I.useState)(Die),[b,x]=(0,I.useState)(),[S,C]=(0,I.useState)(),[w,T]=(0,I.useState)(),E=new URL(`${d}${l}${u.size>0?`?${u}`:``}`,window.location.origin).href,D=(0,I.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,I.useEffect)(()=>{O&&(v.kind===`provider-sign-in`&&D(df),(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&&uf(E)!==void 0;(0,I.useEffect)(()=>{!O&&v.kind===`sign-in`&&v.providerError&&k&&D(df)},[O,v,k,D]);let A=(0,I.useCallback)(e=>y({kind:`sign-in`,error:e}),[]),j=e=>{D(jre),y(e)},M=async()=>{n.kind===`signed-in`&&await a(),j({kind:`sign-in`,notice:z(`passwordChanged`)})},N=()=>{y({kind:`sign-in`}),a().then(()=>h(`sign-in`,{replace:!0}))};switch(n.kind){case`loading`:return(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,z(`loading`)]});case`error`:return(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:z(`cannotReach`,n.message)}),(0,R.jsx)(V,{onClick:r,children:z(`tryAgain`)})]});case`needs-admin`:return(0,R.jsx)(Dre,{onCheckAgain:r})}if(n.kind===`signed-in`&&p)return(0,R.jsx)(Lg,{to:m??`/`});if(v.kind===`reset-password`)return(0,R.jsx)(Lre,{token:v.token,onDone:()=>void M(),onRequestNewLink:i?()=>{y({kind:`sign-in`}),f(Ps({step:`forgot-password`}),{replace:!0})}:void 0,onBack:()=>j({kind:`sign-in`})});if(v.kind===`staff-sign-in`)return(0,R.jsx)($re,{link:v.link,onBack:()=>{D(eg),y({kind:`sign-in`})}});let ee=n.kind===`signed-out`||n.kind===`visitor`;if(v.kind===`invitation`&&(n.kind===`signed-in`||ee&&!p))return(0,R.jsx)(cie,{token:v.token,onDone:()=>{D(iie),y({kind:`sign-in`})},signIn:g()});if(n.kind===`signed-in`)return t;if(n.kind===`two-factor`)return(0,R.jsx)(nie,{methods:n.methods,onBack:N});if(n.kind===`setup-required`)return(0,R.jsx)(Bre,{missing:n.missing},n.missing.join());if(v.kind===`provider-sign-in`)return(0,R.jsx)(Pre,{provider:v.provider,workspace:e,onFailed:A});let te=v.kind===`sign-in`?v:{kind:`sign-in`};if(!p){let e=te.notice||te.error||te.providerError;return n.kind===`visitor`&&!e?t:(0,R.jsx)(Lg,{to:Ps({next:m})})}let ne={"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`,re=e=>()=>h(e,{replace:!0}),ie=c&&(()=>{c(),_()});if(ne===`forgot-password`)return(0,R.jsx)(Mre,{back:g(`sign-in`,{replace:!0})});if(ne===`email-code`)return(0,R.jsx)(Tre,{email:b,onBack:re(`sign-in`)});if(ne===`sign-up`||ne===`sign-up-code`||ne===`sign-up-details`)return(0,R.jsx)(Yre,{workspace:e,email:ne===`sign-up`?void 0:S,ticket:ne===`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:re(`sign-up`),onSignIn:()=>h(`sign-in`),onBrowse:ie},ne);let ae=te.providerError&&of(te.providerError,o.length===1?o[0].name:`the provider`),oe=te.error??ae;return(0,R.jsx)(Gre,{workspace:e,notice:te.notice,error:oe,forgotPassword:i?g(`forgot-password`):void 0,onCodeSent:e=>{x(e),h(`email-code`)},signUp:s?g(`sign-up`):void 0,onBrowse:ie},oe)},Rg=e=>[...e].reduce((e,t)=>(e*31+t.charCodeAt(0))%360,7),zg=e=>e.split(/[\s@.]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join(``),Bg=e=>(e.role??`user`).split(`,`).map(e=>e.trim()),Vg=e=>Bg(e).includes(`admin`),Aie=e=>{let t=Bg(e),n=t.includes(`admin`);return{name:e.name||e.email,email:e.email,initials:zg(e.name||e.email)||`?`,hue:Rg(e.id||e.email),role:n?z(`admin`):(t[0]??`user`).replace(/^./,e=>e.toUpperCase()),roleTone:n?`violet`:`blue`}},jie=3e4,Mie=(e,t=Date.now())=>Math.max(1e3,hu(e)-t-jie),Hg=()=>{let{state:e,session:t}=B(),n=e.kind===`signed-in`,[r,i]=(0,I.useState)();return(0,I.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),Mie(s))))};return a(),()=>{e=!1,clearTimeout(r)}},[t,n]),n?r:void 0},Ug=({locale:e,children:t})=>{h(e);let n=p();return(0,I.useEffect)(()=>{document.documentElement.lang=n},[n]),(0,R.jsx)(I.Fragment,{children:t},n)},Nie=({children:e})=>(0,R.jsx)(Ug,{locale:B().locale,children:e}),Pie=(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)}},Fie=(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}},Wg=(e,t)=>e.sources?.find(e=>e.source.resources.includes(t)),Iie=e=>{let t=U(),n=Om(),r=(0,I.useContext)(Nh),i=(0,I.useMemo)(()=>Object.values(e.resources).filter(t=>t.live&&!Wg(e,t.name)).map(e=>e.name).sort().join(`,`),[e]);(0,I.useEffect)(()=>{if(!i)return;let e=Pie(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])},Gg=(e,t,n=!0)=>{let r=U(),i=ur(t);return Ah({queryKey:H.record(e,i),enabled:n,queryFn:()=>r.get(e,t)})},Kg=(e,t,n=!0)=>{let r=U(),i=Om(),a=ur(t);return Ah({queryKey:H.record(e,a),enabled:n,queryFn:()=>r.get(e,t),placeholderData:()=>i.getQueryData(H.recordPreview(e,a))})},Lie=e=>e.charAt(0).toUpperCase()+e.slice(1),K=e=>Lie(e.replace(/(Id|Code|_id|_code)$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/_+/g,` `).trim().toLowerCase()||e);function Rie(){var e=[...arguments];return(0,I.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var qg=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Jg(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Yg(e){return`nodeType`in e}function Xg(e){return e?Jg(e)?e:Yg(e)?e.ownerDocument?.defaultView??window:window:window}function Zg(e){let{Document:t}=Xg(e);return e instanceof t}function Qg(e){return!Jg(e)&&e instanceof Xg(e).HTMLElement}function $g(e){return e instanceof Xg(e).SVGElement}function e_(e){return e?Jg(e)?e.document:Yg(e)?Zg(e)?e:Qg(e)||$g(e)?e.ownerDocument:document:document:document}var t_=qg?I.useLayoutEffect:I.useEffect;function n_(e){let t=(0,I.useRef)(e);return t_(()=>{t.current=e}),(0,I.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function zie(){let e=(0,I.useRef)(null);return[(0,I.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,I.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function r_(e,t){t===void 0&&(t=[e]);let n=(0,I.useRef)(e);return t_(()=>{n.current!==e&&(n.current=e)},t),n}function i_(e,t){let n=(0,I.useRef)();return(0,I.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function a_(e){let t=n_(e),n=(0,I.useRef)(null);return[n,(0,I.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function o_(e){let t=(0,I.useRef)();return(0,I.useEffect)(()=>{t.current=e},[e]),t.current}var s_={};function c_(e,t){return(0,I.useMemo)(()=>{if(t)return t;let n=s_[e]==null?0:s_[e]+1;return s_[e]=n,e+`-`+n},[e,t])}function l_(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 u_=l_(1),d_=l_(-1);function Bie(e){return`clientX`in e&&`clientY`in e}function f_(e){if(!e)return!1;let{KeyboardEvent:t}=Xg(e.target);return t&&e instanceof t}function Vie(e){if(!e)return!1;let{TouchEvent:t}=Xg(e.target);return t&&e instanceof t}function p_(e){if(Vie(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 Bie(e)?{x:e.clientX,y:e.clientY}:null}var m_=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[m_.Translate.toString(e),m_.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),h_=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Hie(e){return e.matches(h_)?e:e.querySelector(h_)}var g_={display:`none`};function __(e){let{id:t,value:n}=e;return I.createElement(`div`,{id:t,style:g_},n)}function v_(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return I.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 y_(){let[e,t]=(0,I.useState)(``);return{announce:(0,I.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var b_=(0,I.createContext)(null);function Uie(e){let t=(0,I.useContext)(b_);(0,I.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Wie(){let[e]=(0,I.useState)(()=>new Set),t=(0,I.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,I.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Gie={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,6 +64,6 @@ 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 lde(e,t){if(e){if(typeof e==`string`)return C$(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)?C$(e,t):void 0}}function C$(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 ude(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 dde(e){if(Array.isArray(e))return e}function fde(e,t){if(e==null)return{};var n,r,i=pde(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 pde(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 w$(){return w$=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},w$.apply(null,arguments)}function T$(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 E$(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?T$(Object(n),!0).forEach(function(t){mde(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T$(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mde(e,t,n){return(t=hde(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function hde(e){var t=gde(e,`string`);return typeof t==`symbol`?t:t+``}function gde(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 D$={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:_F.axis};function _de(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=E$(E$(E$({},c),$T(s)),{},{fill:`none`});if(a===`top`||a===`bottom`){var u=+(a===`top`&&!o||a===`bottom`&&o);l=E$(E$({},l),{},{x1:t,y1:n+u*i,x2:t+r,y2:n+u*i})}else{var d=+(a===`left`&&!o||a===`right`&&o);l=E$(E$({},l),{},{x1:t+d*r,y1:n,x2:t+d*r,y2:n+i})}return I.createElement(`line`,w$({},l,{className:qT(`recharts-cartesian-axis-line`,xE(s,`className`))}))}function vde(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 yde(e,t){switch(e){case`left`:return t?`start`:`end`;case`right`:return t?`end`:`start`;default:return`middle`}}function bde(e,t){switch(e){case`left`:case`right`:return`middle`;case`top`:return t?`start`:`end`;default:return t?`end`:`start`}}function xde(e){var t=e.option,n=e.tickProps,r=e.value,i,a=qT(n.className,`recharts-cartesian-axis-tick-value`);if(I.isValidElement(t))i=I.cloneElement(t,E$(E$({},n),{},{className:a}));else if(typeof t==`function`)i=t(E$(E$({},n),{},{className:a}));else{var o=`recharts-cartesian-axis-tick-value`;typeof t!=`boolean`&&(o=qT(o,BY(t))),i=I.createElement(VJ,w$({},n,{className:o}),r)}return i}function Sde(e){var t=e.ticks,n=e.axisType,r=e.axisId,i=xk(),a=(0,I.useRef)(null);return(0,I.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&&Gue(o.ticks,e)||(a.current={ticks:e,axisId:r,axisType:n},i(ide({ticks:e,axisId:r,axisType:n})))}},[i,t,r,n]),(0,I.useEffect)(()=>r==null||n==null?zE:()=>{i(ade({axisId:r,axisType:n}))},[i,r,n]),null}var Cde=(0,I.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=y$(E$(E$({},x),{},{ticks:r}),y,b),E=$T(x),D=eE(i),O=AJ(E.textAnchor)?E.textAnchor:yde(d,f),k=bde(d,f),A={};typeof a==`object`&&(A=a);var j=E$(E$({},E),{},{fill:`none`},A),M=T.map(e=>E$({entry:e},vde(e,p,m,h,g,d,_,f,v))),N=M.map(e=>{var t=e.entry,n=e.line;return I.createElement(fE,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},a&&I.createElement(`line`,w$({},j,n,{className:qT(`recharts-cartesian-axis-tick-line`,xE(a,`className`))})))}),ee=M.map((e,t)=>{var n=e.entry,r=e.tick,a=E$(E$({},E$(E$(E$(E$({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 I.createElement(fE,w$({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},QD(S,n,t)),i&&I.createElement(xde,{option:i,tickProps:a,value:`${typeof s==`function`?s(n.value,t):n.value}${c||``}`}))});return I.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${C}-ticks`},I.createElement(Sde,{ticks:T,axisId:w,axisType:C}),ee.length>0&&I.createElement(OK,{zIndex:_F.label},I.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${C}-tick-labels`,ref:t},ee)),N.length>0&&I.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${C}-tick-lines`},N))}),wde=(0,I.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=fde(e,sde),d=S$((0,I.useState)(``),2),f=d[0],p=d[1],m=S$((0,I.useState)(``),2),h=m[0],g=m[1],_=(0,I.useRef)(null);(0,I.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>nde({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin}),getCalculatedHeight:()=>rde({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var v=(0,I.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:I.createElement(OK,{zIndex:e.zIndex},I.createElement(fE,{className:qT(`recharts-cartesian-axis`,a)},I.createElement(_de,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:$T(e)}),I.createElement(Cde,{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}),I.createElement($J,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},I.createElement(mY,{label:e.label,labelRef:e.labelRef}),e.children)))}),O$=I.forwardRef((e,t)=>{var n=iO(e,D$);return I.createElement(wde,w$({},n,{ref:t}))});O$.displayName=`CartesianAxis`;var k$=(0,I.createContext)({grid:{stroke:`#ccc`,fill:`none`}});k$.Provider;var Tde=()=>(0,I.useContext)(k$),Ede=[`x1`,`y1`,`x2`,`y2`,`key`],Dde=[`offset`],Ode=[`xAxisId`,`yAxisId`],kde=[`xAxisId`,`yAxisId`];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){Ade(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 Ade(e,t,n){return(t=jde(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jde(e){var t=Mde(e,`string`);return typeof t==`symbol`?t:t+``}function Mde(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 M$(){return M$=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},M$.apply(null,arguments)}function N$(e,t){if(e==null)return{};var n,r,i=Nde(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 Nde(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 Pde=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 I.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function P$(e){var t=e.option,n=e.lineItemProps,r;if(I.isValidElement(t))r=I.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=$T(N$(n,Ede))??{};l.offset;var u=N$(l,Dde),d=Array.isArray(u.strokeDasharray)?u.strokeDasharray.join(`,`):u.strokeDasharray;r=I.createElement(`line`,M$({},u,{strokeDasharray:d,x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function Fde(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=N$(e,Ode),s=a.map((e,r)=>{var a=j$(j$({},o),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${r}`,index:r});return I.createElement(P$,{key:`line-${r}`,option:i,lineItemProps:a})});return I.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},s)}function Ide(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=N$(e,kde),s=a.map((e,r)=>{var a=j$(j$({},o),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${r}`,index:r});return I.createElement(P$,{option:i,lineItemProps:a,key:`line-${r}`})});return I.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},s)}function Lde(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 I.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 I.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function Rde(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 I.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 I.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},d)}var zde=(e,t)=>{var n=e.xAxis,r=e.width,i=e.height,a=e.offset;return rM(y$(j$(j$(j$({},D$),n),{},{ticks:iM(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},Bde=(e,t)=>{var n=e.yAxis,r=e.width,i=e.height,a=e.offset;return rM(y$(j$(j$(j$({},D$),n),{},{ticks:iM(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},Vde={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:_F.grid};function F$(e){var t=RM(),n=zM(),r=LM(),i=j$(j$({},iO(e,Vde)),{},{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=SM(),h=X(e=>QU(e,`xAxis`,a,m)),g=X(e=>QU(e,`yAxis`,o,m)),_=Tde(),v={stroke:i.stroke??_.grid.stroke,strokeWidth:i.strokeWidth??_.grid.strokeWidth,strokeOpacity:i.strokeOpacity??_.grid.strokeOpacity,strokeDasharray:i.strokeDasharray??_.grid.strokeDasharray};if(!Qj(l)||!Qj(u)||!Y(s)||!Y(c))return null;var y=i.verticalCoordinatesGenerator||zde,b=i.horizontalCoordinatesGenerator||Bde,x=i.horizontalPoints,S=i.verticalPoints;if((!x||!x.length)&&typeof b==`function`){var C=f&&f.length,w=b({yAxis:g?j$(j$({},g),{},{ticks:C?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},C?!0:d);TM(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?j$(j$({},h),{},{ticks:T?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},T?!0:d);TM(Array.isArray(E),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof E}]`),Array.isArray(E)&&(S=E)}return I.createElement(OK,{zIndex:i.zIndex},I.createElement(`g`,{className:`recharts-cartesian-grid`},I.createElement(Pde,{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}),I.createElement(Lde,M$({},i,{horizontalPoints:x})),I.createElement(Rde,M$({},i,{verticalPoints:S})),I.createElement(Fde,M$({},i,v,{offset:r,horizontalPoints:x,xAxis:h,yAxis:g})),I.createElement(Ide,M$({},i,v,{offset:r,verticalPoints:S,xAxis:h,yAxis:g}))))}F$.displayName=`CartesianGrid`;var Hde=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function I$(){return I$=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},I$.apply(null,arguments)}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 Gde(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function L$(e,t){return`${t}px ${e}px`}function Kde(e){return e.length%2==0?e:[...e,...e]}function qde(e,t){for(var n=[],r=0;r<t;++r)n.push(...e);return n}function Jde(e,t,n){var r=Kde(n),i=r.reduce((e,t)=>e+t,0);if(!i)return L$(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[...qde(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function Yde(e,t,n){return e?Jde(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):L$(t,n)}function Xde(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=Ude(e,Hde),a=r??!1,o;if(t!=null){var s=i.pathRef;o=Yde(n,Gde(s?.current??null),t)}else n!=null&&(o=String(n));return I.createElement(SN,I$({},i,{connectNulls:a,strokeDasharray:o}))}function Zde(e){var t=(0,I.useRef)(0),n=(0,I.useRef)(0),r=(0,I.useRef)(!1),i=(0,I.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,I.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(wE(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 R$=xj({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))}}}),z$=R$.actions;z$.addErrorBar,z$.replaceErrorBar,z$.removeErrorBar;var Qde=R$.reducer,$de=[`children`];function efe(e,t){if(e==null)return{};var n,r,i=tfe(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 tfe(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,I.createContext)({data:[],xAxisId:`xAxis-0`,yAxisId:`yAxis-0`,dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function B$(e){var t=e.children,n=efe(e,$de);return I.createElement(nfe.Provider,{value:n},t)}function V$(e,t){var n=X(t=>$V(t,e)),r=X(e=>nH(e,t)),i=n?.allowDataOverflow??ZV.allowDataOverflow,a=r?.allowDataOverflow??eH.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function H$(e){var t=e.xAxisId,n=e.yAxisId,r=e.clipPathId,i=xQ(),a=V$(t,n),o=a.needClipX,s=a.needClipY,c=a.needClip,l=X(e=>EU(e,t,!1)),u=X(e=>DU(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 I.createElement(`clipPath`,{id:`clipPath-${r}`},I.createElement(`rect`,{x:h,y:g,width:_,height:v}))}var U$=(e,t,n,r)=>tW(e,`xAxis`,t,r),W$=(e,t,n,r)=>eW(e,`xAxis`,t,r),G$=(e,t,n,r)=>tW(e,`yAxis`,n,r),K$=(e,t,n,r)=>eW(e,`yAxis`,n,r),rfe=Z([BM,U$,G$,W$,K$],(e,t,n,r,i)=>nM(e,`xAxis`)?lM(t,r,!1):lM(n,i,!1)),ife=(e,t,n,r,i)=>i;function afe(e){return e.type===`line`}var ofe=Z([BM,U$,G$,W$,K$,Z([uH,ife],(e,t)=>e.filter(afe).find(e=>e.id===t)),rfe,AP],(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 Dfe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function sfe(e){var t=eE(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 cfe=[`id`],lfe=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],ufe=[`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 J$(e,t){if(e==null)return{};var n,r,i=dfe(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 dfe(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 Y$(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 X$(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Y$(Object(n),!0).forEach(function(t){ffe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y$(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ffe(e,t,n){return(t=pfe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pfe(e){var t=mfe(e,`string`);return typeof t==`symbol`?t:t+``}function mfe(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 hfe(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function gfe(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 Z$={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=gfe(e),r=[];for(var i of e)if(i.status===`matched`)r.push(X$(X$({},i.next),{},{x:PE(i.prev.x,i.next.x,t),y:PE(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(X$(X$({},i.next),{},{x:PE(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(X$(X$({},i.prev),{},{x:PE(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:kX,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:Xde,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:_F.line,type:`linear`},_fe=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:dM(n,t),payload:e}]},vfe=I.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:zE,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:dM(o,t),hide:s,type:u,color:r,unit:c,formatter:l,graphicalItemId:d}};return I.createElement(bX,{tooltipEntrySettings:f})});function yfe(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=$T(J$(r,cfe));return I.createElement(rQ,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:s,needClip:o,clipPathId:t})}function bfe(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,I.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return X$(X$({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return I.createElement(SY,{value:t?i:void 0},n)}function xfe(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=X$(X$({},tE(J$(i,lfe))),{},{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 I.createElement(I.Fragment,null,r?.length>1&&I.createElement(gX,{option:p,DefaultShape:Z$.shape,shapeProps:h}),I.createElement(yfe,{points:r,clipPathId:t,props:i}))}function Sfe(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=hfe(r.current),m=WX(n.onAnimationStart,n.onAnimationEnd),h=m.isAnimating,g=m.handleAnimationStart,_=m.handleAnimationEnd,v=!h,y=Zde(a),b=(0,I.useCallback)(e=>e>0&&p>0,[p]);return I.createElement(bfe,{points:a,showLabels:v},n.children,I.createElement(GX,{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 I.createElement(xfe,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),I.createElement(OY,{label:n.label}))}function Cfe(e){var t=e.clipPathId,n=e.props,r=(0,I.useRef)(null),i=(0,I.useRef)(null);return I.createElement(Sfe,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var wfe=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:tM(e.payload,t)}),Tfe=class extends I.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=qT(`recharts-line`,i),h=d,g=sfe(n),_=g.r,v=g.strokeWidth,y=aX(n),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${h})`:void 0;return I.createElement(OK,{zIndex:p},I.createElement(fE,{className:m},f&&I.createElement(`defs`,null,I.createElement(H$,{clipPathId:h,xAxisId:a,yAxisId:o}),!y&&I.createElement(`clipPath`,{id:`clipPath-dots-${h}`},I.createElement(`rect`,{x:c-b/2,y:s-b/2,width:l+b,height:u+b}))),I.createElement(B$,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:wfe,errorBarOffset:0},I.createElement(Cfe,{props:this.props,clipPathId:h}))),I.createElement(kQ,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}};function Efe(e){var t=iO(e,Z$),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=J$(t,ufe),_=V$(p,m).needClip,v=xQ(),y=VM(),b=SM(),x=X(e=>ofe(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 I.createElement(Tfe,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 Dfe(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=tM(e,o);if(t===`horizontal`)return{x:aM({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(IE(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=IE(l)?null:n.scale.map(l),d=aM({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 Ofe(e){var t=iO(e,Z$),n=SM();return I.createElement(tZ,{id:t.id,type:`line`},e=>I.createElement(I.Fragment,null,I.createElement(xX,{legendPayload:_fe(t)}),I.createElement(vfe,{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}),I.createElement(dZ,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),I.createElement(Efe,q$({},t,{id:e}))))}var Q$=I.memo(Ofe,QM);Q$.displayName=`Line`;function $$(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function e1(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var kfe=`Invariant failed`;function Afe(e,t){if(!e)throw Error(kfe)}var jfe=[`option`];function Mfe(e,t){if(e==null)return{};var n,r,i=Nfe(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 Nfe(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 t1=qN;function n1(e){var t=e.option,n=Mfe(e,jfe);return I.createElement(gX,{option:t,DefaultShape:t1,shapeProps:n,activeClassName:`recharts-active-bar`,inActiveClassName:`recharts-inactive-bar`})}var Pfe=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)||IE(n);return i?e(n,r):(!i&&Afe(!1,`minPointSize callback function received a value with type of ${typeof n}. Currently only numbers or null/undefined are supported.`),t)}},Ffe=(e,t,n)=>n,r1=Z([uH,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`bar`).find(e=>e.id===t)),Ife=Z([r1],e=>e?.maxBarSize),Lfe=(e,t,n,r)=>r,Rfe=Z([BM,uH,$$,e1,Ffe],(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`)),zfe=(e,t,n)=>{var r=BM(e),i=$$(e,t),a=e1(e,t);if(i!=null&&a!=null)return r===`horizontal`?IH(e,`yAxis`,a,n):IH(e,`xAxis`,i,n)},Bfe=Z([Rfe,uF,(e,t)=>{var n=BM(e),r=$$(e,t),i=e1(e,t);if(r!=null&&i!=null)return n===`horizontal`?YU(e,`xAxis`,r):YU(e,`yAxis`,i)}],LQ),Vfe=(e,t,n)=>{var r=r1(e,t);if(r==null)return 0;var i=$$(e,t),a=e1(e,t);if(i==null||a==null)return 0;var o=BM(e),s=sF(e),c=r.maxBarSize,l=IE(c)?s:c,u,d;return o===`horizontal`?(u=tW(e,`xAxis`,i,n),d=eW(e,`xAxis`,i,n)):(u=tW(e,`yAxis`,a,n),d=eW(e,`yAxis`,a,n)),lM(u,d,!0)??l??0},i1=(e,t,n)=>{var r=BM(e),i=$$(e,t),a=e1(e,t);if(i!=null&&a!=null){var o,s;return r===`horizontal`?(o=tW(e,`xAxis`,i,n),s=eW(e,`xAxis`,i,n)):(o=tW(e,`yAxis`,a,n),s=eW(e,`yAxis`,a,n)),lM(o,s)}},Hfe=Z([bM,xM,(e,t,n)=>{var r=$$(e,t);if(r!=null)return tW(e,`xAxis`,r,n)},(e,t,n)=>{var r=e1(e,t);if(r!=null)return tW(e,`yAxis`,r,n)},(e,t,n)=>{var r=$$(e,t);if(r!=null)return eW(e,`xAxis`,r,n)},(e,t,n)=>{var r=e1(e,t);if(r!=null)return eW(e,`yAxis`,r,n)},Z([Z([Bfe,sF,cF,lF,Vfe,i1,Ife],WQ),r1],KQ),BM,jP,i1,Z([zfe,r1],GQ),r1,Lfe],(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 xpe({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})}}),Ufe=[`index`];function a1(){return a1=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},a1.apply(null,arguments)}function Wfe(e,t){if(e==null)return{};var n,r,i=Gfe(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 Gfe(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=(0,I.createContext)(void 0),Kfe=e=>{var t=(0,I.useContext)(o1);if(t!=null)return t.stackId;if(e!=null)return nce(e)},qfe=(e,t)=>`recharts-bar-stack-clip-path-${e}-${t}`,Jfe=e=>{var t=(0,I.useContext)(o1);if(t!=null){var n=t.stackId;return`url(#${qfe(n,e)})`}},s1=e=>{var t=e.index,n=Wfe(e,Ufe),r=Jfe(t);return I.createElement(fE,a1({className:`recharts-bar-stack-layer`,clipPath:r},n))},Yfe=[`onMouseEnter`,`onMouseLeave`,`onClick`],Xfe=[`value`,`background`,`tooltipPosition`],Zfe=[`id`],Qfe=[`onMouseEnter`,`onClick`,`onMouseLeave`];function c1(e,t){return npe(e)||tpe(e,t)||epe(e,t)||$fe()}function $fe(){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 epe(e,t){if(e){if(typeof e==`string`)return l1(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)?l1(e,t):void 0}}function l1(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 tpe(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 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 d1(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 f1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?d1(Object(n),!0).forEach(function(t){rpe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d1(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rpe(e,t,n){return(t=ipe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ipe(e){var t=ape(e,`string`);return typeof t==`symbol`?t:t+``}function ape(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 p1(e,t){if(e==null)return{};var n,r,i=ope(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 ope(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 spe=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:dM(n,t),payload:e}]},cpe=I.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:zE,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:dM(a,t),hide:o,type:l,color:i,unit:s,formatter:c,graphicalItemId:u}};return I.createElement(bX,{tooltipEntrySettings:d})});function lpe(e){var t=X(wG),n=e.data,r=e.dataKey,i=e.background,a=e.allOtherBarProps,o=a.onMouseEnter,s=a.onMouseLeave,c=a.onClick,l=p1(a,Yfe),u=_X(o,r,a.id),d=vX(s),f=yX(c,r,a.id);if(!i||n==null)return null;var p=eE(i);return I.createElement(OK,{zIndex:qQ(i,_F.barBackground)},n.map((e,n)=>{e.value;var a=e.background;e.tooltipPosition;var o=p1(e,Xfe);if(!a)return null;var s=u(e,e.originalDataIndex),c=d(e,e.originalDataIndex),m=f(e,e.originalDataIndex),h=f1(f1(f1(f1(f1({option:i,isActive:String(e.originalDataIndex)===t},o),{},{fill:`#eee`},a),p),QD(l,e,n)),{},{onMouseEnter:s,onMouseLeave:c,onClick:m,dataKey:r,index:n,className:`recharts-bar-background-rectangle`});return I.createElement(n1,u1({key:`background-bar-${n}`},h))}))}function upe(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 f1(f1({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return I.createElement(SY,{value:t?r:void 0},n)}function dpe(e){var t=e.shape,n=e.activeBar,r=e.baseProps,i=e.entry,a=e.index,o=e.dataKey,s=X(wG),c=X(EG),l=n&&String(i.originalDataIndex)===s&&(c==null||o===c),u=s!=null&&(String(i.originalDataIndex)!==s||c!=null&&o!==c),d=c1((0,I.useState)(!1),2),f=d[0],p=d[1],m=c1((0,I.useState)(!1),2),h=m[0],g=m[1];(0,I.useEffect)(()=>{var e;return l?(p(!0),e=requestAnimationFrame(()=>{g(!0)})):(g(!1),u&&p(!1)),()=>{cancelAnimationFrame(e)}},[l,u]);var _=(0,I.useCallback)(()=>{l||p(!1)},[l]),v=l&&h,y=l||f,b=l?n===!0?t:n:t,x=I.createElement(n1,u1({},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?I.createElement(OK,{zIndex:_F.activeBar},I.createElement(s1,{index:i.originalDataIndex},x)):x}function fpe(e){var t=e.shape,n=e.baseProps,r=e.entry,i=e.index,a=e.dataKey;return I.createElement(n1,u1({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance}))}function ppe(e){var t=e.data,n=e.props,r=e.animationElapsedTime,i=e.isAnimating,a=e.isEntrance,o=$T(n)??{},s=o.id,c=p1(o,Zfe),l=n.shape,u=n.dataKey,d=n.activeBar,f=n.onMouseEnter,p=n.onClick,m=n.onMouseLeave,h=p1(n,Qfe),g=_X(f,u,s),_=vX(m),v=yX(p,u,s);return t?I.createElement(I.Fragment,null,t.map((e,t)=>I.createElement(s1,u1({index:e.originalDataIndex,key:`rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,className:`recharts-bar-rectangle`},QD(h,e,t),{onMouseEnter:g(e,e.originalDataIndex),onMouseLeave:_(e,e.originalDataIndex),onClick:v(e,e.originalDataIndex)}),d?I.createElement(dpe,{shape:l,activeBar:d,baseProps:c,entry:e,index:t,dataKey:u,animationElapsedTime:r,isAnimating:i,isEntrance:a}):I.createElement(fpe,{shape:l,baseProps:c,entry:e,index:t,dataKey:u,animationElapsedTime:r,isAnimating:i,isEntrance:a})))):null}var mpe=(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`?[f1(f1({},e.prev),{},{height:PE(e.prev.height,0,t),y:PE(e.prev.y,e.prev.y+e.prev.height,t)})]:[f1(f1({},e.prev),{},{width:PE(e.prev.width,0,t)})];if(e.status===`matched`)return[f1(f1({},e.next),{},{x:PE(e.prev.x,e.next.x,t),y:PE(e.prev.y,e.next.y,t),width:PE(e.prev.width,e.next.width,t),height:PE(e.prev.height,e.next.height,t)})];var r=e.next;return n===`horizontal`?[f1(f1({},r),{},{height:PE(0,r.height,t),y:PE(r.stackedBarStart,r.y,t)})]:[f1(f1({},r),{},{width:PE(0,r.width,t),x:PE(r.stackedBarStart,r.x,t)})]});function hpe(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=WX(t.onAnimationStart,t.onAnimationEnd),d=u.isAnimating,f=u.handleAnimationStart,p=u.handleAnimationEnd;return I.createElement(upe,{showLabels:!d,rects:r},I.createElement(GX,{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)=>I.createElement(fE,null,I.createElement(ppe,{props:t,data:e,animationElapsedTime:n,isAnimating:d||n<1,isEntrance:r}))),I.createElement(OY,{label:t.label}),t.children)}function gpe(e){var t=(0,I.useRef)(null);return I.createElement(hpe,{previousRectanglesRef:t,props:e})}var m1=0,_pe=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:tM(e,t)}},vpe=class extends I.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=qT(`recharts-bar`,i),d=l;return I.createElement(fE,{className:u,id:l},s&&I.createElement(`defs`,null,I.createElement(H$,{clipPathId:d,xAxisId:a,yAxisId:o})),I.createElement(fE,{className:`recharts-bar-rectangles`,clipPath:s?`url(#clipPath-${d})`:void 0},I.createElement(lpe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),I.createElement(gpe,this.props)))}},ype={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:`ease`,animationInterpolateFn:mpe,animationMatchBy:AX,background:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:m1,shape:t1,xAxisId:0,yAxisId:0,zIndex:_F.bar};function bpe(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=V$(t,n).needClip,f=VM(),p=SM(),m=iX(e.children,Oq),h=X(t=>Hfe(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,I.createElement(B$,{xAxisId:t,yAxisId:n,data:h,dataPointFormatter:_pe,errorBarOffset:g},I.createElement(vpe,u1({},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 xpe(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=rce({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=$se(E,y)}else p=tM(e,r),Array.isArray(p)||(p=[b,p]);var D=Pfe(i,m1)(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=oM({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=DE(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=EE(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=oM({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 ee=EE(C||D)*(Math.abs(D)-Math.abs(C));C+=ee}}return v==null||S==null||C==null||w==null||!a&&(C===0||w===0)?null:f1(f1({},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 Spe(e){var t=iO(e,ype),n=Kfe(t.stackId),r=SM();return I.createElement(tZ,{id:t.id,type:`bar`},e=>I.createElement(I.Fragment,null,I.createElement(xX,{legendPayload:spe(t)}),I.createElement(cpe,{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}),I.createElement(dZ,{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!==t1}),I.createElement(OK,{zIndex:t.zIndex},I.createElement(bpe,u1({},t,{id:e})))))}var h1=I.memo(Spe,QM);h1.displayName=`Bar`;var Cpe=[`domain`,`range`],wpe=[`domain`,`range`];function g1(e,t){if(e==null)return{};var n,r,i=Tpe(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 Tpe(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 _1(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 v1(e,t){if(e===t)return!0;var n=e.domain,r=e.range,i=g1(e,Cpe),a=t.domain,o=t.range,s=g1(t,wpe);return!_1(n,a)||!_1(r,o)?!1:QM(i,s)}var Epe=[`type`],Dpe=[`dangerouslySetInnerHTML`,`ticks`,`scale`],Ope=[`id`,`scale`];function y1(){return y1=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},y1.apply(null,arguments)}function b1(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 x1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?b1(Object(n),!0).forEach(function(t){kpe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b1(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kpe(e,t,n){return(t=Ape(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ape(e){var t=jpe(e,`string`);return typeof t==`symbol`?t:t+``}function jpe(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 S1(e,t){if(e==null)return{};var n,r,i=Mpe(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 Mpe(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 Npe(e){var t=xk(),n=(0,I.useRef)(null),r=HM(),i=e.type,a=S1(e,Epe),o=xF(r,`xAxis`,i),s=(0,I.useMemo)(()=>{if(o!=null)return x1(x1({},a),{},{type:o})},[a,o]);return(0,I.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(dQ(s)):n.current!==s&&t(fQ({prev:n.current,next:s})),n.current=s)},[s,t]),(0,I.useLayoutEffect)(()=>()=>{n.current&&=(t(pQ(n.current)),null)},[t]),null}var Ppe=e=>{var t=e.xAxisId,n=e.className,r=e.height,i=e.label,a=(0,I.useRef)(null),o=(0,I.useRef)(null),s=X(xM),c=SM(),l=xk(),u=`xAxis`,d=X(e=>$U(e,u,t,c)),f=X(e=>VU(e,t)),p=X(e=>KU(e,t)),m=X(e=>QV(e,t));if((0,I.useLayoutEffect)(()=>{if(!(r!==`auto`||!f||aY(i)||(0,I.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedHeight();Math.round(f.height)!==Math.round(n)&&l(vQ({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=S1(e,Dpe);m.id,m.scale;var g=S1(m,Ope);return I.createElement(O$,y1({},h,g,{ref:a,labelRef:o,x:p.x,y:p.y,width:f.width,height:f.height,className:qT(`recharts-${u} ${u}`,n),viewBox:s,ticks:d,axisType:u,axisId:t}))},Fpe={allowDataOverflow:ZV.allowDataOverflow,allowDecimals:ZV.allowDecimals,allowDuplicatedCategory:ZV.allowDuplicatedCategory,angle:ZV.angle,axisLine:D$.axisLine,height:ZV.height,hide:!1,includeHidden:ZV.includeHidden,interval:ZV.interval,label:!1,minTickGap:ZV.minTickGap,mirror:ZV.mirror,orientation:ZV.orientation,padding:ZV.padding,reversed:ZV.reversed,scale:ZV.scale,tick:ZV.tick,tickCount:ZV.tickCount,tickLine:D$.tickLine,tickSize:D$.tickSize,type:ZV.type,niceTicks:ZV.niceTicks,xAxisId:0},C1=I.memo(e=>{var t=iO(e,Fpe);return I.createElement(I.Fragment,null,I.createElement(Npe,{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}),I.createElement(Ppe,t))},v1);C1.displayName=`XAxis`;var Ipe=[`type`],Lpe=[`dangerouslySetInnerHTML`,`ticks`,`scale`],Rpe=[`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){zpe(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 zpe(e,t,n){return(t=Bpe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Bpe(e){var t=Vpe(e,`string`);return typeof t==`symbol`?t:t+``}function Vpe(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=Hpe(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 Hpe(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 Upe(e){var t=xk(),n=(0,I.useRef)(null),r=HM(),i=e.type,a=D1(e,Ipe),o=xF(r,`yAxis`,i),s=(0,I.useMemo)(()=>{if(o!=null)return E1(E1({},a),{},{type:o})},[o,a]);return(0,I.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(mQ(s)):n.current!==s&&t(hQ({prev:n.current,next:s})),n.current=s)},[s,t]),(0,I.useLayoutEffect)(()=>()=>{n.current&&=(t(gQ(n.current)),null)},[t]),null}function Wpe(e){var t=e.yAxisId,n=e.className,r=e.width,i=e.label,a=(0,I.useRef)(null),o=(0,I.useRef)(null),s=X(xM),c=SM(),l=xk(),u=`yAxis`,d=X(e=>JU(e,t)),f=X(e=>qU(e,t)),p=X(e=>$U(e,u,t,c)),m=X(e=>tH(e,t));if((0,I.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||aY(i)||(0,I.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(_Q({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=D1(e,Lpe);m.id,m.scale;var g=D1(m,Rpe);return I.createElement(O$,w1({},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:qT(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u,axisId:t}))}var Gpe={allowDataOverflow:eH.allowDataOverflow,allowDecimals:eH.allowDecimals,allowDuplicatedCategory:eH.allowDuplicatedCategory,angle:eH.angle,axisLine:D$.axisLine,hide:!1,includeHidden:eH.includeHidden,interval:eH.interval,label:!1,minTickGap:eH.minTickGap,mirror:eH.mirror,orientation:eH.orientation,padding:eH.padding,reversed:eH.reversed,scale:eH.scale,tick:eH.tick,tickCount:eH.tickCount,tickLine:D$.tickLine,tickSize:D$.tickSize,type:eH.type,niceTicks:eH.niceTicks,width:eH.width,yAxisId:0},O1=I.memo(e=>{var t=iO(e,Gpe);return I.createElement(I.Fragment,null,I.createElement(Upe,{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}),I.createElement(Wpe,t))},v1);O1.displayName=`YAxis`;var k1=Z([(e,t)=>t,BM,LF,KF,_G,yG,QG,bM],uK);function Kpe(e){return`getBBox`in e.currentTarget&&typeof e.currentTarget.getBBox==`function`}function A1(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(Kpe(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 j1=fj(`mouseClick`),M1=Kj();M1.startListening({actionCreator:j1,effect:(e,t)=>{var n=e.payload,r=k1(t.getState(),A1(n));r?.activeIndex!=null&&t.dispatch(SW({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var N1=fj(`mouseMove`),P1=Kj(),F1=null,I1=null,L1=null;P1.startListening({actionCreator:N1,effect:(e,t)=>{var n=e.payload,r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a?.includes(`mousemove`);F1!==null&&(cancelAnimationFrame(F1),F1=null),I1!==null&&(typeof i!=`number`||!o)&&(clearTimeout(I1),I1=null),L1=A1(n);var s=()=>{var e=t.getState(),n=oW(e,e.tooltip.settings.shared);if(!L1){F1=null,I1=null;return}if(n===`axis`){var r=k1(e,L1);r?.activeIndex==null?t.dispatch(yW()):t.dispatch(xW({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}F1=null,I1=null};if(!o){s();return}i===`raf`?F1=requestAnimationFrame(s):typeof i==`number`&&I1===null&&(I1=setTimeout(s,i))}});function qpe(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 R1={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},z1=xj({name:`rootProps`,initialState:R1,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??R1.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}}}),Jpe=z1.reducer,Ype=z1.actions.updateOptions,B1=xj({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)}}),Xpe=B1.actions.updatePolarOptions,Zpe=B1.reducer,V1=fj(`keyDown`),H1=fj(`focus`),U1=fj(`blur`),W1=Kj(),G1=null,K1=null,q1=null;W1.startListening({actionCreator:V1,effect:(e,t)=>{q1=e.payload,G1!==null&&(cancelAnimationFrame(G1),G1=null);var n=t.getState().eventSettings,r=n.throttleDelay,i=n.throttledEvents,a=i===`all`||i.includes(`keydown`);K1!==null&&(typeof r!=`number`||!a)&&(clearTimeout(K1),K1=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=LW(n,aG(e),NH(e),mG(e)),a=i==null?-1:Number(i),o=!Number.isFinite(a)||a<0,s=yG(e),c=aG(e),l=oW(e,e.tooltip.settings.shared);if(r===`Enter`){if(o)return;var u=rK(e,l,`hover`,String(n.index));t.dispatch(wW({active:!n.active,activeIndex:n.index,activeCoordinate:u}));return}var d=nW(e)===`left-to-right`?1:-1,f=r===`ArrowRight`?1:-1,p;if(o){var m=NH(e),h=mG(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(LW(_(v),c,m,h)!=null){p=v;break}}else for(var y=c.length-1;y>=0;y--)if(LW(_(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=rK(e,l,`hover`,String(p));t.dispatch(wW({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}finally{G1=null,K1=null}};if(!a){o();return}r===`raf`?G1=requestAnimationFrame(o):typeof r==`number`&&K1===null&&(o(),q1=null,K1=setTimeout(()=>{q1?o():(K1=null,G1=null)},r))}}),W1.startListening({actionCreator:H1,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=rK(n,oW(n,n.tooltip.settings.shared),`hover`,String(i));t.dispatch(wW({active:!0,activeIndex:i,activeCoordinate:a}))}}}}),W1.startListening({actionCreator:U1,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;r.active&&t.dispatch(wW({active:!1,activeIndex:r.index,activeCoordinate:r.coordinate}))}}});function J1(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 Y1=fj(`externalEvent`),X1=Kj(),Z1=new Map,Q1=new Map,$1=new Map;X1.startListening({actionCreator:Y1,effect:(e,t)=>{var n=e.payload,r=n.handler,i=n.reactEvent;if(r!=null){var a=i.type,o=J1(i);$1.set(a,{handler:r,reactEvent:o});var s=Z1.get(a);s!==void 0&&(cancelAnimationFrame(s),Z1.delete(a));var c=t.getState().eventSettings,l=c.throttleDelay,u=c.throttledEvents,d=u===`all`||u?.includes(a),f=Q1.get(a);f!==void 0&&(typeof l!=`number`||!d)&&(clearTimeout(f),Q1.delete(a));var p=()=>{var e=$1.get(a);try{if(!e)return;var n=e.handler,r=e.reactEvent,i=t.getState(),o={activeCoordinate:kG(i),activeDataKey:EG(i),activeIndex:wG(i),activeLabel:TG(i),activeTooltipIndex:wG(i),isTooltipActive:AG(i)};n&&n(o,r)}finally{Z1.delete(a),Q1.delete(a),$1.delete(a)}};if(!d){p();return}if(l===`raf`){var m=requestAnimationFrame(p);Z1.set(a,m)}else if(typeof l==`number`){if(!Q1.has(a)){p();var h=setTimeout(p,l);Q1.set(a,h)}}else p()}}});var Qpe=Z([Z([VW],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)}}}),e0=fj(`touchMove`),t0=Kj(),n0=null,r0=null,i0=null,a0=null;t0.startListening({actionCreator:e0,effect:(e,t)=>{var n=e.payload;if(n.touches!=null&&n.touches.length!==0){a0=J1(n);var r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a.includes(`touchmove`);n0!==null&&(cancelAnimationFrame(n0),n0=null),r0!==null&&(typeof i!=`number`||!o)&&(clearTimeout(r0),r0=null),i0=Array.from(n.touches).map(e=>A1({clientX:e.clientX,clientY:e.clientY,currentTarget:n.currentTarget}));var s=()=>{if(a0!=null){var e=t.getState(),n=oW(e,e.tooltip.settings.shared);if(n===`axis`){var r=i0?.[0];if(r==null){n0=null,r0=null;return}var i=k1(e,r);i?.activeIndex!=null&&t.dispatch(xW({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(n===`item`){var a=a0.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(_M),c=o.getAttribute(`data-recharts-item-id`)??void 0,l=tG(e).find(e=>e.id===c);if(s==null||l==null||c==null)return;var u=l.dataKey,d=Qpe(e,s,c);t.dispatch(_W({activeDataKey:u,activeIndex:s,activeCoordinate:d,activeGraphicalItemId:c}))}n0=null,r0=null}};if(!o){s();return}i===`raf`?n0=requestAnimationFrame(s):typeof i==`number`&&r0===null&&(s(),a0=null,r0=setTimeout(()=>{a0?s():(r0=null,n0=null)},i))}}});var o0={throttleDelay:`raf`,throttledEvents:[`mousemove`,`touchmove`,`pointermove`,`scroll`,`wheel`]},s0=xj({name:`eventSettings`,initialState:o0,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=uj(t.payload.throttledEvents))}}}),$pe=s0.actions.setEventSettings,eme=s0.reducer,tme=$k({brush:ZQ,cartesianAxis:yQ,chartData:$K,errorBars:Qde,eventSettings:eme,graphicalItems:uZ,layout:Jse,legend:Kce,options:KK,polarAxis:zY,polarOptions:Zpe,referenceElements:n$,renderedTicks:ode,rootProps:Jpe,tooltip:TW,zIndex:DK}),nme=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return bse({reducer:tme,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([M1.middleware,P1.middleware,W1.middleware,X1.middleware,t0.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(yj({type:`raf`}))},devTools:oN.devToolsEnabled&&{serialize:{replacer:qpe},name:`recharts-${t}`}})};function c0(e){var t=e.preloadedState,n=e.children,r=e.reduxStoreName,i=SM(),a=(0,I.useRef)(null);if(i)return n;a.current??=nme(t,r);var o=yk;return I.createElement(ole,{context:o,store:a.current},n)}function rme(e){var t=e.layout,n=e.margin,r=xk(),i=SM();return(0,I.useEffect)(()=>{i||(r(Gse(t)),r(Wse(n)))},[r,i,t,n]),null}var l0=(0,I.memo)(rme,QM);function u0(e){var t=xk();return(0,I.useEffect)(()=>{t(Ype(e))},[t,e]),null}var d0=(0,I.memo)(e=>{var t=xk();return(0,I.useEffect)(()=>{t($pe(e))},[t,e]),null},QM);function f0(e){var t=e.zIndex,n=e.isPanorama,r=(0,I.useRef)(null),i=xk();return(0,I.useLayoutEffect)(()=>(r.current&&i(TK({zIndex:t,element:r.current,isPanorama:n})),()=>{i(EK({zIndex:t,isPanorama:n}))}),[i,t,n]),I.createElement(`g`,{tabIndex:-1,ref:r,className:`recharts-zIndex-layer_${t}`})}function p0(e){var t=e.children,n=e.isPanorama,r=X(fK);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return I.createElement(I.Fragment,null,i.map(e=>I.createElement(f0,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>I.createElement(f0,{key:e,zIndex:e,isPanorama:n})))}var ime=[`children`];function ame(e,t){if(e==null)return{};var n,r,i=ome(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 ome(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 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)}var sme={width:`100%`,height:`100%`,display:`block`},cme=(0,I.forwardRef)((e,t)=>{var n=RM(),r=zM(),i=fN();if(!Qj(n)||!Qj(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),I.createElement(sE,m0({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:sme,ref:t}),a)}),lme=e=>{var t=e.children,n=X(wM);if(!n)return null;var r=n.width,i=n.height,a=n.y,o=n.x;return I.createElement(sE,{width:r,height:i,x:o,y:a},t)},h0=(0,I.forwardRef)((e,t)=>{var n=e.children,r=ame(e,ime);return SM()?I.createElement(lme,null,I.createElement(p0,{isPanorama:!0},n)):I.createElement(cme,m0({ref:t},r),I.createElement(p0,{isPanorama:!1},n))});function ume(e,t){return mme(e)||pme(e,t)||fme(e,t)||dme()}function dme(){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 fme(e,t){if(e){if(typeof e==`string`)return g0(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)?g0(e,t):void 0}}function g0(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 pme(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 mme(e){if(Array.isArray(e))return e}function hme(){var e=xk(),t=ume((0,I.useState)(null),2),n=t[0],r=t[1],i=X(lce);return(0,I.useEffect)(()=>{if(n!=null){var t=n.getBoundingClientRect().width/n.offsetWidth;Zj(t)&&t!==i&&e(qse(t))}},[n,e,i]),r}function _0(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 gme(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?_0(Object(n),!0).forEach(function(t){_me(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _me(e,t,n){return(t=vme(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vme(e){var t=yme(e,`string`);return typeof t==`symbol`?t:t+``}function yme(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 v0(){return v0=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},v0.apply(null,arguments)}function y0(e,t){return Cme(e)||Sme(e,t)||xme(e,t)||bme()}function bme(){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 xme(e,t){if(e){if(typeof e==`string`)return b0(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)?b0(e,t):void 0}}function b0(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 Sme(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 Cme(e){if(Array.isArray(e))return e}var wme=()=>(uq(),null);function x0(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var Tme=(0,I.forwardRef)((e,t)=>{var n=(0,I.useRef)(null),r=y0((0,I.useState)({containerWidth:x0(e.style?.width),containerHeight:x0(e.style?.height)}),2),i=r[0],a=r[1],o=(0,I.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,I.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,I.useEffect)(()=>()=>{n.current?.disconnect()},[o]),I.createElement(I.Fragment,null,I.createElement(WM,{width:i.containerWidth,height:i.containerHeight}),I.createElement(`div`,v0({ref:s},e)))}),Eme=(0,I.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=y0((0,I.useState)({containerWidth:x0(n),containerHeight:x0(r)}),2),a=i[0],o=i[1],s=(0,I.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,I.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 I.createElement(I.Fragment,null,I.createElement(WM,{width:a.containerWidth,height:a.containerHeight}),I.createElement(`div`,v0({ref:c},e)))}),Dme=(0,I.forwardRef)((e,t)=>{var n=e.width,r=e.height;return I.createElement(I.Fragment,null,I.createElement(WM,{width:n,height:r}),I.createElement(`div`,v0({ref:t},e)))}),Ome=(0,I.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?I.createElement(Eme,v0({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?I.createElement(Dme,v0({},e,{width:n,height:r,ref:t})):I.createElement(I.Fragment,null,I.createElement(WM,{width:n,height:r}),I.createElement(`div`,v0({ref:t},e)))});function kme(e){return e?Tme:Ome}var Ame=(0,I.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,I.useRef)(null),S=xk(),C=y0((0,I.useState)(null),2),w=C[0],T=C[1],E=y0((0,I.useState)(null),2),D=E[0],O=E[1],k=hme(),A=PM(),j=A?.width>0?A.width:_,M=A?.height>0?A.height:i,N=(0,I.useCallback)(e=>{k(e),typeof t==`function`&&t(e),T(e),O(e),e!=null&&(x.current=e)},[k,t,T,O]),ee=(0,I.useCallback)(e=>{S(j1(e)),S(Y1({handler:a,reactEvent:e}))},[S,a]),te=(0,I.useCallback)(e=>{S(N1(e)),S(Y1({handler:l,reactEvent:e}))},[S,l]),ne=(0,I.useCallback)(e=>{S(yW()),S(Y1({handler:u,reactEvent:e}))},[S,u]),re=(0,I.useCallback)(e=>{S(N1(e)),S(Y1({handler:d,reactEvent:e}))},[S,d]),ie=(0,I.useCallback)(()=>{S(H1())},[S]),ae=(0,I.useCallback)(()=>{S(U1())},[S]),oe=(0,I.useCallback)(e=>{S(V1(e.key))},[S]),se=(0,I.useCallback)(e=>{S(Y1({handler:o,reactEvent:e}))},[S,o]),ce=(0,I.useCallback)(e=>{S(Y1({handler:s,reactEvent:e}))},[S,s]),le=(0,I.useCallback)(e=>{S(Y1({handler:c,reactEvent:e}))},[S,c]),ue=(0,I.useCallback)(e=>{S(Y1({handler:f,reactEvent:e}))},[S,f]),de=(0,I.useCallback)(e=>{S(Y1({handler:h,reactEvent:e}))},[S,h]),P=(0,I.useCallback)(e=>{b&&S(e0(e)),S(Y1({handler:m,reactEvent:e}))},[S,b,m]),fe=(0,I.useCallback)(e=>{S(Y1({handler:p,reactEvent:e}))},[S,p]),pe=kme(v);return I.createElement(RK.Provider,{value:w},I.createElement(YE.Provider,{value:D},I.createElement(pe,{width:j??g?.width,height:M??g?.height,className:qT(`recharts-wrapper`,r),style:gme({position:`relative`,cursor:`default`,width:j,height:M},g),onClick:ee,onContextMenu:se,onDoubleClick:ce,onFocus:ie,onBlur:ae,onKeyDown:oe,onMouseDown:le,onMouseEnter:te,onMouseLeave:ne,onMouseMove:re,onMouseUp:ue,onTouchEnd:fe,onTouchMove:P,onTouchStart:de,ref:N},I.createElement(wme,null),n)))}),jme=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function Mme(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}var S0=(0,I.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=$T(Mme(e,jme));return c?I.createElement(I.Fragment,null,I.createElement(WM,{width:n,height:r}),I.createElement(h0,{otherAttributes:d,title:l,desc:u},a)):I.createElement(Ame,{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},I.createElement(h0,{otherAttributes:d,title:l,desc:u,ref:t},I.createElement(u$,null,a)))});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){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 Pme(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?w0(Object(n),!0).forEach(function(t){Fme(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Fme(e,t,n){return(t=Ime(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ime(e){var t=Lme(e,`string`);return typeof t==`symbol`?t:t+``}function Lme(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 Rme=Pme({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`},o0),T0=(0,I.forwardRef)(function(e,t){var n=iO(e.categoricalChartProps,Rme),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 I.createElement(c0,{preloadedState:{options:c},reduxStoreName:s.id??r},I.createElement(JQ,{chartData:s.data}),I.createElement(l0,{layout:n.layout,margin:n.margin}),I.createElement(d0,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),I.createElement(u0,{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}),I.createElement(S0,C0({},n,{ref:t})))}),zme=[`axis`],Bme=(0,I.forwardRef)((e,t)=>I.createElement(T0,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:zme,tooltipPayloadSearcher:WK,categoricalChartProps:e,ref:t})),Vme=[`axis`,`item`],E0=(0,I.forwardRef)((e,t)=>I.createElement(T0,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Vme,tooltipPayloadSearcher:WK,categoricalChartProps:e,ref:t}));function Hme(e){var t=xk();return(0,I.useEffect)(()=>{t(Xpe(e))},[t,e]),null}var Ume=[`layout`];function D0(){return D0=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},D0.apply(null,arguments)}function Wme(e,t){if(e==null)return{};var n,r,i=Gme(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 Gme(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 O0(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 Kme(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?O0(Object(n),!0).forEach(function(t){qme(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qme(e,t,n){return(t=Jme(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jme(e){var t=Yme(e,`string`);return typeof t==`symbol`?t:t+``}function Yme(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 k0=Kme({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%`},o0),Xme=(0,I.forwardRef)(function(e,t){var n=iO(e.categoricalChartProps,k0),r=n.layout,i=Wme(n,Ume),a=e.chartName,o={chartName:a,defaultTooltipEventType:e.defaultTooltipEventType,validateTooltipEventTypes:e.validateTooltipEventTypes,tooltipPayloadSearcher:e.tooltipPayloadSearcher,eventEmitter:void 0};return I.createElement(c0,{preloadedState:{options:o},reduxStoreName:n.id??a},I.createElement(JQ,{chartData:n.data}),I.createElement(l0,{layout:r,margin:n.margin}),I.createElement(d0,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),I.createElement(u0,{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}),I.createElement(Hme,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),I.createElement(S0,D0({},i,{ref:t})))});function A0(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 j0(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?A0(Object(n),!0).forEach(function(t){Zme(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Zme(e,t,n){return(t=Qme(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qme(e){var t=$me(e,`string`);return typeof t==`symbol`?t:t+``}function $me(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 ehe=[`item`],the=j0(j0({},k0),{},{layout:`centric`,startAngle:0,endAngle:360}),nhe=(0,I.forwardRef)((e,t)=>{var n=iO(e,the);return I.createElement(Xme,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:ehe,tooltipPayloadSearcher:WK,categoricalChartProps:n,ref:t})}),M0=`flex items-center gap-2 rounded-md px-1 py-0.5`,N0=({resource:e,view:t,filter:n,color:r,label:i,children:a})=>{let o=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`size-2.5 shrink-0 rounded-full`,style:{background:r},"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate group-hover:text-primary-text`,children:i}),a]});return(0,R.jsx)(`li`,{children:n===void 0?(0,R.jsx)(`div`,{className:M0,children:o}):(0,R.jsx)(_S,{to:WT(t,e,n),className:`group ${M0} hover:bg-muted`,children:o})})},rhe=(e,t)=>t>0?`${Math.round(e/t*100)}%`:``,ihe=({active:e,payload:t,measure:n})=>{let r=t?.[0]?.payload;return!e||!r?null:(0,R.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,R.jsx)(`div`,{className:`text-muted-foreground`,children:r.label}),(0,R.jsx)(`div`,{className:`font-semibold tabular-nums`,children:UT(r.value,n)})]})},ahe=({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,R.jsxs)(`div`,{className:`flex flex-col items-center gap-4 sm:flex-row sm:items-center`,children:[(0,R.jsx)(`div`,{className:`size-36 shrink-0`,children:(0,R.jsx)(FM,{width:`100%`,height:`100%`,children:(0,R.jsxs)(nhe,{children:[(0,R.jsx)(GZ,{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,R.jsx)(Oq,{fill:e.color},e.key))}),(0,R.jsx)(Dq,{content:(0,R.jsx)(ihe,{measure:r}),isAnimationActive:!1})]})})}),(0,R.jsx)(`ul`,{className:`flex w-full min-w-0 flex-col gap-0.5`,children:n.map(n=>(0,R.jsxs)(N0,{resource:e,view:t,filter:n.filter,color:n.color,label:n.label,children:[(0,R.jsx)(`span`,{className:`font-medium tabular-nums`,children:UT(n.value,r)}),(0,R.jsx)(`span`,{className:`w-9 text-right text-xs text-muted-foreground tabular-nums`,children:rhe(n.value??0,a)})]},n.key))})]})},P0={hour:`2-digit`,minute:`2-digit`,hour12:!1},F0={day:`numeric`,month:`short`,...P0},ohe={minute:P0,"5_minutes":P0,"15_minutes":P0,hour:P0,day:{day:`numeric`,month:`short`},week:{day:`numeric`,month:`short`},month:{month:`short`,year:`2-digit`},year:{year:`numeric`}},I0={minute:F0,"5_minutes":F0,"15_minutes":F0,hour:F0,day:{day:`numeric`,month:`short`,year:`numeric`},week:{day:`numeric`,month:`short`,year:`numeric`},month:{month:`long`,year:`numeric`},year:{year:`numeric`}},L0=e=>{let t=new Intl.DateTimeFormat(l(),{...e,timeZone:`UTC`});return e=>t.format(e)},R0={fontSize:11,fill:`var(--muted-foreground)`},she=864e5,che=new Set([`minute`,`5_minutes`,`15_minutes`,`hour`]),lhe=(e,t)=>{let n=t.length>1?t.at(-1).at-t[0].at:0;return che.has(e)&&n>=she?F0:ohe[e]},uhe=({active:e,payload:t,measure:n,bucket:r,series:i})=>{let a=t?.[0]?.payload;return!e||!a?null:(0,R.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,R.jsx)(`div`,{className:`text-muted-foreground`,children:r===`week`?PT(`weekOf`,L0(I0[r])(a.at)):L0(I0[r])(a.at)}),i?.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{background:e.color},"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`flex-1`,children:e.label}),(0,R.jsx)(`span`,{className:`font-semibold tabular-nums`,children:UT(a[e.key]??null,e.measure??n)})]},e.key)),i&&(n.kind===`count`||n.kind===`sum`)&&(0,R.jsx)(`div`,{className:`mt-0.5 border-t pt-0.5 font-semibold tabular-nums`,children:UT(a.value,n)}),!i&&(0,R.jsx)(`div`,{className:`font-semibold tabular-nums`,children:UT(a.value,n)})]})},z0=({points:e,measure:t,bucket:n,type:r,series:i,resource:a,view:o})=>{let s=Tu(`(min-width: 640px)`),c=L0(lhe(n,e)),u=(0,R.jsx)(F$,{vertical:!1,stroke:`var(--border)`}),d=(0,R.jsx)(C1,{dataKey:`at`,tickFormatter:c,tick:R0,axisLine:!1,tickLine:!1,minTickGap:s?24:40,height:18}),f=(0,R.jsx)(O1,{width:s?48:36,tick:R0,axisLine:!1,tickLine:!1,tickCount:3,tickFormatter:e=>e.toLocaleString(l(),{notation:`compact`})}),p=(0,R.jsx)(Dq,{cursor:r===`bar`?{fill:`var(--muted)`}:{stroke:`var(--border-strong)`},content:(0,R.jsx)(uhe,{measure:t,bucket:n,...i&&{series:i}}),isAnimationActive:!1}),m=i??[{key:`value`,label:``,color:`var(--chart-1)`}],h=(0,R.jsx)(`div`,{className:`h-40`,children:(0,R.jsx)(FM,{width:`100%`,height:`100%`,children:r===`line`?(0,R.jsxs)(Bme,{data:e,margin:{top:6,right:6,bottom:0,left:0},children:[u,d,f,p,m.map(t=>(0,R.jsx)(Q$,{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,R.jsxs)(E0,{data:e,margin:{top:6,right:0,bottom:0,left:0},barCategoryGap:`22%`,children:[u,d,f,p,m.map((e,t)=>(0,R.jsx)(h1,{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,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h,(0,R.jsx)(`ul`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-sm`,children:i.map(e=>(0,R.jsx)(N0,{resource:a,view:o,color:e.color,label:e.label,...e.filter!==void 0&&{filter:e.filter}},e.key))})]})},dhe=1e-6,fhe=(e,t,n,r,i,a=``)=>{let o=t.map((e,t)=>({key:`s${t}`,label:RT(n,r,e),color:LT(n,r,e.value,t),filter:zT(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=HT(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<dhe?0:l}});return i.kind!==`average`&&l.some(e=>(e.other??0)>0)?{series:[...o,{key:`other`,label:PT(`other`),color:`var(--border-strong)`}],points:l}:{series:o,points:l.map(({other:e,...t})=>t)}},phe=(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]}},B0=(e,t,n)=>{let r=e?.type===`relation`&&e.relation?t[e.relation.resource]:void 0;return r&&r.primaryKey.length===1?cx(r,n[r.name]):void 0},V0=({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=PT(`nothingYet`)})=>{let{resources:f,views:p}=J(),m=e.fields[n],h=m?.type===`date`||m?.type===`timestamp`,g=B0(m,f,p),_=h&&r!==void 0?e.fields[r]:void 0,v=B0(_,f,p),y=_?{splitBy:_.name,splitLimit:8,...v&&{splitLabel:v}}:{},b=h?{granularity:c,range:l,timeZone:Ef(),...y}:{limit:u,...g&&{label:g}},x=MT(e.name,{groupBy:n,filter:s,...a&&{sum:a},...o&&{average:o},...b},!!m),S=phe(e,t,a,o);if(!m)return null;if(x.isPending)return(0,R.jsx)(Uu,{className:`h-36 w-full`});if(x.error)return(0,R.jsx)(`p`,{className:`text-danger-text`,children:PT(`couldNotLoad`)});let{groups:C}=x.data;if(C.every(e=>e.count===0))return(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:d});let w=i===`line`?`line`:`bar`;if(h&&_&&x.data.splits){let{series:n,points:r}=fhe(C,x.data.splits,_,t?.fields[_.name],S,s);return(0,R.jsx)(z0,{points:r,measure:S,bucket:c,type:w,series:n,resource:e.name,view:t})}if(h)return(0,R.jsx)(z0,{points:HT(C,S),measure:S,bucket:c,type:w});let T=VT(C,m,t?.fields[n],S,s);return i===`donut`?(0,R.jsx)(ahe,{resource:e.name,view:t,slices:T,measure:S}):(0,R.jsx)(GT,{resource:e.name,view:t,slices:T,measure:S})},mhe=({node:e,slots:t})=>{let{resource:n,title:r,description:i,actions:a,span:o,...s}=xT(e),{resources:c,views:l}=J(),u=c[n];return u?(0,R.jsx)(wT,{title:r,description:i,actions:t.actions,className:`h-full`,children:(0,R.jsx)(V0,{model:u,view:l[n],...s})}):null},hhe=Un(),H0=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=cx(n,i),c=await e.fetchQuery({queryKey:H.labels(n.name,o.join(`,`)),staleTime:3e5,queryFn:async()=>(await t.list(n.name,{filter:Fn(hhe.in(a,o)),fields:[a,s],pageSize:o.length})).items.map(e=>[String(e[a]),String(e[s])])});return new Map(c)},U0=(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}]:[]}),W0=(e,t,n,r)=>Object.fromEntries(U0(e,n,r).filter(({target:e})=>e.primaryKey.length===1).map(({name:e,target:n})=>[e,cx(n,t[n.name])])),G0=(e,t,n,r,i={})=>{let a=U0(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})},K0=(e,t)=>{let n=String(t);return e&&Object.hasOwn(e,n)?e[n]:void 0},q0=({value:e,hints:t,children:n})=>(0,R.jsx)(dd,{tone:yx(String(e)),color:K0(t?.valueColors,e),shape:t?.badgeShape,children:n}),ghe=({field:e,value:t,known:n})=>{let{resources:r,views:i}=J(),a=U(),o=Om(),s=e.relation?r[e.relation.resource]:void 0,c=String(t),l=Ah({queryKey:H.relatedLabel(s?.name??``,c),enabled:!!s&&n===void 0,queryFn:async()=>(await H0(o,a,s,[c],i[s.name])).get(c)??c});return s?(0,R.jsx)(_S,{to:{kind:`record`,resource:s.name,key:c},className:`font-medium text-primary-text hover:underline`,children:n??l.data??c}):(0,R.jsx)(`span`,{children:c})},_he=({model:e,field:t,value:n,format:r,relationLabel:i})=>{let{views:a}=J(),o={...a[e.name]?.fields[t.name],...r&&{format:r}};if(n==null||n===``)return(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});if(t.type===`relation`)return(0,R.jsx)(ghe,{field:t,value:n,known:i});let s=t.type===`file`?wb(n):void 0;if(s&&`url`in s&&s.url){let e=Mb(n,{width:40,height:40});return(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[e&&(0,R.jsx)(QS,{image:e,className:`size-10 shrink-0 rounded border border-border object-cover`}),(0,R.jsx)(`a`,{href:s.url,target:`_blank`,rel:`noreferrer`,className:`truncate font-medium text-primary-text hover:underline`,children:s.name})]})}if(ox(t,o))return(0,R.jsx)(aC,{source:String(n)});let c=Ox(t,n,o),l=t.type===`text`?hx(o):void 0;return l?(0,R.jsx)(sC,{format:l,value:c}):t.type===`enum`||o.format===`badge`?(0,R.jsx)(q0,{value:n,hints:o,children:c}):(0,R.jsx)(`span`,{title:kx(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})},J0=e=>{let{views:t}=J(),n=rC(e.field,t[e.model.name]?.fields[e.field.name]),r=(0,R.jsx)(_he,{...e});return n?(0,R.jsx)(iC,{shown:n,part:`display`,field:e.field,value:e.value,fallback:r}):r},Y0=(e,t,n)=>{if(!t)return[];let r=xc(e,t.model.name,n);return r.ok?r.steps:[]},X0=(e,t,n,r,i)=>({queryKey:H.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:H.record(a,String(i)),queryFn:()=>e.get(a,String(i))})).record}return r[i.at(-1).field.name]??null}}),Z0=(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}},Q0=(e,t)=>{let{resources:n}=J(),r=Y0(n,e,t);return Z0(e,r,Ah(X0(U(),Om(),e,t,r)))},vhe=(e,t)=>{let{resources:n}=J(),r=U(),i=Om(),a=t.map(t=>Y0(n,e,t)),o=Oh({queries:t.map((t,n)=>X0(r,i,e,t,a[n]))});return t.map((t,n)=>Z0(e,a[n],o[n]))},$0=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>K(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},yhe=({node:e})=>{let{name:t,label:n,format:r}=xT(e),{views:i}=J(),a=Q0($w(),t);if(a.state===`missing`)return null;let o=a.state===`loading`?(0,R.jsx)(Uu,{className:`h-4 w-24`}):(0,R.jsx)(J0,{model:a.model,field:a.field,value:a.value,format:r});if(n===!1)return(0,R.jsx)(`div`,{children:o});let s=n??$0(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-body text-muted-foreground`,children:s}),(0,R.jsx)(`div`,{className:`mt-0.5 truncate`,children:o})]})},bhe={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},xhe={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},She={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`},Che=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,whe=({node:e,children:t})=>{let{columns:n=2}=xT(e),r=e.children,i=r.length>0&&r.every(Che);return(0,R.jsx)(`div`,{className:g(`grid grid-cols-1 gap-4`,i?xhe[n]:bhe[n]),children:t.map((e,t)=>{let n=r[t],i=typeof n==`object`?n.props.span:void 0;return(0,R.jsx)(`div`,{className:g(`min-w-0`,i&&She[i]),children:e},t)})})},e2=`font-medium text-primary-text hover:underline`,The=({node:e})=>{let t=xT(e),n=$w()?.record,r=e.children.filter(e=>typeof e==`string`).join(``);if(t.to){let e=Jn(t.to,n);return(0,R.jsx)(_S,{to:e,className:e2,children:r||ws(e)})}let i=t.href??``;return(0,R.jsx)(`a`,{href:i,className:e2,...i.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:r||i})},Ehe=(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]:TS(n.record[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:TS(i)]})),Dhe=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return IS(r)?r.key===TS(n.record[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:jS(i,r,n.record[t])?[[t,OS(i,r)]]:[]})),Ohe=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=J(),u=U(),d=ub(),f=_T(),p=l[e.name],[m,h]=(0,I.useState)(()=>Ehe(e,a,t)),[g,_]=(0,I.useState)({}),[v,y]=(0,I.useState)(0),b=pC(v),[x,S]=(0,I.useState)(),[C,w]=(0,I.useState)(!1),T=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...RS(e,c,m),...o}):u.update(e.name,t.key,Dhe(e,m,t),t.etag??`*`)).then(async()=>{await f(e.name),d.show({state:`success`,title:_g(`saved`,i??r)}),s()},e=>{let t=fC(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,R.jsx)(sp,{title:i??r,onClose:s,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:s,children:_g(`cancel`)}),(0,R.jsx)(V,{variant:`primary`,loading:C,onClick:()=>void T(),children:_g(n===`create`?`create`:`save`)})]}),children:(0,R.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,R.jsx)(US,{title:_g(`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??K(n),s=g[n];return(0,R.jsx)(pb,{name:n,label:o,help:p?.fields[n]?.help,error:s&&dC(r,o,s),children:(0,R.jsx)(cC,{field:r,hints:p?.fields[n],value:IS(i)?i.key:i,stored:t?.record[n],relationLabel:IS(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)})]})})},khe=({model:e,recordKey:t,children:n})=>{let r=hT(e,{key:t});return(0,R.jsx)(R.Fragment,{children:n(r.data??void 0)})},Ahe=({node:e})=>{let t=xT(e),n=$w(),{resources:r}=J(),i=r[t.resource??n?.model.name??``],a=hS(i?.name??``),[o,s]=(0,I.useState)(!1);if(!i||!(t.mode===`create`?eT(a,`create`):eT(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,R.jsx)(Ohe,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,R.jsx)(khe,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},jhe=({node:e,children:t,slots:n})=>{let{title:r,description:i}=xT(e);return(0,R.jsx)(`div`,{className:`flex-1`,children:(0,R.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,R.jsx)(Jd,{title:r,subtitle:i,actions:n.actions}),t]})})},t2=(e,t)=>{let n=$w(),r=Q0(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},Mhe=({node:e})=>{let{value:t,max:n,label:r}=xT(e),i=t2(t,0),a=t2(n,100);if(i===void 0||a===void 0)return(0,R.jsx)(Uu,{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,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:r}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[i.toLocaleString(l()),` / `,a.toLocaleString(l())]})]}),(0,R.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,R.jsx)(`div`,{className:o>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${o*100}%`}})})]})},Nhe=({model:e,filter:t,sort:n,recordKey:r,title:i,description:a,empty:o,actions:s,children:c})=>{let l=hT(e,{filter:t,sort:n,key:r}),u=e=>l.data?(0,R.jsx)(Qw,{value:l.data,children:e}):void 0,d=l.isPending?(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(Uu,{className:`h-4 w-1/2`}),(0,R.jsx)(Uu,{className:`h-4 w-1/3`})]}):l.error?(0,R.jsx)(US,{title:_g(`couldNotLoad`),error:l.error}):l.data?u((0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:c})):(0,R.jsx)(TT,{children:o??_g(`nothingYet`)});return(0,R.jsx)(wT,{title:i,description:a,actions:s?u(s):void 0,className:`h-full`,children:d})},Phe=({node:e,children:t,slots:n})=>{let{resource:r,filter:i,sort:a,recordKey:o,title:s,description:c,empty:l}=xT(e),u=J().resources[r];return u?(0,R.jsx)(Nhe,{model:u,filter:i,sort:a,recordKey:o,title:s,description:c,empty:l,actions:n.actions,children:t}):null};function Fhe(e){return Ihe(e)||typeof e==`function`||Lhe(e)}function Ihe(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Lhe(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function n2(e,t){return e==null?null:Fhe(e)?I.createElement(e,t):e}function Rhe(e){if(`cell`in e&&e.cell){let t=e.cell,n=t.column.columnDef,r=t,i=n;return r.getIsAggregated?.()?n2(i.aggregatedCell??n.cell,t.getContext()):r.getIsPlaceholder?.()?null:n2(n.cell,t.getContext())}return`header`in e&&e.header?n2(e.header.column.columnDef.header,e.header.getContext()):`footer`in e&&e.footer?n2(e.footer.column.columnDef.footer,e.footer.getContext()):null}function zhe({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 Bhe(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 r2=[],i2=0,{link:a2,unlink:Vhe,propagate:Hhe,checkDirty:o2,shallowPropagate:s2}=zhe({update(e){return e._update()},notify(e){r2[l2++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,f2(e))}}),c2=0,l2=0,u2,d2=0;function Uhe(e){try{++d2,e()}finally{--d2||p2()}}function f2(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Vhe(n,e)}function p2(){if(!(d2>0)){for(;c2<l2;){let e=r2[c2];r2[c2++]=void 0,e.notify()}c2=0,l2=0}}function Whe(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 u2!==void 0&&a2(i,u2,i2),i._snapshot},subscribe(e){let t=Bhe(e),n={current:!1},r=Ghe(()=>{i.get(),n.current?(u2=void 0,t.next?.(i._snapshot)):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=u2,o=t?.compare??Object.is;if(n)u2=i,++i2,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{u2=a,n&&(i.flags&=-5),f2(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&o2(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&s2(e)}}else e&32&&(i.flags=e&-33);return u2!==void 0&&a2(i,u2,i2),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Hhe(e),s2(e),p2())}},i}function Ghe(e){let t=()=>{let t=u2;u2=n,++i2,n.depsTail=void 0,n.flags=6;try{return e()}finally{u2=t,n.flags&=-5,f2(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&&o2(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,f2(this)}};return t(),n}function m2(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=h2(e);if(n.length!==h2(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 h2(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function Khe(e,t){return e===t}function g2(e,t=e=>e,n){let r=n?.compare??Khe,i=(0,I.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,I.useCallback)(()=>e.get(),[e]);return(0,vk.useSyncExternalStoreWithSelector)(i,a,a,t,r)}function qhe(e){let t=g2(e.source,e.selector,{compare:m2});return typeof e.children==`function`?e.children(t):e.children}function Jhe(e){let t=e;return Object.defineProperty(e,"state",{get(){return e.get()}}),`set`in e&&(t.setState=e.set.bind(e)),t}function Yhe(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 Xhe(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 Zhe(){return Yhe({createAtom:Whe,batch:Uhe})}function _2(e,t){return typeof e==`function`?e(t):e}function v2(e){if(Array.isArray(e))return e.map(v2);if(e&&typeof e==`object`){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=t===null?y2():{},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:v2(e[i]),writable:!0})}return n}return e}function Qhe(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 y2(){return Object.create(null)}function b2(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function x2(e,t){return n=>{(t.options.atoms?.[e]??t.baseAtoms[e]).set(e=>_2(n,e))}}function S2(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 C2(e){return Reflect.ownKeys(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}var $he=3;function ege(e,t){return w2(e,t,$he)}function w2(e,t,n){if(Object.is(e,t))return!0;if(n<=0||!S2(e)||!S2(t)||(Array.isArray(e)||Array.isArray(t))&&(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length))return!1;let r=C2(e),i=C2(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)||!w2(a[i],o[i],n-1))return!1}return!0}function T2(e,t,n,r=ege){let i=`on${t.charAt(0).toUpperCase()}${t.slice(1)}Change`,a=e.options[i];a&&a(e=>{let t=_2(n,e);return r(e,t)?e:t})}function tge(e){return e instanceof Function}function nge(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 rge=({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 ige(e){let t=!1;return()=>{if(!t){t=!0;return}e()}}function E2({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 rge({...a,...s})}function D2(e,t=`_`){let[n,r]=e.split(t);return{fnKey:r,fnName:`${n}.${r}`,parentName:n}}function O2(e,t,n){for(let[r,{fn:i,memoDeps:a}]of Object.entries(n)){let{fnKey:n,fnName:o}=D2(r);t[n]=a?E2({memoDeps:a,fn:i,fnName:o,table:t,feature:e}):i}}function k2(e,t,n,r){for(let[i,{fn:a,memoDeps:o}]of Object.entries(r)){let{fnKey:r,fnName:s}=D2(i);if(o){let i=`_memo_${r}`;t[r]=function(...t){if(!this[i]){let t=this;this[i]=E2({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 A2(e,t,n,...r){return e[t]?.(...r)??n(e,...r)}function age(e){return e.row.getValue(e.column.id)}function oge(e){return e.getValue()??e.table.options.renderFallbackValue}function sge(e){return{table:e.table,column:e.column,row:e.row,cell:e,getValue:()=>e.getValue(),renderValue:()=>e.renderValue()}}var cge={assignCellPrototype:(e,t)=>{k2(`coreCellsFeature`,e,t,{cell_getValue:{fn:e=>age(e)},cell_renderValue:{fn:e=>oge(e)},cell_getContext:{fn:e=>sge(e),memoDeps:e=>[e]}})}};function lge(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 j2(e,t,n){let r=lge(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 uge(){return{start:[],end:[]}}function M2(e){let t=e.table.atoms.columnVisibility?.get();if(!t)return!0;let n=e.columns;return n.length?n.some(e=>A2(e,`getIsVisible`,M2)):(b2(t,e.id)?t[e.id]:void 0)??!0}function dge(e){return e.getAllLeafColumns().filter(e=>A2(e,`getIsVisible`,M2))}function N2(e,t=1){let n=t;for(let r=0;r<e.length;r++){let i=e[r];A2(i,`getIsVisible`,M2)&&i.columns.length&&(n=Math.max(n,N2(i.columns,t+1)))}return n}function fge(e,t){return e?`${e}_${t}`:String(t)}function pge(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 mge(e,t){let n=0;for(let r=0;r<e.length;r++)e[r].column===t&&n++;return n}function P2(e,t,n,r,i,a){let o={depth:t,id:fge(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=j2(n,u,{id:pge(r,t,u.id,a.id),isPlaceholder:d,placeholderId:d?String(mge(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&&P2(s,t-1,n,r,i,a)}function F2(e){for(let t=0;t<e.length;t++){let n=e[t];if(!A2(n.column,`getIsVisible`,M2))continue;let r=0;if(n.subHeaders.length){F2(n.subHeaders);for(let e=0;e<n.subHeaders.length;e++){let t=n.subHeaders[e];A2(t.column,`getIsVisible`,M2)&&(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 I2(e,t,n,r){let i=N2(e),a=[],o=n._headerGroupInstanceInitFns,s=Array(t.length);for(let e=0;e<t.length;e++)e in t&&(s[e]=j2(n,t[e],{depth:i,index:e}));return P2(s,i-1,n,r,a,o),a.reverse(),F2(a[0]?.headers??[]),a}function hge(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 gge(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=hge(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 L2(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 _ge(e,r)}}function _ge(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 vge(e){return[e,...e.columns.flatMap(e=>e.getFlatColumns())]}function yge(e){if(e.columns.length){let t=e.columns.flatMap(e=>e.getLeafColumns());return A2(e.table,`getOrderColumns`,L2)(t)}return[e]}function bge(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 R2(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=gge(e,o,r,n),c=o;s.columns=c.columns?R2(e,c.columns,s,r+1):[],i[a]=s}return i}function xge(e){return R2(e,e.options.columns)}function Sge(e){return e.getAllColumns().flatMap(e=>e.getFlatColumns())}function Cge(e){let t=y2(),n=e.getAllFlatColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function wge(e){let t=e.getAllColumns().flatMap(e=>e.getLeafColumns());return A2(e,`getOrderColumns`,L2)(t)}function Tge(e){let t=y2(),n=e.getAllLeafColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function Ege(e,t){return e.getAllFlatColumnsById()[t]}var Dge={assignColumnPrototype:(e,t)=>{k2(`coreColumnsFeature`,e,t,{column_getFlatColumns:{fn:e=>vge(e),memoDeps:e=>[e.table.options.columns]},column_getLeafColumns:{fn:e=>yge(e),memoDeps:e=>[e.table.atoms.columnOrder?.get(),e.table.atoms.grouping?.get(),e.table.options.columns,e.table.options.groupedColumnMode]}})},constructTableAPIs:e=>{O2(`coreColumnsFeature`,e,{table_getDefaultColumnDef:{fn:()=>bge(e),memoDeps:()=>[e.options.defaultColumn]},table_getAllColumns:{fn:()=>xge(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumns:{fn:()=>Sge(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumnsById:{fn:()=>Cge(e),memoDeps:()=>[e.options.columns]},table_getAllLeafColumns:{fn:()=>wge(e),memoDeps:()=>[e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.columns,e.options.groupedColumnMode]},table_getAllLeafColumnsById:{fn:()=>Tge(e),memoDeps:()=>[e.getAllLeafColumns()]},table_getColumn:{fn:t=>Ege(e,t)}})}};function z2(e,t){for(let n=0;n<e.subHeaders.length;n++)z2(e.subHeaders[n],t);t.push(e)}function Oge(e){let t=[];return z2(e,t),t}function kge(e){return{column:e.column,header:e,table:e.column.table}}function Age(e){let{start:t,end:n}=e.atoms.columnPinning?.get()??uge(),r=e.getAllColumns(),i=A2(e,`getVisibleLeafColumns`,dge);if(!t.length&&!n.length)return I2(r,i,e);let a=e.getAllLeafColumnsById(),o=[];for(let e=0;e<t.length;e++){let n=a[t[e]];n&&A2(n,`getIsVisible`,M2)&&o.push(n)}let s=[];for(let e=0;e<n.length;e++){let t=a[n[e]];t&&A2(t,`getIsVisible`,M2)&&s.push(t)}let c=i.filter(e=>!t.includes(e.id)&&!n.includes(e.id));return I2(r,[...o,...c,...s],e)}function jge(e){return[...e.getHeaderGroups()].reverse()}function Mge(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 Nge(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 Pge={assignHeaderPrototype:(e,t)=>{k2(`coreHeadersFeature`,e,t,{header_getLeafHeaders:{fn:e=>Oge(e),memoDeps:e=>[e.column.table.options.columns]},header_getContext:{fn:e=>kge(e),memoDeps:e=>[e.column.table.options.columns]}})},constructTableAPIs:e=>{O2(`coreHeadersFeature`,e,{table_getHeaderGroups:{fn:()=>Age(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:()=>jge(e),memoDeps:()=>[e.getHeaderGroups()]},table_getFlatHeaders:{fn:()=>Mge(e),memoDeps:()=>[e.getHeaderGroups()]},table_getLeafHeaders:{fn:()=>Nge(e),memoDeps:()=>[e.getHeaderGroups()]}})}};function Fge(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 Ige=(e,t,n,r,i,a,o)=>{let s=Fge(e),c=Object.create(s);c._displayIndexCache=-1,c._uniqueValuesCache=y2(),c._valuesCache=y2(),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},Lge=/([0-9]+)/gm;function B2(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}B2({resolveDataValue:e=>U2(e).toLowerCase(),sort:(e,t)=>W2(e,t)}),B2({resolveDataValue:e=>U2(e),sort:(e,t)=>W2(e,t)}),B2({resolveDataValue:e=>U2(e).toLowerCase(),sort:(e,t)=>H2(e,t)}),B2({resolveDataValue:e=>U2(e),sort:(e,t)=>H2(e,t)}),B2({resolveDataValue:e=>Rge(e),sort:(e,t)=>e>t?1:e<t?-1:0});var V2=B2({sort:(e,t)=>H2(e,t)});function H2(e,t){return e===t?0:e>t?1:-1}function Rge(e){return e instanceof Date?e.getTime():e}function U2(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function W2(e,t){let n=0,r=0,i=e.length,a=t.length;for(;n<i&&r<a;){let i=G2(e.charCodeAt(n)),a=G2(t.charCodeAt(r)),o=K2(e,n,i),s=K2(t,r,a);if(!i&&!a){let i=zge(e,n,o,t,r,s);if(i)return i;n=o,r=s;continue}if(i!==a)return i?1:-1;let c=Bge(e,n,o,t,r,s);if(c)return c;n=o,r=s}return J2(e,n)-J2(t,r)}function G2(e){return e>=48&&e<=57}function K2(e,t,n){let r=t+1;for(;r<e.length&&G2(e.charCodeAt(r))===n;)r++;return r}function zge(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 Bge(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=q2(e,o,n),i=q2(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 q2(e,t,n){let r=0;for(let i=t;i<n;i++)r=r*10+e.charCodeAt(i)-48;return r}function J2(e,t){let n=0,r=t;for(;r<e.length;)n++,r=K2(e,r,G2(e.charCodeAt(r)));return n}function Y2(){return[]}function Vge(e,t){T2(e,`cellSelection`,t?Y2():v2(e.initialState.cellSelection)??Y2())}function Hge(e){e.atoms.cellSelection&&(e.options.autoResetAll??e.options.autoResetCellSelection??!0)&&e._reactivity.schedule(()=>Vge(e))}function Uge(e){e.atoms.expanded&&(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding)&&e._reactivity.schedule(()=>Wge(e))}function Wge(e,t){let n=e.initialState.expanded;T2(e,`expanded`,t?y2():n===!0||Object.assign(y2(),v2(n??{})))}var X2=0;function Gge(e){if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if((e.atoms.pagination?.get()?.pageIndex??X2)===X2)return;Jge(e,!0)}}function Kge(e,t){T2(e,`pagination`,t)}function qge(e,t){Kge(e,n=>{let r=_2(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 Jge(e,t){qge(e,t?X2:e.initialState.pagination?.pageIndex??X2)}function Yge(){return[]}function Z2(e,t){T2(e,`sorting`,t)}function Q2(e,t){Z2(e,t?[]:v2(e.initialState.sorting??[]))}function Xge(e){e.atoms.sorting&&(e.options.autoResetAll??e.options.autoResetSorting??!1)&&Q2(e)}function $2(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(Lge).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 V2}function e4(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 Zge(e){let t=e.table._rowModelFns.sortFns;return tge(e.columnDef.sortFn)?e.columnDef.sortFn:e.columnDef.sortFn===`auto`?$2(e):t?.[e.columnDef.sortFn]??V2}function t4(e,t,n){let r=r4(e,n&&a4(e)),i=t!==void 0;Z2(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&&a4(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 n4(e){return e.columnDef.sortDescFirst??e.table.options.sortDescFirst??e4(e)===`desc`?`desc`:`asc`}function r4(e,t){let n=n4(e),r=o4(e);return r?r!==n&&(e.table.options.enableSortingRemoval??!0)&&(!t||(e.table.options.enableMultiRemove??!0))?!1:r===`desc`?`asc`:`desc`:n}function i4(e){return(e.columnDef.enableSorting??!0)&&(e.table.options.enableSorting??!0)&&!!e.accessorFn}function a4(e){return e.columnDef.enableMultiSort??e.table.options.enableMultiSort??!!e.accessorFn}function o4(e){let t=e.table.atoms.sorting?.get()?.find(t=>t.id===e.id);return t?t.desc?`desc`:`asc`:!1}function Qge(e){return e.table.atoms.sorting?.get()?.findIndex(t=>t.id===e.id)??-1}function $ge(e){Z2(e.table,t=>t.length?t.filter(t=>t.id!==e.id):[])}function e_e(e){let t=i4(e);return n=>{t&&t4(e,void 0,a4(e)?e.table.options.isMultiSortEvent?.(n):!1)}}function t_e(){return e=>E2({feature:`coreRowModelsFeature`,table:e,fnName:`table.getCoreRowModel`,memoDeps:()=>[e.options.data],fn:()=>n_e(e,e.options.data),onAfterUpdate:ige(()=>{Uge(e),Gge(e),Xge(e),Hge(e)})})}function s4(e,t,n,r=0,i){let a=[];for(let o=0;o<n.length;o++){let s=n[o],c=Ige(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=s4(e,t,c.originalSubRows,r+1,c)))}return a}function n_e(e,t){let n={rows:[],flatRows:[],rowsById:y2()};return n.rows=s4(e,n,t),n}function r_e(e){return e._rowModels.coreRowModel||(e._rowModels.coreRowModel=e.options.features.coreRowModel?.(e)??t_e()(e)),e._rowModels.coreRowModel()}function i_e(e){return e.getCoreRowModel()}function a_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 o_e(e){return e.getFilteredRowModel()}function s_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 c_e(e){return e.getGroupedRowModel()}function l_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 u_e(e){return e.getSortedRowModel()}function d_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 f_e(e){return e.getExpandedRowModel()}function p_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 m_e(e){return e.getPaginatedRowModel()}var h_e={constructTableAPIs:e=>{O2(`coreRowModelsFeature`,e,{table_getCoreRowModel:{fn:()=>r_e(e)},table_getPreFilteredRowModel:{fn:()=>i_e(e)},table_getFilteredRowModel:{fn:()=>a_e(e)},table_getPreGroupedRowModel:{fn:()=>o_e(e)},table_getGroupedRowModel:{fn:()=>s_e(e)},table_getPreSortedRowModel:{fn:()=>c_e(e)},table_getSortedRowModel:{fn:()=>l_e(e)},table_getPreExpandedRowModel:{fn:()=>u_e(e)},table_getExpandedRowModel:{fn:()=>d_e(e)},table_getPrePaginatedRowModel:{fn:()=>f_e(e)},table_getPaginatedRowModel:{fn:()=>p_e(e)},table_getRowModel:{fn:()=>m_e(e)}})}};function g_e(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 __e(e,t,n){let r=g_e(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 v_e(e){let t=e.table.getRowsInDisplayOrder(),n=e._displayIndexCache;return t[n]===e?n:-1}function y_e(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 b_e(e,t){if(b2(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 x_e(e,t){if(b2(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 S_e(e,t){return e.getValue(t)??e.table.options.renderFallbackValue}function C_e(e){return nge(e.subRows,e=>e.subRows)}function w_e(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 T_e(e){if(e.parentId)return e.table.getCoreRowModel().rowsById[e.parentId]??e.table.getRow(e.parentId,!0)}function E_e(e){let t=[],n=e;for(;;){let e=n.getParentRow();if(!e)break;t.push(e),n=e}return t.reverse()}function D_e(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=__e(a,e,e.table),n.set(a,o)),r[i]=o}return r}function O_e(e){let t=y2(),n=e.getAllCells();for(let e=0;e<n.length;e++){let r=n[e];t[r.column.id]=r}return t}function k_e(e,t,n,r){return t.options.getRowId?.(e,n,r)??(r?`${r.id}.${n}`:String(n))}function A_e(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 j_e={assignRowPrototype:(e,t)=>{k2(`coreRowsFeature`,e,t,{row_getDisplayIndex:{fn:e=>v_e(e)},row_getAllCellsByColumnId:{fn:e=>O_e(e),memoDeps:e=>[e.getAllCells()]},row_getAllCells:{fn:e=>D_e(e),memoDeps:e=>[e.table.getAllLeafColumns()]},row_getLeafRows:{fn:e=>C_e(e),memoDeps:e=>[e.subRows]},row_getParentRow:{fn:e=>T_e(e)},row_getParentRows:{fn:e=>E_e(e)},row_getUniqueValues:{fn:(e,t)=>x_e(e,t)},row_getValue:{fn:(e,t)=>b_e(e,t)},row_renderValue:{fn:(e,t)=>S_e(e,t)}})},constructTableAPIs:e=>{O2(`coreRowsFeature`,e,{table_getRowsInDisplayOrder:{fn:()=>y_e(e),memoDeps:()=>[e.getPrePaginatedRowModel().rows,e.options.paginateExpandedRows,e.options.paginateExpandedRows===!1?e.atoms.expanded?.get():void 0]},table_getRowId:{fn:(t,n,r)=>k_e(t,e,n,r)},table_getRow:{fn:(t,n)=>A_e(e,t,n)},table_getMaxSubRowDepth:{fn:()=>w_e(e),memoDeps:()=>[e.getCoreRowModel()]}})}};function c4(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 l4(e,t,n=(e,t)=>e===t){e._reactivity.batch(()=>{c4(e,t,n),e._reactivity.commit?.()})}function M_e(e){let t=v2(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 N_e(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 u4(e,t,n){let r=N_e(e,_2(t,e.options));e.optionsStore?e.optionsStore.set(()=>r):e.options=r,n?.syncExternalState!==!1&&l4(e,r.state??null)}var P_e={coreCellsFeature:cge,coreColumnsFeature:Dge,coreHeadersFeature:Pge,coreRowModelsFeature:h_e,coreRowsFeature:j_e,coreTablesFeature:{constructTableAPIs:e=>{O2(`coreTablesFeature`,e,{table_reset:{fn:()=>M_e(e)},table_setOptions:{fn:t=>u4(e,t)}})}}};function F_e(){return{accessor:(e,t)=>typeof e==`function`?{...t,accessorFn:e}:{...t,accessorKey:e},columns:e=>e,display:e=>e,group:e=>e}}function I_e(e){return e}function L_e(e,t={}){return Object.values(e).forEach(e=>{t=e.getInitialState?.(t)??t}),v2(t)}function R_e(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:{...P_e,..._},_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=L_e(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&&b2(i,n)){let e=i[n];return e===void 0?v.initialState[n]:e}return r},{debugName:`table/atoms/${n}`})}c4(v),v.store=Jhe(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:m2,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 z_e(){return y2()}function d4(e,t){e.options.onRowSelectionChange?.(t)}function B_e(e,t){e._lastSelectedRowId=null,d4(e,t?y2():Object.assign(y2(),v2(e.initialState.rowSelection??{})))}function f4(e,t,n){e._lastSelectedRowId=null,d4(e,r=>{if(t=t===void 0?!A2(e,`getIsAllRowsSelected`,h4):t,n?.deselectAll&&!t)return y2();let i=Object.assign(y2(),r),a=e.getPreGroupedRowModel().flatRows;if(t){let e=new Map;a.forEach(t=>{T4(t,e)&&(i[t.id]=!0)})}else a.forEach(e=>{x4(e)&&delete i[e.id]});return i})}function p4(e,t,n){e._lastSelectedRowId=null,d4(e,r=>{let i=t===void 0?!A2(e,`getIsAllPageRowsSelected`,g4):t;if(n?.deselectAll&&!i)return y2();let a=Object.assign(y2(),r);return e.getRowModel().rows.forEach(t=>{w4(a,t.id,i,!0,e,!0)}),a})}function V_e(e){return e.getCoreRowModel()}function H_e(e){let t=e.getCoreRowModel();return A2(e,`getIsSomeRowsSelected`,_4)?O4(t,e):{rows:[],flatRows:[],rowsById:y2()}}function U_e(e){let t=e.getFilteredRowModel();return A2(e,`getIsSomeRowsSelected`,_4)?O4(t,e):{rows:[],flatRows:[],rowsById:y2()}}function W_e(e){let t=e.getSortedRowModel();return A2(e,`getIsSomeRowsSelected`,_4)?O4(t,e):{rows:[],flatRows:[],rowsById:y2()}}function m4(e){return Object.keys(e.atoms.rowSelection?.get()??{})}function h4(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=>!k4(t,n)&&T4(t,e))&&(r=!1)}return r}function g4(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(k4(a,n))!i&&T4(a,r)&&(i=!0);else if(T4(a,r))return!1}return i}function _4(e){return A2(e,`getSelectedRowIds`,m4).length>0}function G_e(e){return e.getPaginatedRowModel().flatRows.filter(e=>x4(e)).some(e=>y4(e)||A2(e,`getIsSomeSelected`,b4))}function K_e(e){return t=>{f4(e,t.target.checked)}}function q_e(e){return t=>{p4(e,t.target.checked)}}function v4(e,t,n){let r=y4(e);d4(e.table,i=>{t=t===void 0?!r:t;let a=Object.assign(y2(),i);return w4(a,e.id,t,(n?.selectChildren??!0)&&C4(e),e.table),!t&&n?.deselectParents&&E4(a,e),a})}function y4(e){return k4(e,e.table.atoms.rowSelection?.get()??{})}function b4(e){return A4(e)===`some`}function J_e(e){return A4(e)===`all`}function x4(e){let t=e.table.options;return typeof t.enableRowSelection==`function`?t.enableRowSelection(e):t.enableRowSelection??!0}function S4(e){let t=e.table.options;return typeof t.enableSubRowSelection==`function`?t.enableSubRowSelection(e):t.enableSubRowSelection??!0}function C4(e){let t=e.table.options;return typeof t.enableMultiRowSelection==`function`?t.enableMultiRowSelection(e):t.enableMultiRowSelection??!0}function Y_e(e,t){let n=x4(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&&C4(e)&&(a.options.isRowRangeSelectionEvent?.(r)??!1))||!X_e(e,s,o,t))&&v4(e,o,t),a._lastSelectedRowId=e.id}}function X_e(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||!C4(s)||!C4(e))return!1;let f=Math.min(c,l),p=Math.max(c,l);return d4(a,e=>{let t=Object.assign(y2(),e);for(let e=f;e<=p;e++){let s=o[e];x4(s)&&C4(s)&&(w4(t,s.id,n,i,a),!n&&r?.deselectParents&&E4(t,s))}return t}),!0}function w4(e,t,n,r,i,a){let o=i.getRow(t,!0);n?(C4(o)||Object.keys(e).forEach(t=>delete e[t]),x4(o)&&(e[t]=!0)):(!a||x4(o))&&delete e[t],r&&o.subRows.length&&S4(o)&&o.subRows.forEach(t=>w4(e,t.id,n,r,i,a))}function T4(e,t){if(!x4(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(!S4(r)){s=!1;break}c=r.parentId}return o.forEach(e=>t.set(e,s)),s}function E4(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 D4(e,t,n,r){let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=k4(o,t);if(s&&(n.push(o),r[o.id]=o),o.subRows.length){let e=D4(o.subRows,t,n,r);if(s){let t=Object.create(Object.getPrototypeOf(o));Qhe(t,o),t.subRows=e,i.push(t)}}else s&&i.push(o)}return i}function O4(e,t){let n=[],r=y2(),i=t.atoms.rowSelection?.get()??{};return{rows:D4(e.rows,i,n,r),flatRows:n,rowsById:r}}function k4(e,t){return!!(b2(t,e.id)&&t[e.id])}function A4(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(x4(o)&&(i=!0,k4(o,t)?n=!0:r=!1),o.subRows.length){let e=A4(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 Z_e={initTableInstanceData:e=>{e._lastSelectedRowId=null},resetTableInstanceData:e=>{e._lastSelectedRowId=null},getInitialState:e=>({rowSelection:z_e(),...e}),getDefaultTableOptions:e=>({onRowSelectionChange:x2(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableRowRangeSelection:!0,enableSubRowSelection:!0,isRowRangeSelectionEvent:e=>{let t=e;return!!(t.shiftKey||t.nativeEvent?.shiftKey)}}),assignRowPrototype:(e,t)=>{k2(`rowSelectionFeature`,e,t,{row_toggleSelected:{fn:(e,t,n)=>v4(e,t,n)},row_getIsSelected:{fn:e=>y4(e)},row_getIsSomeSelected:{fn:e=>b4(e),memoDeps:e=>[e.subRows,e.table.atoms.rowSelection?.get(),e.table.options.enableRowSelection]},row_getIsAllSubRowsSelected:{fn:e=>J_e(e),memoDeps:e=>[e.subRows,e.table.atoms.rowSelection?.get(),e.table.options.enableRowSelection]},row_getCanSelect:{fn:e=>x4(e)},row_getCanSelectSubRows:{fn:e=>S4(e)},row_getCanMultiSelect:{fn:e=>C4(e)},row_getToggleSelectedHandler:{fn:(e,t)=>Y_e(e,t)}})},constructTableAPIs:e=>{O2(`rowSelectionFeature`,e,{table_setRowSelection:{fn:t=>d4(e,t)},table_resetRowSelection:{fn:t=>B_e(e,t)},table_toggleAllRowsSelected:{fn:(t,n)=>f4(e,t,n)},table_toggleAllPageRowsSelected:{fn:(t,n)=>p4(e,t,n)},table_getPreSelectedRowModel:{fn:()=>V_e(e)},table_getSelectedRowModel:{fn:()=>H_e(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getCoreRowModel()]},table_getFilteredSelectedRowModel:{fn:()=>U_e(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getFilteredRowModel()]},table_getGroupedSelectedRowModel:{fn:()=>W_e(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getSortedRowModel()]},table_getSelectedRowIds:{fn:()=>m4(e),memoDeps:()=>[e.atoms.rowSelection?.get()]},table_getIsAllRowsSelected:{fn:()=>h4(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getFilteredRowModel(),e.options.enableRowSelection,e.options.enableSubRowSelection]},table_getIsAllPageRowsSelected:{fn:()=>g4(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getPaginatedRowModel(),e.options.enableRowSelection,e.options.enableSubRowSelection]},table_getIsSomeRowsSelected:{fn:()=>_4(e),memoDeps:()=>[e.atoms.rowSelection?.get()]},table_getIsSomePageRowsSelected:{fn:()=>G_e(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getPaginatedRowModel(),e.options.enableRowSelection]},table_getToggleAllRowsSelectedHandler:{fn:()=>K_e(e)},table_getToggleAllPageRowsSelectedHandler:{fn:()=>q_e(e)}})}},Q_e={getInitialState(e){return{sorting:Yge(),...e}},getDefaultColumnDef(){return{sortFn:`auto`,sortUndefined:1}},getDefaultTableOptions(e){return{autoResetSorting:!1,onSortingChange:x2(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}},assignColumnPrototype(e,t){k2(`rowSortingFeature`,e,t,{column_getAutoSortFn:{fn:e=>$2(e)},column_getAutoSortDir:{fn:e=>e4(e)},column_getSortFn:{fn:e=>Zge(e)},column_toggleSorting:{fn:(e,t,n)=>t4(e,t,n)},column_getFirstSortDir:{fn:e=>n4(e)},column_getNextSortingOrder:{fn:(e,t)=>r4(e,t)},column_getCanSort:{fn:e=>i4(e)},column_getCanMultiSort:{fn:e=>a4(e)},column_getIsSorted:{fn:e=>o4(e)},column_getSortIndex:{fn:e=>Qge(e)},column_clearSorting:{fn:e=>$ge(e)},column_getToggleSortingHandler:{fn:e=>e_e(e)}})},constructTableAPIs(e){O2(`rowSortingFeature`,e,{table_setSorting:{fn:t=>Z2(e,t)},table_resetSorting:{fn:t=>Q2(e,t)}})}},$_e=typeof window>`u`?I.useEffect:I.useLayoutEffect;function eve(e,t){let[{table:n,rootSource:r}]=(0,I.useState)(()=>{let t=R_e({...e,features:{coreReactivityFeature:Zhe(),...e.features}});return t.Subscribe=(e=>qhe({...e,source:e.source??t.store})),t.FlexRender=Rhe,{table:t,rootSource:Xhe(t.store,m2)}}),i=n;u4(i,t=>({...t,...e}),{syncExternalState:!1});let a=i.options.state,o=r.get(),s=g2(r,t,{compare:m2});return $_e(()=>{r.markCommitted(o),l4(i,a??null,m2)}),(0,I.useMemo)(()=>({...n,options:e,state:s}),[n,e,s])}var tve=e=>t=>{let n=t.currentTarget;n.scrollWidth>Math.ceil(n.getBoundingClientRect().width)?n.title=e:n.removeAttribute(`title`)},j4=({text:e,className:t})=>(0,R.jsx)(`span`,{className:g(`truncate`,t),onMouseEnter:tve(e),children:e}),M4=e=>(0,R.jsx)(`span`,{className:`text-faint-foreground`,children:e}),N4=(e,t)=>{if(t==null)return M4(`—`);let n=Rb(e,t)??``;switch(e.kind){case`text`:return e.link?(0,R.jsx)(sC,{format:e.link,value:n,className:`block min-w-0 truncate`}):(0,R.jsx)(j4,{text:n});case`id`:return(0,R.jsx)(j4,{text:n,className:`font-mono text-xs text-muted-foreground`});case`money`:return(0,R.jsx)(`span`,{className:`tabular-nums`,children:n});case`date`:return(0,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n});case`datetime`:return(0,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,title:e.relative?Kf(Number(t)):Ib(`shownIn`,Ff(Number(t),Ef())),children:n});case`number`:return(0,R.jsx)(`span`,{className:`tabular-nums`,children:n});case`signed`:return(0,R.jsx)(`span`,{className:g(`tabular-nums`,Number(t)<0?`text-danger-text`:`text-success-text`),children:n});case`percent`:return Number(t)===0?M4(`—`):(0,R.jsx)(`span`,{className:`tabular-nums`,children:n});case`status`:return(0,R.jsx)(dd,{tone:e.tones?.[String(t)]??`neutral`,color:K0(e.colors,t),shape:e.shape,children:n});case`relation`:return(0,R.jsx)(j4,{text:n,className:`font-medium text-primary-text hover:underline`});case`boolean`:return t?(0,R.jsx)(`span`,{className:`inline-flex size-4 items-center justify-center rounded-full bg-success-soft text-success-text`,children:(0,R.jsx)(Ci,{className:`size-3`,strokeWidth:3})}):M4(Ib(`no`));case`file`:{let e=wb(t);if(!e)return M4(`—`);if(`missing`in e)return(0,R.jsx)(j4,{text:e.name,className:`text-danger-text`});let n=Mb(t,{width:20,height:20});return(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[n?(0,R.jsx)(QS,{image:n,className:`size-5 shrink-0 rounded-sm object-cover`}):(0,R.jsx)(Xa,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(j4,{text:e.name})]})}case`user`:{let e=Ly(String(t));return(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-2 truncate`,children:[(0,R.jsx)(nd,{initials:e.initials,hue:e.hue,size:`xs`,className:`ring-0`}),(0,R.jsx)(j4,{text:e.name,className:`text-muted-foreground`})]})}}},nve=I_e({rowSortingFeature:Q_e,rowSelectionFeature:Z_e}),P4=F_e(),rve=e=>P4.columns(e.map(e=>P4.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):N4(e,t.getValue())}))),ive=(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}]}),ave=({total:e,selectedCount:t,bulkActions:n=[],className:r})=>(0,R.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,R.jsxs)(`span`,{className:`flex items-center tabular-nums`,children:[Tf(e),t>0&&(0,R.jsx)(`span`,{className:`ml-3 font-medium text-primary-text`,children:Ib(`selected`,Sf(t))}),t>0&&n.map(e=>(0,R.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))]})}),ove=(e,t)=>typeof e.label==`string`?e.label:e.label(t),sve=(e,t)=>e.filter(e=>e.available?.(t)??!0),cve=({row:e,actions:t})=>{let{open:n,setOpen:r,place:i,button:a,menu:o}=xS();return(0,R.jsxs)(`div`,{className:`relative flex justify-center bg-inherit`,onClick:e=>e.stopPropagation(),children:[(0,R.jsx)(`button`,{ref:a,type:`button`,"aria-label":Ib(`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,R.jsx)(Yi,{className:`size-4`})}),n&&(0,ps.createPortal)((0,R.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=ove(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,R.jsx)(`li`,{role:`none`,children:t.link?(0,R.jsx)(Ku,{role:`menuitem`,to:t.link(e),onClick:()=>r(!1),className:o,children:i}):(0,R.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)]})},lve=e=>52+Math.ceil(String(e).length*1.33)*7,F4=.6,I4=(e,t)=>Math.max(e.minWidth??0,e.width*t),uve=(e,t)=>e.fixed?`${Math.max(e.minWidth??0,e.width)}px`:`minmax(${I4(e,t)}px, ${e.width}fr)`,L4=(e,t,n=0,r=F4)=>`${t}px ${e.map(e=>uve(e,r)).join(` `)}${n>0?` ${n}px`:``}`,dve=(e,t,n=0,r=F4)=>t+n+e.reduce((e,t)=>e+(t.fixed?Math.max(t.minWidth??0,t.width):I4(t,r)),0),fve=()=>{let e=(0,I.useRef)(null),t=(0,I.useRef)(null),[n,r]=(0,I.useState)({scrolled:!1,more:!1}),i=(0,I.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,I.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}},pve=`protobase:pinned:`,mve=(e,t)=>`${pve}${e}:${t}`,hve=(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),gve=(e,t,n)=>u(()=>e.setItem(t,JSON.stringify(n)),void 0),_ve=(e,t=[])=>{let[n,r]=(0,I.useState)(()=>e?hve(localStorage,e):void 0),i=(0,I.useCallback)(t=>{r(t),e&&gve(localStorage,e,t)},[e]);return[n??t,i]},vve=e=>{let t=e.findIndex(e=>e.title);return t<0||t>1?[]:e.slice(0,t+1).map(e=>e.id)},yve=e=>Object.fromEntries(e.map(({id:e,width:t,minWidth:n,fixed:r})=>[e,{width:t,minWidth:n,fixed:r}])),bve=(e,t)=>{let n=e.map(e=>e.id).sort().join(` `),[r,i]=(0,I.useState)(),a=r?.key===n?r:void 0;!a&&t.length>0&&i({key:n,sizes:yve(tx(e,t))});let o=a?.sizes;return(0,I.useMemo)(()=>o?e.map(e=>({...e,...o[e.id]})):e,[e,o])},R4=e=>e===`money`||e===`number`||e===`signed`||e===`percent`,z4=()=>Ib(`unsortable`),xve=({header:e,pinned:t,sortable:n,onTogglePin:r})=>{let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null);return(0,I.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,R.jsxs)(`div`,{ref:o,className:`relative ml-auto shrink-0`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":Ib(`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,R.jsx)(Yi,{className:`size-3.5`})}),i&&(0,R.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,R.jsx)(`li`,{role:`none`,children:(0,R.jsx)(`span`,{role:`menuitem`,"aria-disabled":`true`,className:`block min-h-9 whitespace-nowrap px-3 py-1.5 text-muted-foreground`,children:z4()})}),(0,R.jsx)(`li`,{role:`none`,children:(0,R.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:Ib(t?`unpin`:`pinToLeft`)})})]})]})},Sve=({sorted:e})=>e===`asc`?(0,R.jsx)(Xr,{className:`size-3 text-foreground`}):e===`desc`?(0,R.jsx)(Br,{className:`size-3 text-foreground`}):(0,R.jsx)(ji,{className:`size-3 opacity-0 group-hover/head:opacity-100`}),B4=({spec:e})=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.header}),e.highlight&&(0,R.jsx)(`span`,{className:`rounded bg-primary px-1 text-[10px] font-semibold uppercase leading-4 text-primary-foreground`,children:Ib(`new`)})]}),Cve=({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,R.jsxs)(`div`,{className:`grid h-8 shrink-0 items-center border-b bg-surface text-body font-medium text-muted-foreground`,style:{gridTemplateColumns:L4(t,n,a,o)},role:`row`,children:[(0,R.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,R.jsx)(tg,{checked:!1,indeterminate:r>0,label:Ib(r>0?`clearSelection`:`noRowsSelected`),disabled:r===0,onChange:d,className:g(r===0&&`opacity-60`)}),n>40&&(0,R.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,R.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,R.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`,R4(e.kind)&&`justify-end`,`hover:text-foreground`,t&&`text-foreground`),children:[(0,R.jsx)(B4,{spec:e}),(0,R.jsx)(Sve,{sorted:t})]}):(0,R.jsx)(`div`,{title:z4(),className:g(`flex h-full min-w-0 flex-1 items-center gap-1 pl-3 pr-1 text-left`,R4(e.kind)&&`justify-end`),children:(0,R.jsx)(B4,{spec:e})}),(0,R.jsx)(`div`,{className:`pr-1.5`,children:(0,R.jsx)(xve,{header:e.header,pinned:r,sortable:!!e.sortable,onTogglePin:()=>u(e.id)})})]},e.id)}),a?(0,R.jsx)(`div`,{className:`sticky right-0 z-10 h-full bg-inherit`}):null]}),V4=e=>({gridTemplateColumns:L4(e.specs,e.gutter,e.trailing,e.minScale),height:e.height,transform:`translateY(${e.offset}px)`}),H4=(e,t)=>g(`flex h-full min-w-0 items-center overflow-hidden whitespace-nowrap px-3`,R4(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)]`),U4=(e,t)=>t&&e.id in t?{left:t[e.id]}:void 0,W4=({width:e,index:t,selectable:n,selected:r,onToggle:i,edge:a})=>(0,R.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,R.jsx)(tg,{checked:!!r,label:Ib(`selectRow`,t+1)}),e>40&&(0,R.jsx)(`span`,{className:`min-w-6 text-right text-[11px] tabular-nums text-faint-foreground`,children:Sf(t+1)})]}),wve=(e,t,n)=>({gridTemplateColumns:L4(e.specs,e.gutter,e.trailing,e.minScale),height:e.height,top:e.offset,transform:t===0?void 0:`translateY(${t}px)`,transition:n}),Tve=e=>t=>{t.target.closest(`a`)||e()},G4=({cells:e,selected:t,onToggle:n,onOpen:r,menu:i,handle:a,rowRef:o,dragY:s,transition:c,dragging:l,...u})=>(0,R.jsxs)(`div`,{ref:o,role:`row`,onClick:r&&Tve(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?V4(u):wve(u,s,c),children:[a?(0,R.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,R.jsx)(W4,{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,R.jsx)(`div`,{role:n?`gridcell`:`cell`,...n,className:g(H4(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:U4(e,u.pins),children:t},e.id)),i&&(0,R.jsx)(`div`,{className:`sticky right-0 z-10 flex h-full items-center justify-center bg-inherit`,children:i})]}),K4=[`w-3/4`,`w-1/2`,`w-2/3`,`w-5/6`,`w-2/5`],Eve=e=>(0,R.jsxs)(`div`,{role:`row`,"aria-busy":!0,className:`absolute inset-x-0 top-0 grid items-center border-b bg-background`,style:V4(e),children:[(0,R.jsx)(W4,{width:e.gutter,index:e.index,selectable:!1,edge:e.scrolled&&!e.lastPinned}),e.specs.map((t,n)=>(0,R.jsx)(`div`,{className:H4(t,e),style:U4(t,e.pins),children:(0,R.jsx)(Uu,{className:g(`h-2.5`,K4[(e.index+n)%K4.length],R4(t.kind)&&`ml-auto`)})},t.id))]}),Dve=(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}}},q4=(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)},J4=(e,t)=>Math.max(0,Math.min(40,e-t*40)),Y4=({total:e,rowAt:t,loadRows:n,revision:r,latencyMs:i},a,o)=>{let s=(0,I.useMemo)(()=>Dve(40,60),[t,n]),[c,l]=(0,I.useState)(0),u=Math.floor(a/40),d=Math.floor(o/40),f=!n&&i===0;(0,I.useEffect)(()=>{if(f)return;let r=q4(u*40,d*40,40).filter(e=>!s.hasPage(e)),a=t=>J4(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,I.useRef)(r);return(0,I.useEffect)(()=>{if(!n||r===p.current)return;p.current=r;let t=q4(u*40,d*40,40);s.keepOnly(t);for(let r of t.filter(e=>s.hasPage(e)))n(r*40,J4(e,r)).then(e=>{s.setPage(r,e),l(e=>e+1)})},[s,r,n,u,d,e]),(0,I.useCallback)(e=>f?t(e):s.get(e),[s,f,t,c])},Ove=1e7,X4=(e,t,n)=>{let r=e*t,i=Math.min(r,Ove);return{rowHeight:t,trueHeight:r,contentHeight:i,scaled:r>i,maxTop:Math.max(0,r-n),maxScroll:Math.max(0,i-n)}},kve=(e,t)=>!e.scaled||t<=0?t:t>=e.maxScroll?e.maxTop+t-e.maxScroll:t/e.maxScroll*e.maxTop,Z4=(e,t)=>!e.scaled||t<=0?t:t>=e.maxTop?e.maxScroll+t-e.maxTop:t/e.maxTop*e.maxScroll,Ave=(e,t,n,r)=>{let i=t*e.rowHeight;return e.scaled?i-n+r:i},Q4=(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)}},jve=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},$4=e=>e===(document.scrollingElement??document.documentElement),Mve=e=>$4(e)?window:e,e3=e=>Number.parseFloat(e)||0,Nve=e=>{let t=getComputedStyle(e),n=$4(e)?{top:0,height:e.clientHeight}:{top:e.getBoundingClientRect().top+e.clientTop,height:e.clientHeight},r=e3(t.scrollPaddingTop);return{top:n.top+r,height:Math.max(0,n.height-r-e3(t.scrollPaddingBottom))}},t3=6,n3=(e,t,n)=>{let r=X4(t,n,e.height),i=kve(r,e.position);return{geometry:r,top:i,topIndex:Math.floor(Math.max(0,i)/n),...Q4(t,i,n,e.height,t3)}},r3=({total:e,rowHeight:t,initialIndex:n,inset:r=0,settle:i,ready:a=!0,onScroll:o})=>{let s=(0,I.useRef)(null),c=(0,I.useRef)(null),[l,u]=(0,I.useState)({position:0,height:0}),d=(0,I.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,I.useCallback)(()=>{let e=s.current;if(!e||!c.current)return;let t=Nve(c.current),n=d.current.inset;return{position:t.top+n-e.getBoundingClientRect().top,height:Math.max(0,t.height-n)}},[]),p=(0,I.useRef)({pending:!0,laidOut:!1}),m=(0,I.useRef)(l);m.current=l;let h=(0,I.useCallback)(()=>{let e=f();if(!e)return;let t=m.current,{total:n,rowHeight:r,onScroll:i}=d.current,a=n3(t,n,r),o=n3(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,I.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+=Z4(X4(n,r,e.height),i*r)-e.position:e.position>0&&(t.scrollTop=0)},[f]);(0,I.useLayoutEffect)(()=>{let e=s.current;if(!e)return;let t=jve(e);c.current=t;let n=Mve(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,I.useLayoutEffect)(()=>{g(),h()});let _=(0,I.useCallback)(e=>{let t=f();if(!t||!c.current)return;let n=X4(d.current.total,d.current.rowHeight,t.height);c.current.scrollTop+=Z4(n,e)-t.position,h()},[f,h]),v=n3(l,e,t),y=i?i(v.top):v.top,{first:b,last:x}=i?Q4(e,y,t,l.height,t3):v,S=Array.from({length:x-b+1},(e,t)=>({index:b+t,offset:Ave(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:_}},Pve=e=>e===`ArrowUp`||e===`ArrowDown`||e===`ArrowLeft`||e===`ArrowRight`,Fve=(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},Ive=(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)},i3=e=>`${e.index}:${e.column}`,Lve=({editor:e,columns:t,total:n,rowAt:r,onOpenRow:i,container:a})=>{let[o,s]=(0,I.useState)(),[c,l]=(0,I.useState)(!1),u=(0,I.useRef)(!1),d=(0,I.useRef)(!1);if((0,I.useEffect)(()=>{if(!o||c||!u.current)return;u.current=!1;let e=a.current?.querySelector(`[data-cell="${i3(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?Ive(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":i3(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!==i3(o))return;let a=e.key===`Tab`?e.shiftKey?`ArrowLeft`:`ArrowRight`:e.key;if(Pve(a)){let i=Fve(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)}}},Rve=({ids:e,rowAt:t,reorder:n,children:r})=>{let i=T_(w_(bv,{activationConstraint:{distance:4}}),w_(Sv,{activationConstraint:{delay:250,tolerance:5}}),w_(fv,{coordinateGetter:Ay})),a=t=>e.indexOf(String(t)),o=e=>{let r=t(a(e));return r?n.label(r):Ib(`row`)};return(0,R.jsx)(fy,{sensors:i,collisionDetection:P_,onDragEnd:({active:e,over:t})=>{t&&e.id!==t.id&&n.onMove(a(e.id),a(t.id))},accessibility:{announcements:{onDragStart:({active:t})=>Ib(`pickedUp`,o(t.id),a(t.id)+1,e.length),onDragOver:({active:t,over:n})=>n?Ib(`isOver`,o(t.id),a(n.id)+1,e.length):void 0,onDragEnd:({active:t,over:n})=>n?Ib(`droppedAt`,o(t.id),a(n.id)+1,e.length):Ib(`putBack`,o(t.id)),onDragCancel:({active:e})=>Ib(`cancelled`,o(e.id),a(e.id)+1)},screenReaderInstructions:{draggable:Ib(`reorderInstructions`)}},children:(0,R.jsx)(Ey,{items:e,strategy:Cy,children:r})})},zve=({row:e,label:t,...n})=>{let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,transition:c,isDragging:l}=Oy({id:e.id}),u=(0,R.jsx)(`button`,{ref:o,type:`button`,"aria-label":Ib(`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,R.jsx)(aa,{className:`size-4`})});return(0,R.jsx)(G4,{...n,rowRef:a,handle:u,dragY:s?.y??0,transition:c,dragging:l})},a3=32,o3=({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=!Eu(),D=(h??(E?[]:vve(e))).join(` `),[O,k]=_ve(m,(0,I.useMemo)(()=>D?D.split(` `):[],[D])),A=(0,I.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,ee]=(0,I.useState)(n?[{id:n.columnId,desc:n.direction===`desc`}]:[]),te=o?[{id:o.columnId,desc:o.direction===`desc`}]:N,ne=e=>{let t=typeof e==`function`?e(te):e,n=t[0];s&&n&&s({columnId:n.id,direction:n.desc?`desc`:`asc`}),o||ee(t)},[re,ie]=(0,I.useState)({}),ae=(0,I.useMemo)(()=>rve(A),[A]),oe=te[0],se=!!(!o&&n&&oe&&oe.id===n.columnId&&(oe.desc?`desc`:`asc`)!==n.direction),ce=t.rowAt,le=(0,I.useCallback)(e=>ce(se?M-1-e:e),[ce,se,M]),[ue]=(0,I.useState)(r),{ref:de,geometry:P,rows:fe,first:pe,last:me}=r3({total:M,rowHeight:T,initialIndex:ue,inset:a3,onScroll:i&&(e=>i(e/T))}),he=E||!_?40:lve(M),F=Y4({total:M,rowAt:ce?le:void 0,loadRows:t.loadRows,revision:t.revision,latencyMs:a},pe,me),ge=(0,I.useCallback)(e=>{let t=F(e),n=t&&f?.get(t.id);return n?{...t,...n}:t},[F,f]),_e=fe.map(({index:e,offset:t})=>({index:e,offset:t,row:ge(e)})),ve=(0,I.useMemo)(()=>_e.flatMap(({row:e})=>e?[e]:[]),[ge,pe,me]),ye=bve(A,ve),be=eve({features:nve,columns:ae,data:ve,state:{sorting:te,rowSelection:re},onSortingChange:ne,onRowSelectionChange:ie,manualSorting:!0,enableMultiSort:!1,enableSortingRemoval:!1,getRowId:e=>e.id}),xe=new Map(be.getRowModel().rows.map(e=>[e.id,e])),Se=Object.keys(re).length,Ce=(0,I.useRef)(new Map);for(let e of be.getRowModel().rows)e.getIsSelected()&&Ce.current.set(e.id,e.original);let we=u&&u.length>0?40:0,Te=E?1:F4,Ee=fve(),De=(0,I.useRef)(null),Oe=()=>{Ee.onScroll(),De.current&&Ee.ref.current&&(De.current.scrollLeft=Ee.ref.current.scrollLeft)},[ke,Ae]=(0,I.useState)({});(0,I.useLayoutEffect)(()=>{let e=De.current?.querySelector(`[role=row]`);if(!e)return;let t=he,n={};for(let r of j)n[r]=t,t+=e.querySelector(`[data-col-id="${r}"]`)?.offsetWidth??0;JSON.stringify(ke)!==JSON.stringify(n)&&Ae(n)});let je=j.at(-1),Me=e=>k(O.includes(e)?O.filter(t=>t!==e):[...O,e]),Ne=be.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)}))),Pe=(0,I.useRef)(null),Fe=Lve({editor:d,columns:(0,I.useMemo)(()=>A.map(e=>e.id),[A]),total:M,rowAt:ge,onOpenRow:c,container:Pe}),Ie=(A.find(e=>e.title)??A[0])?.id,Le=dve(ye,he,we,Te),Re=S===`own`,ze=(0,R.jsx)(`div`,{ref:De,className:g(`sticky z-20 shrink-0 overflow-hidden`,Re?`top-0`:`top-[var(--pb-sticky-top,0px)]`),children:(0,R.jsx)(`div`,{style:{minWidth:Le},children:(0,R.jsx)(Cve,{cells:Ne,specs:ye,gutter:he,trailing:we,minScale:Te,pins:ke,lastPinned:je,scrolled:Ee.scrolled,onTogglePin:Me,selectable:w,selectedCount:Se,onClearSelection:()=>ie({})})})}),Be=_e.map(({index:e,offset:t,row:n})=>{let r={specs:ye,gutter:he,index:e,offset:t,height:T,selectable:w,trailing:we,minScale:Te,scrolled:Ee.scrolled,pins:ke,lastPinned:je},i=n?xe.get(n.id):void 0;if(!i||!n)return(0,R.jsx)(Eve,{...r},`skeleton-${e}`);let a=we?sve(u,n):[],o={...r,selected:i.getIsSelected(),onToggle:()=>i.toggleSelected(),onOpen:c?()=>c(n):void 0,menu:a.length>0?(0,R.jsx)(cve,{row:n,actions:a}):void 0,cells:i.getAllCells().map(t=>{let r=(0,R.jsx)(be.FlexRender,{cell:t}),i=!!d?.editable(n,t.column.id),a=l&&t.column.id===Ie&&!i?(0,R.jsx)(Ku,{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),...Fe?Fe.cell(e,n,t.column.id,a):{content:a}}})};return b?(0,R.jsx)(zve,{...o,row:n,label:b.label(n)},n.id):(0,R.jsx)(G4,{...o},n.id)}),Ve=(0,R.jsx)(`div`,{ref:Ee.attach,onScroll:Oe,className:`overflow-x-auto overflow-y-hidden overscroll-x-contain [-webkit-overflow-scrolling:touch]`,children:(0,R.jsx)(`div`,{ref:de,className:`relative`,style:{minWidth:Le,height:P.contentHeight},children:b?(0,R.jsx)(Rve,{ids:Array.from({length:M},(e,t)=>ge(t)?.id??`missing-${t}`),rowAt:ge,reorder:b,children:Be}):Be})});return(0,R.jsxs)(`div`,{ref:Pe,role:`grid`,"aria-rowcount":M,onKeyDown:Fe?.onKeyDown,className:g(`flex flex-col rounded-lg border bg-background`,Re?`min-h-0 overflow-hidden`:`overflow-clip`,C),style:x&&Re?{height:a3+M*T+2}:void 0,children:[(0,R.jsxs)(`div`,{className:g(`relative`,Re&&`flex min-h-0 flex-1 flex-col`),children:[Re?(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,children:[ze,Ve]}):(0,R.jsxs)(R.Fragment,{children:[ze,Ve]}),Ee.more&&(0,R.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,R.jsx)(ave,{total:M,className:Re?void 0:`sticky bottom-[var(--pb-sticky-bottom,0px)] z-20`,selectedCount:Se,bulkActions:ive(p??[],Object.keys(re).flatMap(e=>Ce.current.get(e)??[])).map(({action:e,rows:t,skipped:n})=>({label:e.label(t.length),destructive:e.destructive,onRun:()=>{e.onRun(t,n),ie({}),Ce.current.clear()}}))})]})},Bve=500,s3=async(e,t,n)=>{let r=[],i={},a;do{let o=await e.search(t,{...n,pageSize:Bve,...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}},c3=Un(),l3=(...e)=>{let t=e.filter(e=>!!e);return t.length===1?t[0]:t.map(e=>`(${e})`).join(` AND `)},u3=e=>e==null?void 0:String(e),Vve=(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=u3(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},Hve=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 s3(e,a.name,{filter:l3(Fn(c3.in(i.field,r)),i.filter),fields:[i.field,o]})).items.flatMap(e=>{let t=u3(e[i.field]),n=u3(e[o]);return t===void 0||n===void 0?[]:[[t,n]]})},Uve=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 Hve(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=W0(t,n,s,u),f=await s3(e,s.name,{filter:l3(Fn(c3.in(a.field,l)),a.filter),...a.sort&&{orderBy:a.sort},fields:u,labels:d});return Vve(c,G0(t,s,u,f.items,f.labels),a.field)},Wve=5e3,Gve=({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?H.page(i.name,o,s,40,e):[...H.page(i.name,o,s,40,e),l],d=W0(n,r,i,a),f=jx(r[i.name]),p=async e=>e.nextPageToken===``?e.items.length:e.totalSizeEstimate>Wve?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=>fx(i,e)),_=G0(n,i,a,Mx(i,h.items,h.photos),h.labels),v=await Promise.all(c.map(e=>Uve({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}},d3=({resources:e,views:t,model:n,columns:r,filter:i,orderBy:a,related:o})=>{let s=U(),c=Om(),l=r.join(`,`),u=JSON.stringify(o??[]),d=(0,I.useMemo)(()=>Gve({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=Ah({queryKey:[...H.first(n.name,i,a),l],queryFn:async()=>(await c.invalidateQueries({queryKey:H.pages(n.name,i,a),refetchType:`none`}),d.page(0))});return{source:(0,I.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:[...H.first(n.name,i,a),l]}},Kve=`protobase:embedded-display:`,qve=e=>`${Kve}${e}`,Jve=(e,t)=>u(()=>e.getItem(t)??void 0,void 0),Yve=(e,t,n)=>u(()=>e.setItem(t,n),void 0),f3=(e,t,{picked:n,preferred:r})=>{let i=Jx(e).map(e=>e.name);return n!==void 0&&i.includes(n)?n:Bx(e,t,r!==void 0&&i.includes(r)?r:void 0)},p3=(e,t,n,{resource:r=e.name,...i})=>lS({kind:`list`,resource:r},i,{...cS(e,t,n),display:Bx(t,n)}),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`}}),m3=`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`,h3=({chips:e,className:t})=>(0,R.jsx)(`ul`,{className:g(`flex flex-wrap gap-1.5`,t),"aria-label":Q(`filters`),children:e.map(e=>(0,R.jsx)(`li`,{className:m3,children:e.label},e.key))}),g3=({chips:e})=>(0,R.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,t)=>(0,R.jsxs)(`span`,{className:m3,children:[t>0&&(0,R.jsx)(`span`,{className:`sr-only`,children:`, `}),e.label]},e.key))}),Xve=e=>e.map(e=>e.label).join(`, `),_3=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`}}),Zve=`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`,v3=({chips:e,lockedLabels:t=[],onRemove:n,onClear:r,scroll:i})=>e.length===0&&t.length===0?null:(0,R.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,R.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,R.jsx)(ite,{className:`size-3 text-muted-foreground`}),e]},e)),e.map(e=>(0,R.jsxs)(`span`,{className:Zve,children:[e.label,(0,R.jsx)(`button`,{type:`button`,"aria-label":_3(`remove`,e.label),onClick:()=>n(e.key),className:`rounded-full p-0.5 hover:bg-primary-border/60`,children:(0,R.jsx)(ds,{className:`size-3`})})]},e.key)),e.length>0&&(0,R.jsx)(`button`,{type:`button`,onClick:r,className:`ml-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:_3(`clearAll`)})]}),Qve=[`today`,`7d`,`30d`,`year`],$ve=new Set([`today`,`yesterday`,`24h`,`7d`,`30d`,`90d`,`month`,`quarter`,`year`]),y3=e=>$ve.has(e)?_3(e):void 0,eye=({value:e,presets:t=Qve,onChange:n})=>(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let r=y3(t);return(0,R.jsx)(`button`,{type:`button`,disabled:!r,title:r?void 0:_3(`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??_3(`unsupported`,t)},t)})}),b3=({label:e,onRemove:t})=>(0,R.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,R.jsx)(`span`,{className:`truncate`,children:e}),(0,R.jsx)(`button`,{type:`button`,"aria-label":Bd(`remove`,e),className:`rounded p-0.5 hover:bg-primary-border/60`,onMouseDown:e=>e.preventDefault(),onClick:t,children:(0,R.jsx)(ds,{className:`size-3`})})]}),x3={facets:{},toggles:[]},S3=(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}}},C3=(e,t)=>({...e,toggles:e.toggles.includes(t)?e.toggles.filter(e=>e!==t):[...e.toggles,t]}),w3=(e,t,n)=>{let{[t]:r,...i}=e.ranges??{};return{...e,ranges:n?{...i,[t]:n}:i}},T3=(e,t)=>e.options.find(e=>e.value===t)?.label??e.labels?.[t]??t,E3=(e,t)=>{let n=e.facets.flatMap(e=>(t.facets[e.id]??[]).map(t=>({key:`facet:${e.id}:${t}`,label:`${e.label}: ${T3(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:y3(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]},D3=(e,t)=>{if(t===`date`)return{...e,date:void 0};let[n,r,i]=t.split(`:`);if(n===`range`)return w3(e,r,void 0);if(n===`toggle`)return C3(e,r);if(n===`facet`)return S3(e,r,i);throw Error(`Unknown filter chip key: ${t}`)},O3=(e,t)=>e.toLowerCase().includes(t.trim().toLowerCase()),tye=(e,t)=>e.onSearch?e.options:e.options.filter(e=>O3(e.label,t)),nye=(e,t,n)=>t===0?-1:n===`ArrowDown`?e<0?0:(e+1)%t:e<0?t-1:(e-1+t)%t,rye=({config:e,selected:t,onToggle:n,inline:r=!1})=>{let i=(0,I.useId)(),a=(0,I.useRef)(null),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(-1),f=r||c,p=tye(e,o),m=(0,I.useRef)(e.onSearch);m.current=e.onSearch,(0,I.useEffect)(()=>()=>m.current?.(``),[]);let h=t=>{s(t),d(-1),e.onSearch?.(t)};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.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,R.jsx)(vo,{className:`size-3.5 shrink-0 text-muted-foreground`}),t.map(t=>(0,R.jsx)(b3,{label:T3(e,t),onRemove:()=>n(t)},t)),(0,R.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?``:_3(`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(nye(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,R.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,R.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,R.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,R.jsx)(Ci,{className:`size-3`,strokeWidth:3})}),(0,R.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:Sf(e.count)})]},e.value)}),p.length===0&&(0,R.jsx)(`li`,{className:`px-1.5 py-1 text-xs text-faint-foreground`,children:_3(`noMatches`)})]})]})},iye=({config:e,selected:t,onToggle:n})=>{let[r,i]=(0,I.useState)(``),a=e.options.filter(e=>O3(e.label,r));return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.searchable&&(0,R.jsx)(Rd,{wrapperClassName:`mb-1 h-7`,leading:(0,R.jsx)(vo,{className:`size-3.5`}),placeholder:_3(`searchIn`,e.label),value:r,onChange:e=>i(e.target.value)}),a.map(e=>(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-1 hover:bg-muted`,children:[(0,R.jsx)(tg,{checked:t.includes(e.value),onChange:()=>n(e.value),label:e.label}),(0,R.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:Sf(e.count)})]},e.value)),a.length===0&&(0,R.jsx)(`span`,{className:`px-1 py-1 text-xs text-faint-foreground`,children:_3(`noMatches`)})]})},k3=({label:e,activeCount:t,width:n=240,defaultOpen:r=!1,children:i})=>{let[a,o]=(0,I.useState)(r),[s,c]=(0,I.useState)(!1),l=(0,I.useRef)(null);return(0,I.useLayoutEffect)(()=>{a&&l.current&&c(l.current.getBoundingClientRect().left+n>document.documentElement.clientWidth)},[a,n]),(0,I.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,R.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,R.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,R.jsx)(`span`,{className:`rounded-full bg-primary px-1.5 text-[11px] leading-4 text-primary-foreground`,children:t}),(0,R.jsx)(Ti,{className:`size-3.5 text-muted-foreground`})]}),a&&(0,R.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})]})},A3=({title:e,children:t})=>(0,R.jsxs)(`section`,{className:`flex flex-col gap-2 border-b py-3 last:border-b-0`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),t]}),j3=(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}},aye=({items:e,onPick:t,close:n})=>{let r=(0,I.useRef)([]);return(0,I.useEffect)(()=>r.current[0]?.focus(),[]),(0,R.jsx)(`ul`,{role:`menu`,"aria-label":_3(`moreFilters`),onKeyDown:t=>{if(t.key===`Escape`)return n();let i=j3(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,R.jsx)(`li`,{role:`none`,children:(0,R.jsx)(`button`,{ref:e=>{r.current[i]=e},type:`button`,role:`menuitem`,className:Gae,onClick:()=>{n(),t(e.key)},children:e.label})},e.key))})},oye=({items:e,onPick:t})=>e.length===0?null:(0,R.jsx)(k3,{label:_3(`moreFilters`),activeCount:0,children:n=>(0,R.jsx)(aye,{items:e,onPick:t,close:n})}),M3=(e,t)=>{let[n,r]=(0,I.useState)(e);return(0,I.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n},sye=(e,t,n,r,i)=>{let a=n+(r-n)*e/t;return n+(r-n)*(e+1)/t>i[0]&&a<i[1]},N3=(e,t,n)=>n===t?0:(e-t)/(n-t),cye=(e,t,n)=>t===0?[Math.min(n,e[1]),e[1]]:[e[0],Math.max(n,e[0])],lye=1e3,uye=({config:e,value:t,onChange:n})=>{let{min:r,max:i,step:a,histogram:o,format:s}=e,[c,l]=(0,I.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=M3(c,lye);return(0,I.useEffect)(()=>{p&&f()},[p]),(0,R.jsxs)(`div`,{className:`w-full`,children:[(0,R.jsxs)(`div`,{className:`px-[7px]`,children:[o.length>0&&(0,R.jsx)(`div`,{className:`mb-1 flex h-12 items-end gap-0.5`,children:o.map((e,t)=>(0,R.jsx)(`span`,{className:g(`flex-1 rounded-t-sm`,sye(t,o.length,r,i,u)?`bg-primary/70`:`bg-border`),style:{height:`${Math.max(6,e/d*100)}%`}},t))}),(0,R.jsxs)(`div`,{className:`relative h-4`,children:[(0,R.jsx)(`span`,{className:`absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-border`}),(0,R.jsx)(`span`,{className:`absolute top-1/2 h-1 -translate-y-1/2 rounded-full bg-primary`,style:{left:`${N3(u[0],r,i)*100}%`,right:`${100-N3(u[1],r,i)*100}%`}})]})]}),(0,R.jsx)(`div`,{className:`relative -mt-4 h-4`,children:[0,1].map(t=>(0,R.jsx)(`input`,{type:`range`,className:`pb-range`,"aria-label":_3(t===0?`minimum`:`maximum`,e.label),min:r,max:i,step:a,value:u[t],onChange:e=>l(cye(u,t,Number(e.target.value))),onPointerUp:f,onTouchEnd:f,onBlur:f},t))}),(0,R.jsxs)(`div`,{className:`mt-2 flex justify-between text-xs tabular-nums text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:s(u[0])}),(0,R.jsx)(`span`,{children:s(u[1])})]})]})},dye=e=>[...new Set(e.map(e=>e.key.split(`:`).slice(0,2).join(`:`)))],P3=(e,t)=>{let n=t.filter(t=>!e.includes(t));return n.length===0?e:[...e,...n]},fye=(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:_3(`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}},F3=({label:e,checked:t,onChange:n})=>(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between gap-3 py-1`,children:[(0,R.jsx)(`span`,{children:e}),(0,R.jsx)(WS,{checked:t,onChange:n,label:e})]}),I3=(e,t)=>e.some(e=>e.length>0)||!!t,L3=({groups:e,trailing:t})=>{if(!I3(e,t))return null;let n=e.filter(e=>e.length>0);return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.map((e,t)=>(0,R.jsxs)(I.Fragment,{children:[t>0&&(0,R.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`}),e]},t)),t&&(0,R.jsx)(`div`,{className:`flex min-w-32 flex-1 justify-end`,children:t})]})},pye=(e,t,n)=>{let[r,i]=(0,I.useState)(t??x3);return[e??r,e=>{i(e),n?.(e)}]},R3=({config:e,layout:t,value:n,defaultValue:r,onChange:i,lockedLabels:a,defaultOpenMenu:o,fullWidth:s,leading:c,trailing:l})=>{let[u,d]=pye(n,r,i),f=E3(e,u),p=dye(f),[m,h]=(0,I.useState)(()=>p),[g,_]=(0,I.useState)();(0,I.useEffect)(()=>h(e=>P3(e,p)),[p.join(`,`)]);let v=(0,R.jsx)(v3,{chips:f,lockedLabels:a,onRemove:e=>d(D3(u,e)),onClear:()=>d(x3)}),y=(e,t=!1)=>{let n=u.facets[e.id]??[],r=t=>d(S3(u,e.id,t));return e.combobox?(0,R.jsx)(rye,{config:e,selected:n,onToggle:r,inline:t}):(0,R.jsx)(iye,{config:e,selected:n,onToggle:r})},b=e.ranges??[],x=e=>(0,R.jsx)(uye,{config:e,value:u.ranges?.[e.id],onChange:t=>d(w3(u,e.id,t))}),S=e.datePresets&&(0,R.jsx)(eye,{value:u.date,presets:Array.isArray(e.datePresets)?e.datePresets:void 0,onChange:e=>d({...u,date:e})}),C=(e.toggles??[]).map(e=>(0,R.jsx)(F3,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(C3(u,e.id))},e.id));if(t===`panel`)return(0,R.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,R.jsx)(`div`,{className:`flex items-center justify-between pb-1`,children:(0,R.jsx)(`h2`,{className:`font-semibold`,children:_3(`filters`)})}),(f.length>0||(a?.length??0)>0)&&(0,R.jsx)(`div`,{className:`border-b pb-3`,children:v}),c,e.facets.map(e=>(0,R.jsx)(A3,{title:e.label,children:y(e)},e.id)),b.map(e=>(0,R.jsx)(A3,{title:e.label,children:x(e)},e.id)),S&&(0,R.jsx)(A3,{title:_3(`date`),children:S}),C.length>0&&(0,R.jsx)(A3,{title:_3(`showOnly`),children:C})]});let{shown:w,more:T}=fye(e,m),E=e=>{h(t=>P3(t,[e])),_(e)},D=[...e.facets.filter(e=>w.has(`facet:${e.id}`)).map(e=>(0,R.jsx)(k3,{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,R.jsx)(k3,{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,R.jsx)(I.Fragment,{children:S},`date`)]:[]],O=(e.toggles??[]).filter(e=>w.has(`toggle:${e.id}`)).map(e=>(0,R.jsx)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:(0,R.jsx)(F3,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(C3(u,e.id))})},e.id)),k=[c?[(0,R.jsx)(I.Fragment,{children:c},`leading`)]:[],D,O,T.length>0?[(0,R.jsx)(oye,{items:T,onPick:E},`more`)]:[]];return!I3(k,l)&&f.length===0&&!a?.length?null:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(L3,{groups:k,trailing:l}),v]})},z3=Un(),B3={start:0,end:0},V3={"24h":{amount:24,unit:`h`},"7d":{amount:7,unit:`d`},"30d":{amount:30,unit:`d`},"90d":{amount:90,unit:`d`}},mye=e=>new Date(e).toISOString().replace(`.000Z`,`Z`),H3=(e,t,n)=>{let r=Mf(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},U3=[`year`,`quarter`,`month`,`yesterday`,`today`],W3=(e,t,n)=>t===`date`?e:mye(Pf(e,n)),G3=(e,t,n)=>t===`date`?{kind:`string`,value:W3(e,t,n),span:B3}:{kind:`timestamp`,value:W3(e,t,n),span:B3},hye=(e,t,n,r,i)=>{if(t in V3)return[z3.gte(e,z3.ago(t))];let a=z3.gte(e,G3(H3(t,n,i),r,i));return t===`yesterday`?[a,z3.lt(e,G3(H3(`today`,n,i),r,i))]:[a]},gye=(e,t,n=new Date,r=Ef())=>{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=>z3.eq(e.value,!0));return t.length===0?[]:[t.length===1?t[0]:z3.or(...t)]}return[n.length===1?z3.eq(e.id,n[0]):z3.in(e.id,n)]}),a=(e.ranges??[]).flatMap(e=>{let n=t.ranges?.[e.id];return n?[z3.gte(e.id,n[0]),z3.lte(e.id,n[1])]:[]}),o=e.dateField&&t.date?hye(e.dateField,t.date,n,e.dateKind,r):[],s=(e.toggles??[]).filter(e=>t.toggles.includes(e.id)).map(e=>z3.eq(e.id,!0));return[...i,...a,...o,...s]},_ye=e=>e.length===0?``:Fn(z3.and(...e)),K3=(e,t,n=[],r=new Date,i=Ef())=>_ye([...gye(e,t,r,i),...n]),q3=e=>e.kind===`and`?e.args.flatMap(q3):[e],J3=e=>e.field.path.join(`.`),vye=e=>e.kind===`compare`&&e.op===`=`&&e.value.kind===`boolean`&&e.value.value,yye=(e,t)=>{let n=e.kind===`or`?e.args:[e];if(!n.every(vye))return;let r=n.map(J3),i=t.get(r[0]);return i!==void 0&&r.every(e=>t.get(e)===i)?{group:i,fields:r}:void 0},Y3=e=>e.kind===`number`?String(e.raw):e.kind===`string`?String(e.value):void 0,X3=(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(V3).find(([,n])=>n.amount===e&&n.unit===t)?.[0]}if(r.kind===`timestamp`)return U3.find(e=>W3(H3(e,t,n),`timestamp`,n)===r.value);if(r.kind===`string`)return U3.find(e=>H3(e,t,n)===r.value)},Z3=(e,t,n=new Date,r=Ef())=>{let i=Yt(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?q3(i.ast):[]){let i=yye(t,c);if(i&&!a.facets[i.group])a.facets[i.group]=i.fields;else if(t.kind===`compare`&&s.has(J3(t))&&t.op===`=`&&Y3(t.value)!==void 0)a.facets[J3(t)]=[...a.facets[J3(t)]??[],Y3(t.value)];else if(t.kind===`in`&&s.has(J3(t))&&t.values.every(e=>Y3(e)!==void 0))a.facets[J3(t)]=[...a.facets[J3(t)]??[],...t.values.map(e=>Y3(e))];else if(t.kind===`compare`&&e.dateField===J3(t)&&t.op===`>=`&&X3(t,n,r)&&!a.date)a.date=X3(t,n,r),f=t;else if(t.kind===`compare`&&e.dateField===J3(t)&&t.op===`<`&&(t.value.kind===`timestamp`||t.value.kind===`string`)&&t.value.value===W3(H3(`today`,n,r),t.value.kind===`string`?`date`:`timestamp`,r))p=t;else if(t.kind===`compare`&&l.has(J3(t))&&t.op===`=`&&t.value.kind===`boolean`&&t.value.value)a.toggles.push(J3(t));else if(t.kind===`compare`&&u.has(J3(t))&&(t.op===`>=`||t.op===`<=`)&&t.value.kind===`number`){let e=d.get(J3(t))??{clauses:[]};t.op===`>=`?e.low=t.value.value:e.high=t.value.value,e.clauses.push(t),d.set(J3(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}},bye=[`integer`,`bigint`,`decimal`],xye=(e,t)=>{let n=e?.fields[t]?.type;return n!==void 0&&bye.includes(n)},Q3=(e,t)=>e.kind===`range`||e.kind===`facets`&&xye(t,e.field),$3=e=>e.secondary?{secondary:!0}:{},Sye=e=>({id:e.field,label:e.field,min:0,max:0,step:1,histogram:[],format:String,...$3(e)}),e6=(e,t)=>{let n=e?.filters??[],r=n.find(e=>e.kind===`dateRange`);return{facets:n.flatMap(e=>e.kind===`facets`&&!Q3(e,t)?[{id:e.field,label:e.field,options:[],searchable:e.search,...t?.fields[e.field]?.type===`relation`&&{combobox:!0},...$3(e)}]:e.kind===`flags`?[{id:e.fields.join(`|`),label:e.label,options:e.fields.map(e=>({value:e,label:e,count:0})),flags:!0,...$3(e)}]:[]),ranges:n.flatMap(e=>e.kind!==`flags`&&Q3(e,t)?[Sye(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,...$3(e)}]:[])}},t6=(e,t)=>(e?.filters??[]).some(e=>e.kind===`range`&&e.field===t&&e.histogram),n6=(e,t)=>{let n=e?.fields[t],r=n?.suffix??``;return e=>`${n?.prefix===`€`?yf(e*100).replace(`.00`,``):String(e)}${r}`},r6=Un(),Cye={start:0,end:0},wye=(e,t,n)=>{let r=Z3(e6(t,e),n);return r.ok?Object.fromEntries(Object.entries(r.state.facets).filter(([t,n])=>e.fields[t]?.type===`relation`&&n.length>0)):{}},Tye=(e,t,n)=>{let r=e=>t?.fields[e]?.label??K(e),i=e6(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,_s(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:n6(t,e.id)})),toggles:i.toggles?.map(e=>({...e,label:r(e.id)}))}},i6=(e,t,n,r={})=>{let i=Tye(e,t,r),a=Z3(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[...E3(i,a.state),...o]},Eye=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]))}])),Dye=(e,t,n)=>{if(typeof n!=`string`||n===``)return e;let r=r6.gt(t,{kind:`timestamp`,value:new Date(n).toISOString(),span:Cye}),i=Yt(e);if(!i.ok)throw Error(`The saved filter cannot be read: ${i.errors.map(e=>e.message).join(`; `)}`);return Fn(i.ast?r6.and(i.ast,r):r)},Oye=(e,t)=>typeof t!=`string`||t===``?!0:typeof e!=`string`||e===``?!1:new Date(e).getTime()>new Date(t).getTime(),a6=(e,t)=>{let n=U(),r=Om(),{resources:i,views:a}=J(),o=a[e.name],s=Object.entries(wye(e,o,t)),c=Oh({queries:s.map(([t,o])=>{let s=i[e.fields[t].relation.resource];return{queryKey:H.labels(`chips:${e.name}.${t}`,o.join(`,`)),enabled:s!==void 0,queryFn:async()=>Object.fromEntries(await H0(r,n,s,o,a[s.name]))}})});return i6(e,o,t,Object.fromEntries(s.flatMap(([e],t)=>c[t]?.data?[[e,c[t].data]]:[])))},kye=(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}}),o6=e=>{let t=Om();return(0,I.useCallback)(n=>t.setQueryData(H.recordPreview(e.name,ur(px(e,n))),kye(e,n)),[t,e])},s6={wallet:dte,"file-text":ra,send:So,ruler:go,bed:ni,bath:ei,house:$ee,"door-open":Gee,"land-plot":nte,leaf:ba,tag:cte,key:pa,calendar:vi,heart:ca,bell:ii,bookmark:fi,"external-link":Zi,ban:Qr,play:ste,stop:Ro,power:ao,restart:mo,terminal:lte,camera:Fee,"hard-drive":Qee,server:wo,network:Ka,archive:Rr,copy:zi,"arrow-right-left":Hr,download:Gi,upload:ns,cpu:Wee,memory:La,plug:to,wrench:fte},c6=e=>e!==void 0&&Object.hasOwn(s6,e)?s6[e]:void 0,l6=({benefits:e})=>e&&e.length>0?(0,R.jsx)(`ul`,{className:`flex flex-col gap-2 text-left`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(Ci,{className:`mt-0.5 size-4 shrink-0 text-primary`,"aria-hidden":!0}),e]},e))}):null,u6=({prompt:e})=>{let{canSignUp:t}=B(),{link:n}=ng(),r=op({variant:`primary`}),i=e.signUp?(0,R.jsx)(`a`,{href:e.signUp.href,target:`_blank`,rel:`noreferrer`,className:r,children:e.signUp.label}):t&&(0,R.jsx)(Ku,{to:n(`sign-up`),className:r,children:z(`createAnAccount`)});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Ku,{to:n(),className:i?op():r,children:z(`signIn`)}),i]})},d6=e=>{let{prompt:t}=e,n=(0,I.useId)();if(e.as===`dialog`)return(0,R.jsx)(Mw,{title:t.title,description:t.description,open:e.open,onClose:e.onClose,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:e.onClose,children:z(`notNow`)}),(0,R.jsx)(u6,{prompt:t})]}),children:(0,R.jsx)(l6,{benefits:t.benefits})});let r=c6(t.icon)??Aa;return(0,R.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,R.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,R.jsx)(r,{className:`size-6`,"aria-hidden":!0})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`h1`,{id:n,className:`text-lg font-semibold`,children:t.title}),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:t.description})]}),(0,R.jsx)(l6,{benefits:t.benefits}),(0,R.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,R.jsx)(u6,{prompt:t})})]})},Aye=Un(),f6=e=>{if(typeof e==`string`||typeof e==`number`)return e;if(e&&typeof e==`object`&&`id`in e)return f6(e.id)},jye=(e,t,n)=>n.flatMap(n=>{let r=f6(n[t]);return r===void 0?[]:[{key:ur(px(e,n)),target:r}]}),Mye=(e,t)=>e.find(e=>ur(e.target)===t),Nye=(e,t)=>[...e,{key:``,target:t}],Pye=(e,t)=>e.filter(e=>ur(e.target)!==t),p6=(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:Aye.in(n,r)},m6=(e,t)=>H.list(e,``,``,500,`saved:${t}`),h6=(e,t,n)=>{let r=U(),i=J().resources[e];return Ah({queryKey:m6(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 jye(i,t,n)}})},g6=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`}}),Fye=e=>e instanceof Error?e.message:g6(`somethingWrong`),Iye=(e,t,n)=>{let r=J(),i=U(),a=Om(),o=ub(),s=_T(),{resource:c,field:l}=e,u=r.permissions[c],d=r.resources[c]!==void 0&&u!==void 0&&eT(u,`create`)&&eT(u,`delete`),f=r.signIn?.[c]?.signIn,p=h6(c,l,d),m=p.data&&Mye(p.data,t),h=m6(c,l),g=jh({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?Pye(r,t):Nye(r,n)),{before:r}},onError:(e,t,n)=>{a.setQueryData(h,n?.before),o.show({state:`error`,title:g6(t?`couldNotTakeOff`:`couldNotSave`),description:Fye(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)}},Lye=({favorite:e,recordKey:t,target:n,className:r})=>{let i=Iye(e,t,n),[a,o]=(0,I.useState)(!1);if(!i.mode)return null;let s=e.label??g6(`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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":s,"aria-haspopup":`dialog`,className:c,onClick:()=>o(!0),children:(0,R.jsx)(ca,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(d6,{as:`dialog`,prompt:i.prompt,open:a,onClose:()=>o(!1)})]}):(0,R.jsx)(`button`,{type:`button`,"aria-label":s,"aria-pressed":i.saved,"aria-disabled":!i.ready,className:c,onClick:()=>i.ready&&i.toggle(),children:(0,R.jsx)(ca,{className:g(`size-4`,i.saved&&`fill-current text-danger`),"aria-hidden":!0})})},_6=6,Rye=(e,t,n)=>{let r=e.bottom+_6;return{top:r+t.height>n.height-_6?Math.max(_6,e.top-_6-t.height):r,left:Math.max(_6,Math.min(e.left,n.width-_6-t.width))}},v6=(e,t)=>{let n=zx(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},zye=(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:tS(r,n[r.name],v6(n[r.name],e.status))}]:[]}),Bye=a({en:{none:e=>`No ${e}`},nl:{none:e=>`Geen ${e}`}}),Vye=(e,{values:t,label:n,singular:r,plural:i})=>{if(e.length===0)return Bye(`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(`, `)}`},y6=`flex shrink-0 items-center justify-center rounded-full p-0.5 pointer-coarse:p-1.5`,b6=`size-2.5 rounded-full`,x6=`flex min-w-0 items-center gap-0.5`,Hye=150,S6=288,Uye=({shown:e,row:t,target:n,view:r,column:i,Card:a,onEnter:o,onLeave:s})=>{let c=(0,I.useRef)(null),[l,u]=(0,I.useState)();return(0,I.useLayoutEffect)(()=>{c.current&&u(Rye(e.dot,{width:S6,height:c.current.offsetHeight},{width:window.innerWidth,height:window.innerHeight}))},[e]),(0,ps.createPortal)((0,R.jsx)(`div`,{ref:c,"data-dot-card":!0,onMouseEnter:o,onMouseLeave:s,style:{width:S6,...l??{visibility:`hidden`,top:0,left:0}},className:`fixed z-50 rounded-lg shadow-pop`,children:(0,R.jsx)(a,{model:n,view:r,display:v6(r,i.status),row:t})}),document.body)},C6=({column:e,records:t,target:n,view:r,wrap:i=!1,Card:a})=>{let o=(0,I.useMemo)(()=>t.map(e=>rS(n,e)),[t,n]),[s,c]=(0,I.useState)(),l=(0,I.useRef)(void 0),u=(0,I.useRef)(`mouse`),d=(0,I.useRef)(null),f=n.fields[e.status],p=r?.fields[e.status],m=t=>f?Ox(f,t.record[e.status],p):``,h=lx(n,r),_=e=>e.labels[h]??String(e.record[h]??e.key),v=(r?.names?.singular??K(n.name)).toLowerCase(),y=(r?.names?.plural??K(n.name)).toLowerCase(),b=Vye(o.map(t=>t.record[e.status]),{values:f?.enumValues??[],label:e=>f?Ox(f,e,p):e,singular:v,plural:y}),x=()=>window.clearTimeout(l.current),S=()=>{x(),l.current=window.setTimeout(()=>c(void 0),Hye)},C=(e,t)=>{x(),c({key:e,dot:t.getBoundingClientRect()})};(0,I.useEffect)(()=>x,[]),(0,I.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,R.jsxs)(`div`,{ref:d,className:g(x6,i&&`pointer-events-none flex-wrap`),onClick:e=>e.stopPropagation(),onPointerDown:e=>u.current=e.pointerType,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:b}),o.map(t=>{let r=t.record[e.status],i=K0(p?.valueColors,r);return(0,R.jsx)(_S,{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(y6,`pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`),children:(0,R.jsx)(`span`,{"aria-hidden":!0,style:i===void 0?void 0:{backgroundColor:i},className:g(b6,i===void 0&&ld[yx(String(r))],s?.key===t.key&&`ring-2 ring-foreground/30`)})},t.key)}),s&&E&&(0,R.jsx)(Uye,{shown:s,row:E,target:n,view:r,column:e,Card:a,onEnter:x,onLeave:S})]})},Wye=({count:e})=>(0,R.jsx)(`span`,{"aria-hidden":!0,className:g(x6,`invisible flex-wrap`),children:Array.from({length:e},(e,t)=>(0,R.jsx)(`span`,{className:y6,children:(0,R.jsx)(`span`,{className:b6})},t))}),w6=`flex flex-col gap-1.5`,Gye=({dots:e})=>(0,R.jsx)(`span`,{className:w6,children:e.map(({column:e,records:t})=>(0,R.jsx)(Wye,{count:t.length},e.name))}),Kye=({dots:e,Card:t})=>{let{resources:n,views:r}=J();return(0,R.jsx)(`div`,{className:`pointer-events-none absolute inset-x-[calc(0.75rem+1px)] bottom-[calc(0.75rem+1px)] ${w6}`,children:e.map(({column:e,records:i})=>{let a=n[e.resource];return a&&(0,R.jsx)(C6,{column:e,records:i,target:a,view:r[a.name],Card:t,wrap:!0},e.name)})})},qye=(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}]:[]}),T6=({value:e})=>{let t=Mb(e,{width:320,height:240});return t?(0,R.jsx)(QS,{image:t,loading:`lazy`,className:`size-full object-cover`}):null},E6=({children:e})=>(0,R.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}),Jye=({value:e})=>(0,R.jsx)(E6,{children:(0,R.jsx)(T6,{value:e})}),Yye=10,Xye=(e,t)=>{let n=Sb(e)?e.uri:void 0,r=t.filter(e=>Sb(e)&&e.uri!==n);return(n===void 0?r:[e,...r]).slice(0,Yye)},Zye=(e,t)=>t===0?0:(e%t+t)%t,Qye=(e,t,n)=>t<=0||n===0?0:Math.min(n-1,Math.max(0,Math.round(e/t))),D6=`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`,O6=`[@media(hover:none)]:opacity-100`,$ye=({photos:e,cover:t,swipe:n=!0,children:r})=>{let i=(0,I.useRef)(null),a=(0,I.useRef)(void 0),[o,s]=(0,I.useState)(0),c=Xye(t,e),l=e=>{let t=i.current;t&&t.scrollTo({left:e*t.clientWidth})},u=e=>{a.current=Zye((a.current??o)+e,c.length),l(a.current)},d=()=>{a.current=void 0},f=e=>{s(Qye(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,R.jsx)(E6,{children:(0,R.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,R.jsx)(`span`,{className:`block size-full shrink-0 snap-start snap-always`,children:(0,R.jsx)(T6,{value:e})},t))})});return(0,R.jsxs)(R.Fragment,{children:[r(p),c.length>1&&(0,R.jsxs)(`div`,{className:`group/arrows pointer-events-none absolute inset-x-px top-px aspect-[4/3]`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":q(`previousPhoto`),className:g(D6,!n&&O6,`left-2`),onClick:()=>u(-1),children:(0,R.jsx)(Di,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(`button`,{type:`button`,"aria-label":q(`nextPhoto`),className:g(D6,!n&&O6,`right-2`),onClick:()=>u(1),children:(0,R.jsx)(ki,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsxs)(`span`,{className:`absolute inset-x-0 bottom-2 flex justify-center`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:q(`photoOf`,o+1,c.length)}),(0,R.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,R.jsx)(`span`,{className:g(`size-1.5 rounded-full`,t===o?`bg-foreground`:`bg-foreground/35`)},t))})]})]})]})},ebe=({icon:e,children:t})=>{let n=c6(e);return(0,R.jsxs)(`dd`,{className:`flex items-center gap-1 tabular-nums`,children:[n&&(0,R.jsx)(n,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t]})},k6=({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}=Xx(e,t,n),m=e=>t?.fields[e]?.label??K(e),h=n=>{let i=e.fields[n];if(!i)return``;let a=r.record[n];return r.labels[n]===void 0&&ox(i,t?.fields[n])&&typeof a==`string`&&a!==``?ax(a):r.labels[n]??Ox(i,a,t?.fields[n])},{fields:g,components:_}=tC(),v=o6(e),y=n.card===void 0?void 0:_?.[n.card],b=n=>{let i=e.fields[n],a=i&&nC(g,i,t?.fields[n]);return a?(0,R.jsx)(iC,{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||!ox(i,t?.fields[n])||nC(g,i,t?.fields[n])||typeof a!=`string`||a===``?b(n):(0,R.jsx)(aC,{source:a,inLink:!0})},S=n=>{let i=e.fields[n],a=t?.fields[n],o=r.record[n];return!i||a?.format!==`badge`||nC(g,i,a)||o==null||o===``?b(n):(0,R.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||nC(g,i,t?.fields[n]))return(0,R.jsx)(`strong`,{className:`font-semibold text-foreground`,children:b(n)});let a=$x(i,r.record[n],t?.fields[n]);return(0,R.jsxs)(R.Fragment,{children:[(0,R.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=Qx(r,l),k=Zx(r,f),A=o!==void 0||w!==void 0,j=n.favorite,M=y?[]:qye(t,n,r),N=e=>(0,R.jsxs)(R.Fragment,{children:[A&&e,(0,R.jsxs)(`span`,{className:`flex items-start justify-between gap-2 ${j&&!A?`pr-8`:``}`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:b(s)}),u!==void 0&&T!=null&&(0,R.jsx)(q0,{value:T,hints:t?.fields[u],children:h(u)})]}),c!==void 0&&(0,R.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,R.jsx)(`span`,{className:`truncate tabular-nums text-muted-foreground`,children:C(O)}),d.length>0&&(0,R.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:Zx(r,d).map(e=>(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`dt`,{className:`sr-only`,children:m(e)}),(0,R.jsx)(ebe,{icon:t?.fields[e]?.icon,children:S(e)})]},e))}),E.length>0&&(0,R.jsx)(`ul`,{className:`flex flex-wrap gap-1`,"aria-label":q(`features`),children:E.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(dd,{dot:!1,children:m(e)})},e))}),k.length>0&&(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground ${d.length>0?``:`mt-auto`}`,children:k.map((e,t)=>(0,R.jsxs)(`span`,{children:[t>0&&(0,R.jsx)(`span`,{"aria-hidden":!0,children:` • `}),b(e)]},e))}),M.length>0&&(0,R.jsx)(Gye,{dots:M})]}),ee=t=>(0,R.jsxs)(_S,{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,R.jsx)(dd,{tone:`blue`,className:`self-start`,children:a}),y?(0,R.jsx)(vg,{name:n.card,fallback:N(t),children:(0,R.jsx)(y,{row:r})}):N(t)]});return(0,R.jsxs)(`div`,{className:w?`group/card relative h-full`:j||a||M.length>0?`relative h-full`:`h-full`,children:[w?(0,R.jsx)($ye,{photos:r.photos??[],cover:D,swipe:i,children:ee},r.key):ee((0,R.jsx)(Jye,{value:D})),a&&A&&(0,R.jsx)(dd,{tone:`blue`,className:`pointer-events-none absolute top-2 left-2 shadow-sm`,children:a}),M.length>0&&(0,R.jsx)(Kye,{dots:M,Card:k6}),j&&(0,R.jsx)(Lye,{favorite:j,recordKey:r.key,target:px(e,r.record),className:A?void 0:`right-1.5 top-1.5`})]})},A6=268,j6=3,M6=(e,t,n)=>{let r=Math.floor(Math.max(0,e)/A6),i=Math.ceil((Math.max(0,e)+t)/A6);return{start:Math.max(0,r-j6),end:Math.min(n,i+j6)}},N6=e=>e*A6,tbe=e=>{let t=(0,I.useRef)(null),[n,r]=(0,I.useState)({left:0,width:0});(0,I.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]=[M6(t.left,t.width,e),M6(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,N6(e)-12),a=e=>t.current?.scrollBy({left:e*Math.max(N6(1),n.width-12),behavior:`smooth`});return{ref:t,...M6(n.left,n.width,e),back:n.left>0,on:n.left+n.width<i-1,page:a}},P6=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}.`}}),F6=`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`,I6=({cards:e})=>e>0?(0,R.jsx)(`li`,{"aria-hidden":!0,className:`shrink-0`,style:{width:N6(e)-12}}):null,nbe=({model:e,view:t,display:n,source:r,label:i,isNew:a})=>{let{total:o}=r,s=tbe(o),c=Y4({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,R.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,R.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,R.jsx)(I6,{cards:s.start}),l.map(r=>{let i=c(r);if(!i)return(0,R.jsx)(`li`,{"aria-hidden":!0,className:`shrink-0`,style:{width:256},children:(0,R.jsx)(Uu,{className:`h-full min-h-24 rounded-lg`})},`skeleton-${r}`);let s=rS(e,i);return(0,R.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,R.jsx)(k6,{model:e,view:t,display:n,row:s,swipe:!1,mark:a?.(s)?P6(`new`):void 0})},s.key)}),(0,R.jsx)(I6,{cards:o-s.end})]}),s.back&&(0,R.jsx)(`button`,{type:`button`,"aria-label":P6(`previous`,i.toLowerCase()),onClick:()=>s.page(-1),className:`${F6} -left-3`,children:(0,R.jsx)(Di,{className:`size-4`,"aria-hidden":!0})}),s.on&&(0,R.jsx)(`button`,{type:`button`,"aria-label":P6(`next`,i.toLowerCase()),onClick:()=>s.page(1),className:`${F6} -right-3`,children:(0,R.jsx)(ki,{className:`size-4`,"aria-hidden":!0})})]})},rbe=Un(),ibe=(e,t)=>{if(!t)return e;let n=Yt(e);if(!n.ok)throw Error(`The filter cannot be read: ${n.errors.map(e=>e.message).join(`; `)}`);return Fn(n.ast?rbe.and(n.ast,t):t)},abe=(e,t)=>{let n=zx(e).filter(e=>e.kind===`cards`);return n.find(e=>e.name===t)??n[0]??{kind:`cards`,name:`cards`}},obe=()=>(0,R.jsx)(`div`,{className:`flex gap-3 overflow-hidden`,children:Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-24 w-64 shrink-0`},t))}),L6=({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}=J(),g=Du(),_=abe(t,i),v=r||iS(e,t),y=d3({resources:m,views:h,model:e,columns:(0,I.useMemo)(()=>nS(e,t,[]),[e,t]),filter:(0,I.useMemo)(()=>ibe(n,f),[n,f]),orderBy:v}),b=a6(e,n),x=(t?.names?.singular??K(e.name)).toLowerCase(),S=t?.names?.plural??K(e.name),C=y.source?.total,w=(0,I.useMemo)(()=>y.source&&{...y.source,total:Math.min(y.source.total,a??1/0)},[y.source,a]);return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[o&&b.length>0||C!==void 0||c?(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[o&&b.length>0?(0,R.jsx)(h3,{chips:b}):(0,R.jsx)(`span`,{}),(0,R.jsxs)(`p`,{className:`flex flex-wrap gap-x-3 text-muted-foreground`,children:[c&&(0,R.jsx)(`span`,{children:c}),C!==void 0&&(0,R.jsx)(`span`,{className:`tabular-nums`,children:`${C.toLocaleString(l())} ${C===1?x:S.toLowerCase()}`})]})]}):null,y.isLoading?(0,R.jsx)(obe,{}):y.error?(0,R.jsx)(US,{title:P6(`couldNotLoad`),error:y.error}):!w||w.total===0?(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:s??P6(`noneMatch`,S.toLowerCase())}):(0,R.jsx)(nbe,{model:e,view:t,display:_,source:w,label:S,isNew:u}),(0,R.jsxs)(_S,{to:p3(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,R.jsxs)(R.Fragment,{children:[P6(`viewAll`),` `,(0,R.jsx)(`span`,{className:`sr-only`,children:S.toLowerCase()})]}),(0,R.jsx)(Wr,{className:`size-3.5`,"aria-hidden":!0})]})]})},sbe=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=J(),o=sS(i,a,e.name),s=h6(e.name,t.listOf,!0),c=(t.names?.plural??K(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,R.jsx)(US,{title:P6(`couldNotLoadYour`,c),error:s.error});if(!s.data)return(0,R.jsx)(Uu,{className:`h-24`});let l=p6(o.model,s.data);return l?(0,R.jsx)(L6,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:n??P6(`noneYet`,c)})},cbe=e=>H.list(e,``,``,500,`saved-searches`),R6=(e,t)=>{let n=U(),{resources:r,views:i}=J(),a=r[e];return Ah({queryKey:cbe(e),enabled:t&&a!==void 0,queryFn:async()=>{let t=[],r;do{let o=await n.list(e,{pageSize:500,orderBy:iS(a,i[e]),...r&&{pageToken:r}});t.push(...o.items),r=o.nextPageToken||void 0}while(r);return t}})},z6=({model:e,of:t,target:n,targetView:r,row:i,recordKey:a})=>{let o=U(),s=_T(),c=String(i[t.filter]??``),l=a6(n,c),u=t.name===void 0?void 0:i[t.name],d=typeof u==`string`&&u!==``?u:void 0,f=t.unseen,p=jh({mutationFn:t=>o.update(e.name,a,{[f.seenAt]:t},i.etag??`*`),onSettled:()=>s(e.name)}),m=Ah({...pT(o,n,f?Dye(c,f.field,i[f.seenAt]):``),enabled:f!==void 0}),h=(r?.names?.plural??K(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=>Oye(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??Xve(l),body:g}},lbe=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=ur(px(e,i)),{name:o,chips:s,title:c,body:l}=z6({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,R.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,R.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:(0,R.jsx)(_S,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,R.jsx)(g3,{chips:s})})}),(0,R.jsx)(L6,{...l})]})},ube=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=J(),a=t.searchesOf,o=r[a.resource],s=R6(e.name,!0),c=(t.names?.plural??K(e.name)).toLowerCase();return o?s.error?(0,R.jsx)(US,{title:Q(`couldNotLoadYour`,c),error:s.error}):s.data?s.data.length===0?(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:n??Q(`noneYet`,c)}):(0,R.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,R.jsx)(lbe,{model:e,view:t,target:o,targetView:i[a.resource],row:n},ur(px(e,n))))}):(0,R.jsx)(Uu,{className:`h-40`}):null},dbe=({node:e,slots:t})=>{let{resource:n,filter:r=``,sort:i,limit:a,display:o,title:s,description:c,empty:l}=xT(e),{resources:u,views:d}=J(),f=u[n];if(!f)return null;let p=d[f.name];return(0,R.jsx)(wT,{title:s,description:c,actions:t.actions,children:p?.searchesOf?(0,R.jsx)(ube,{model:f,view:p,empty:l}):p?.listOf===void 0?(0,R.jsx)(L6,{model:f,view:p,filter:r,sort:i,limit:a,display:o,empty:l}):(0,R.jsx)(sbe,{model:f,view:p,limit:a,display:o,empty:l})})},B6=(e,t)=>{let{resources:n}=J(),r=U(),i=JSON.stringify(e),a=(0,I.useMemo)(()=>JSON.parse(i).map(vc),[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=bc(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=vhe(t,l),f=Oh({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 yc(e,t)})},fbe=({node:e,children:t})=>{let{when:n}=xT(e),[r]=B6([n],$w());return r?(0,R.jsx)(R.Fragment,{children:t}):null},V6=`text-2xl font-semibold tracking-tight tabular-nums`,pbe=({model:e,filter:t})=>{let{views:n}=J(),r=mT(e,t);return r.isPending?(0,R.jsx)(Uu,{className:`h-8 w-16`}):r.error?(0,R.jsx)(`span`,{className:`text-danger-text`,children:_g(`couldNotCount`)}):(0,R.jsx)(_S,{to:WT(n[e.name],e.name,t),className:`${V6} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:r.data.toLocaleString(l())})},mbe=({field:e,format:t})=>{let n=Q0($w(),e);return n.state===`loading`?(0,R.jsx)(Uu,{className:`h-8 w-16`}):n.state===`missing`?null:(0,R.jsx)(`span`,{className:V6,children:(0,R.jsx)(J0,{model:n.model,field:n.field,value:n.value,format:t})})},hbe=({node:e})=>{let{label:t,value:n,resource:r,filter:i,field:a,format:o,description:s}=xT(e),{resources:c}=J(),l=r===void 0?void 0:c[r];return(0,R.jsxs)(wT,{className:`relative h-full`,bodyClassName:`flex flex-col`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground break-words`,children:t}),(0,R.jsxs)(`div`,{className:`mt-auto pt-1`,children:[n!==void 0&&(0,R.jsx)(`span`,{className:V6,children:n}),l&&(0,R.jsx)(pbe,{model:l,filter:i}),a!==void 0&&(0,R.jsx)(mbe,{field:a,format:o})]}),s&&(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s})]})},H6=(e,t)=>{let n=e.position;if(!n||!eT(t,`update`))return;let r=e.fields[n.field];return r&&!r.readOnly?n.field:void 0},U6=(e,t)=>e.position?.within===void 0?H6(e,t):void 0,gbe=(e,t,n)=>t.position?.within!==void 0&&e.field===t.position.within&&!e.through&&!e.from&&!e.filter?H6(t,n):void 0,_be=(e,t,n,r)=>{if(t===void 0||e?.list?.drag?.rank!==!0||r!==``)return!1;let i=aS(n);return i.columnId===t&&i.direction===`asc`},W6=e=>e===null?`none`:`value:${e}`,G6=e=>e.data.current?.sortable!==void 0,K6=e=>{let t=Xie(e),n=t.find(e=>e.data?.droppableContainer&&G6(e.data.droppableContainer));return n?[n]:t.length>0?t:F_(e)},vbe=(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=>!G6(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=q6(o,n,d.id)[0];return{x:d.rect.left+(d.rect.width-t.width)/2,y:f?.rect.top??d.rect.top}},q6=(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),ybe=(e,t)=>{let n=e.code===`ArrowDown`?1:e.code===`ArrowUp`?-1:0;if(n===0)return vbe(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=q6(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}},J6=(e,t,n,r)=>{let i=Mh({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=>rS(e,t))),total:a[0]?.total??0,loading:i.isPending,error:i.error,more:i.hasNextPage,loadMore:()=>void i.fetchNextPage()}},bbe=({model:e,by:t,value:n,fields:r,filter:i,orderBy:a})=>{let{resources:o,views:s}=J(),c=d3({resources:o,views:s,model:e,columns:r,filter:Ix(i,t,n),orderBy:a});return J6(e,c.page,c.key,!0)},xbe=(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))]},Sbe=({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=bbe({model:e,by:n.by,value:r.value,fields:i,filter:a,orderBy:o}),m=Lx(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=xbe([...y,...b],x?.order).slice(0,s),{setNodeRef:C,isOver:w}=gy({id:W6(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??K(e.name)).toLowerCase(),D=t?.fields[n.by];return(0,R.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,R.jsxs)(`header`,{className:`flex items-center justify-between gap-2 px-1 pt-0.5`,children:[(0,R.jsx)(`h2`,{className:`min-w-0 truncate text-body font-medium`,children:r.value===null?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:r.label}):(0,R.jsx)(q0,{value:r.value,hints:D,children:r.label})}),!p.loading&&(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:T.toLocaleString(l())})]}),p.loading?Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-20`},t)):p.error?(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:p.error}):S.length===0?(0,R.jsx)(`p`,{className:`px-1 py-4 text-center text-xs text-muted-foreground`,children:q(`noPlural`,E)}):(0,R.jsx)(Ey,{id:W6(r.value),items:S.map(e=>e.key),strategy:Cy,children:(0,R.jsx)(`ul`,{className:`-mb-2 flex flex-col`,children:S.map(n=>(0,R.jsx)(Cbe,{model:e,view:t,card:m,row:n,column:r,rows:S,draggable:(u||d)&&tT(n.record,`update`),placeable:d,dragged:f},n.key))})}),s===void 0&&p.more&&(0,R.jsx)(V,{size:`sm`,variant:`ghost`,onClick:p.loadMore,children:q(`showMore`)})]})},Cbe=({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:_}=Oy({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,R.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,R.jsx)(k6,{model:e,view:t,display:n,row:r,swipe:!1})})},Y6=e=>e.kind===`and`?e.args.flatMap(Y6):[e],X6=e=>e.kind===`string`?String(e.value):void 0,wbe=(e,t)=>{if(e.kind===`compare`&&e.op===`=`&&e.field.path.join(`.`)===t){let t=X6(e.value);return t===void 0?void 0:[t]}if(e.kind===`in`&&e.field.path.join(`.`)===t){let t=e.values.map(X6);return t.every(e=>e!==void 0)?t:void 0}},Tbe=(e,t,n)=>{let r=Yt(e);if(!r.ok||!r.ast)return n;let i=Y6(r.ast).map(e=>wbe(e,t)).filter(e=>e!==void 0);return n.filter(e=>i.every(t=>e.value!==null&&t.includes(e.value)))},Z6=(e,t)=>t!==null&&Object.hasOwn(e,t)?e[t]:void 0,Q6=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.`}}),$6=(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:px(e,r),data:Object.fromEntries(a.map(e=>[e,t[e]])),etag:i}]}),e8=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},t8=(e,t)=>t===void 0?e:`(${e}) AND (${t})`,n8=async(e,t,n,r)=>{let i=t.position?.after;if(!i)return{after:[],before:[]};let a=t.primaryKey[0],o=px(t,r),s=e=>ur([e]),c=await e8(e,i.resource,t8(Fn(Wn.or(Wn.eq(i.field,o),Wn.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([e8(e,t.name,t8(Fn(Wn.in(a,[o,...u])),i.while)),d.length===0?[]:e8(e,t.name,Fn(Wn.in(a,d)))]),m=e=>{let r=ur(px(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):[]}},r8=e=>typeof e==`number`&&Number.isInteger(e),i8=(e,t,n)=>{let r=0;for(;r<t&&r8(e[r])&&(r===0||e[r]>e[r-1]);)r+=1;let i=e.length;for(;i-1>n&&r8(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}},Ebe=(e,t,n)=>{let r=e.findIndex(e=>e.key===t.key);return r===-1?[...e.slice(0,n),t,...e.slice(n)]:yy(e,r,n)},a8=(e,t,n)=>{let r=e.findIndex(e=>e.key===t.key);return{order:Ebe(e,t,n),first:r===-1?n:Math.min(r,n),last:r===-1?n:Math.max(r,n)}},o8=e=>typeof e.record.etag==`string`?e.record.etag:`*`,Dbe=(e,t,n,r,i,a,o,s,c)=>{let l=(r.record[t]??null)!==i.value,u=i8(a.map(e=>e.record[n]),o,s),d=a.slice(u.first,u.last+1),f=e=>l&&e.key===r.key?`*`:o8(e),p=(t,r)=>({op:`reorder`,resource:e.name,field:n,keys:t.map(t=>px(e,t.record)),start:r,etags:Object.fromEntries(t.map(t=>[ur(px(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:px(e,r.record),data:{[t]:i.value},etag:o8(r)},...h]:h},Obe=(e,t,n)=>{let r=new Map(t.map(t=>[ur(px(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(ur(px(e,t)),{record:t,etag:r})}return[...i].flatMap(([e,t])=>{let n=r.get(e);return n?[{before:n,...t}]:[]})},s8=a({en:{dependsOn:(e,t)=>`${e} depends on ${t}.`},nl:{dependsOn:(e,t)=>`${e} hangt af van ${t}.`}}),c8=e=>e!=null&&e!==``,kbe=({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}=a8(n,r,l),f=i.map(e=>e.record[t]),p=i8(f,u,d),m=new Map(i.map((t,n)=>[ur(px(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(ur(px(e,r.record)))),_=a.after.filter(e=>c8(h(e))&&Number(h(e))>=g),v=a.before.find(e=>c8(h(e))&&Number(h(e))<=g),y=v?s8(`dependsOn`,v.title,o):_[0]&&s8(`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=>!c8(h(e))||Number(h(e))>b))return{place:{index:l,bump:b},reason:c}}return{reason:c}},Abe=({model:e,view:t,by:n,rank:r,drop:i,labelOf:a,titleOf:o})=>{let s=U(),c=ub(),l=_T(),[u,d]=(0,I.useState)([]),f=(0,I.useRef)(void 0),p=e=>d(t=>t.filter(t=>t.row.key!==e)),m=r?[n,r]:[n],h=jh({mutationFn:e=>e(),onError:e=>c.show({state:`error`,title:q(`couldNotUndo`),description:Rx(e)}),onSettled:()=>l(e.name)}),g=async(t,r)=>{let a=i&&Z6(i,r.value);if(!a)throw Error(`The column ${r.label} takes no cards`);let o=px(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($6(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 n8(s,e,t,n.record),u=kbe({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?Q6(`notMoved`):Q6(`movedToPlace`,u.place.index+1),description:u.reason}),!d)return u.place.index!==a.index&&v(n,i,a8(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}=a8(a.rows,t,o.index);return _(Obe(e,c,await s.batchWrite(Dbe(e,n,r,t,i,c,l,u,o.bump))),i)},x=jh({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,px(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&&a8(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?q(`orderChanged`):q(`stayedIn`,a(i)):q(`movedTo`,a(i));if(!o){c.show({state:`success`,title:l});return}let u=c.show({state:`success`,title:l,action:{label:q(`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?q(`couldNotReorder`):q(`couldNotMoveTo`,r.label);c.show({state:`error`,title:i,description:Rx(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}})}},l8=(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}},u8=({model:e,view:t,display:n,fields:r,filter:i,orderBy:a,limit:o})=>{let s=Px(e,t,n),c=Tbe(i,n.by,s),l=Lx(e,t,n),u=hS(e.name),{boardDrops:d}=tC(),f=t?.list?.drag,p=typeof f?.board==`string`?f.board:void 0,m=p===void 0?void 0:d?.[p],h=t=>eT(u,`update`)&&(f?.board===!0?!e.fields[n.by]?.readOnly:m!==void 0&&Z6(m,t)!==void 0),g=c.some(e=>h(e.value)),_=Fx(e),v=f?.rank===!0&&_!==void 0&&U6(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}=Abe({model:e,view:t,by:n.by,rank:_,drop:m,labelOf:b,titleOf:x}),[w,T]=(0,I.useState)(),E=(0,I.useRef)(!1),D=T_(w_(bv,{activationConstraint:{distance:4}}),w_(Sv,{activationConstraint:{delay:250,tolerance:5}}),w_(fv,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:ybe}));if(p!==void 0&&!m)return(0,R.jsx)(gg,{children:Xh(q(`noDrop`),p)});let O=e=>c.find(t=>W6(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:q(`noColumn`)};let n=v?l8(t,e):void 0;if(!n)return{over:O(t.id)?.label??q(`noColumn`)};let r=n.rows.some(t=>t.key===e.key)?n.rows.length:n.rows.length+1;return{over:q(`placeOf`,n.column.label,n.index+1,r),place:q(`place`,n.column.label,n.index+1)}},M=(e,t)=>{let n=(v?l8(t,e)?.column:void 0)??O(t.id);return n!==void 0&&n.value!==k(e)&&!A(e,n)};return(0,R.jsxs)(fy,{sensors:D,collisionDetection:K6,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?l8(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})=>q(`pickedUp`,x(e.data.current.row)),onDragOver:({active:e,over:t})=>q(`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 q(`putBack`,x(n));let r=j(n,t);return q(`wasMovedTo`,x(n),r.place??r.over)},onDragCancel:({active:e})=>q(`cancelled`,x(e.data.current.row))},screenReaderInstructions:{draggable:q(v?g?`boardAnywhere`:`boardWithin`:`boardAcross`)}},children:[(0,R.jsx)(`div`,{className:`relative min-w-0 flex-1 overflow-x-auto`,children:(0,R.jsx)(`div`,{className:`flex snap-x items-start gap-3 pb-2`,children:c.map(a=>(0,R.jsx)(Sbe,{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},W6(a.value)))})}),(0,R.jsx)(vy,{children:w&&(0,R.jsx)(k6,{model:e,view:t,display:l,row:w,swipe:!1})})]})},d8=864e5,f8=e=>new Date(e).toISOString().slice(0,10),p8=e=>Date.parse(`${e}T00:00:00Z`),m8=(e,t)=>f8(p8(e)+t*d8),h8=e=>m8(e,-((new Date(p8(e)).getUTCDay()+6)%7)),g8=(e,t=0)=>{let n=new Date(p8(e));return f8(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1))},_8=({scale:e,day:t})=>({scale:e,day:e===`month`?g8(t):h8(t)}),v8=(e,t,n=Ef())=>_8(e??{scale:`month`,day:Mf(t,n)}),y8=(e,t,n=Ef())=>_8({scale:e,day:Mf(t,n)}),b8=(e,t)=>e.scale===`month`?{scale:`month`,day:g8(e.day,t)}:{scale:`week`,day:m8(h8(e.day),7*t)},x8=e=>{let t=h8(e.scale===`month`?g8(e.day):e.day),n=(p8(e.scale===`month`?m8(h8(m8(g8(e.day,1),-1)),6):m8(t,6))-p8(t))/d8+1;return Array.from({length:n},(e,n)=>m8(t,n))},jbe=e=>{let t=x8(e);return{from:t[0],to:m8(t.at(-1),1)}},S8=(e,t)=>t.fields[e.start]?.type===`timestamp`,Mbe=(e,t,n,r=Ef())=>{let i=S8(e,t),a=e=>new Date(Pf(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=Wn.and(Wn.gte(e.start,o(n.from)),Wn.lt(e.start,o(n.to)));if(e.end===void 0)return Fn(s);let c=i?Wn.gt(e.end,o(n.from)):Wn.gte(e.end,o(n.from));return Fn(Wn.or(s,Wn.and(Wn.lt(e.start,o(n.from)),c)))},Nbe=(e,t)=>e===``?t:`(${e}) AND (${t})`,C8=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},w8=(e,t,n,r=Ef())=>{let i=C8(e[t.start]);if(i===void 0)return;let a=S8(t,n),o=e=>a?Mf(e,r):f8(e),s=o(i),c=t.end===void 0?void 0:C8(e[t.end]),l=c===void 0?s:o(a?c-1:c);return{first:s,last:l<s?s:l}},Pbe=(e,t,n,r,i=Ef())=>{let a=w8(e,t,n,i);return a?r.filter(e=>e>=a.first&&e<=a.last):[]},T8=(e,t)=>e.toSorted((e,n)=>(C8(e.record[t.start])??0)-(C8(n.record[t.start])??0)),Fbe=(e,t,n,r,i=Ef())=>{let a=new Map(r.map(e=>[e,[]]));for(let o of T8(e,t))for(let e of Pbe(o.record,t,n,r,i))a.get(e).push(o);return a},Ibe=(e,t,n,r,i,a=Ef())=>{let o=(p8(i)-p8(r))/d8,s=S8(t,n),c=e=>{let t=C8(e);if(t!==void 0)return s?new Date(Nf(t+Af(t,a)+o*d8,a)).toISOString():m8(f8(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}}},E8=({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,R.jsx)(_S,{to:s(e),className:t,"aria-label":n,"aria-current":i?`page`:void 0,children:r}):(0,R.jsx)(`button`,{type:`button`,className:t,"aria-label":n,"aria-pressed":i,onClick:()=>l?.(e),children:r}),d=op({variant:`secondary`,size:`sm`});return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium`,children:e}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u(n,d,q(`previousPeriod`,t),(0,R.jsx)(Di,{className:`size-3.5`})),u(r,d,q(`today`),q(`today`)),u(i,d,q(`nextPeriod`,t),(0,R.jsx)(ki,{className:`size-3.5`}))]}),(0,R.jsx)(`span`,{role:`group`,"aria-label":o,className:c.group(),children:a.map(e=>(0,R.jsx)(I.Fragment,{children:u(e.view,c.option(e.current),e.label,e.label,e.current)},e.label))})]})]})},Lbe=e=>{let t=x8(e),n=e=>Date.parse(`${e}T00:00:00Z`);return e.scale===`month`?qf(n(e.day)):Qf(n(t[0]),n(t.at(-1)))},Rbe=({view:e,now:t,linkTo:n,onView:r})=>{let i=e.scale===`month`&&Mf(t,Ef()).startsWith(e.day.slice(0,7)),a=n=>n===`week`&&i?y8(`week`,t):v8({scale:n,day:e.day},t),o=(t,n)=>({view:a(t),label:n,current:e.scale===t});return(0,R.jsx)(E8,{heading:Lbe(e),unit:e.scale===`month`?`month`:`week`,previous:b8(e,-1),today:y8(e.scale,t),next:b8(e,1),scales:[o(`month`,q(`month`)),o(`week`,q(`week`))],scalesLabel:q(`calendarScale`),linkTo:n,onView:r})},zbe=`day:`,D8=e=>`${zbe}${e}`,Bbe=(e,t)=>`${e}@${t}`,Vbe=(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(D8(m8(o,a)));if(s)return{x:s.left+(s.width-n.width)/2,y:s.top+4}},Hbe=({day:e,count:t,children:n,more:r,inMonth:i,today:a,week:o})=>{let{setNodeRef:s,isOver:c}=gy({id:D8(e)}),l=Date.parse(`${e}T00:00:00Z`);return(0,R.jsxs)(`section`,{ref:s,"aria-label":`${Zf(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,R.jsxs)(`header`,{className:g(`flex items-center gap-1 px-0.5 text-xs`,i?`text-foreground`:`text-muted-foreground`),children:[o&&(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:Xf(l)}),(0,R.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]})},O8=(e,t,n,r)=>{let i=n.title??lx(e,t),a=e.fields[i],o=r.labels[i]??(a?Ox(a,r.record[i],t?.fields[i]):``);return o===``?r.key:o},Ube=(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 Mf(a,Ef())===r?$f(a):void 0},k8=({model:e,view:t,display:n,row:r,day:i,className:a})=>{let o=o6(e),s=Ube(e,n,r,i);return(0,R.jsxs)(_S,{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,R.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:s}),(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:O8(e,t,n,r)})]})},A8=({movable:e,dragged:t,...n})=>{let{setNodeRef:r,setActivatorNodeRef:i,listeners:a,isDragging:o}=my({id:Bbe(n.row.key,n.day),data:{row:n.row,day:n.day},disabled:!e});return(0,R.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,R.jsx)(k8,{...n})})},j8=({model:e,display:t,range:n,fields:r,filter:i})=>{let{resources:a,views:o}=J(),s=d3({resources:a,views:o,model:e,columns:r,filter:Nbe(i,Mbe(t,e,n)),orderBy:`${t.start} asc`}),c=J6(e,s.page,s.key,!0),l=c.more&&!c.loading&&c.rows.length<500;(0,I.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}},M8=(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)},N8=(e,t)=>{let n=U(),r=ub(),i=_T(),[a,o]=(0,I.useState)([]),s=e=>o(t=>t.filter(t=>t.key!==e)),c=jh({mutationFn:({row:t,patch:r})=>{let i=typeof t.record.etag==`string`?t.record.etag:`*`;return n.update(e.name,px(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:q(`couldNotMoveTo`,Uf(Date.parse(`${n}T00:00:00Z`))),description:Rx(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:Ibe(n.record,t,e,r,i),to:i})}},Wbe=3,P8=({model:e,view:t,display:n,fields:r,filter:i,at:a,linkTo:o,now:s=Date.now()})=>{let[c,l]=(0,I.useState)(),u=v8(o?a:c,s),d=x8(u),f=j8({model:e,display:n,range:jbe(u),fields:r,filter:i}),{moves:p,move:m}=N8(e,n),h=Fbe(M8(f.rows,p),n,e,d),_=eT(hS(e.name),`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[v,y]=(0,I.useState)(),b=(0,I.useRef)(!1),x=T_(w_(bv,{activationConstraint:{distance:4}}),w_(Sv,{activationConstraint:{delay:250,tolerance:5}}),w_(fv,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:Vbe})),S=Mf(s,Ef()),C=u.scale===`week`,w=e=>Uf(Date.parse(`${String(e).slice(D8(``).length)}T00:00:00Z`)),T=r=>O8(e,t,n,r.row),E={onDragStart:({active:e})=>q(`pickedUp`,T(e.data.current)),onDragOver:({active:e,over:t})=>q(`isOver`,T(e.data.current),t?w(t.id):q(`noDay`)),onDragEnd:({active:e,over:t})=>t?q(`wasMovedTo`,T(e.data.current),w(t.id)):q(`putBack`,T(e.data.current)),onDragCancel:({active:e})=>q(`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(D8(``).length):void 0;i&&i!==r&&m(n,r,i)},A=(e,t)=>{let n=v8({scale:`week`,day:e},s),r=q(`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,R.jsx)(_S,{to:o(n),className:i,children:r}):(0,R.jsx)(`button`,{type:`button`,className:i,onClick:()=>l(n),children:r})};return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,R.jsx)(Rbe,{view:u,now:s,linkTo:o,onView:l}),f.error&&(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:f.error}),f.capped&&(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:q(`capped`,500,u.scale)}),(0,R.jsxs)(fy,{sensors:x,collisionDetection:K6,onDragStart:O,onDragEnd:k,onDragCancel:D,accessibility:{announcements:E,screenReaderInstructions:{draggable:q(`calendarInstructions`)}},children:[(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[!C&&(0,R.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,R.jsx)(`span`,{className:`bg-surface px-1.5 py-1 text-xs font-medium text-muted-foreground`,children:Xf(Date.parse(`${e}T00:00:00Z`))},e))}),(0,R.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,Wbe);return(0,R.jsx)(Hbe,{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,R.jsx)(Uu,{className:`h-4`}):a.map(i=>(0,R.jsx)(A8,{model:e,view:t,display:n,row:i,day:r,movable:_&&tT(i.record,`update`),dragged:()=>b.current},i.key))},r)})})]}),(0,R.jsx)(vy,{children:v&&(0,R.jsx)(k8,{model:e,view:t,display:n,row:v.row,day:v.day})})]})]})},Gbe=864e5,F8=e=>Date.parse(`${e}T00:00:00Z`),I8=(e,t=0)=>{let n=new Date(F8(e));return new Date(Date.UTC(n.getUTCFullYear(),Math.floor(n.getUTCMonth()/3)*3+3*t,1)).toISOString().slice(0,10)},L8=({scale:e,day:t})=>({scale:e,day:e===`week`?h8(t):e===`month`?g8(t):I8(t)}),R8=(e,t,n=Ef())=>L8(e??{scale:`month`,day:Mf(t,n)}),z8=(e,t)=>{let{scale:n,day:r}=L8(e);return{scale:n,day:n===`week`?m8(r,7*t):n===`month`?g8(r,t):I8(r,t)}},B8=e=>{let t=L8(e).day,n=(F8(z8(e,1).day)-F8(t))/Gbe;return Array.from({length:n},(e,n)=>m8(t,n))},Kbe=e=>({from:L8(e).day,to:z8(e,1).day}),qbe=(e,t,n,r=Ef())=>{let i=Mf(n,r),a=B8(e);return L8({scale:t,day:i>=a[0]&&i<=a.at(-1)?i:a[0]})},Jbe=e=>{let t=B8(e);return e.scale===`week`?Qf(F8(t[0]),F8(t.at(-1))):e.scale===`month`?qf(F8(t[0])):Yf(F8(t[0]),F8(g8(t.at(-1))))},Ybe=e=>{let t=B8(e);if(e.scale===`week`)return t.map((e,t)=>({index:t,span:1,label:`${Xf(F8(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:Jf(F8(t[e]))}))},Xbe=(e,t,n,r,i=Ef())=>{let a=w8(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}},Zbe=`none`,Qbe=(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?Zbe:`value:${String(e)}`,c=n?q(`noValue`,o?.label??K(i)):t.labels[i]??Ox(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)},V8=`grid grid-cols-1 sm:grid-cols-[12rem_minmax(0,1fr)]`,H8=(e,t)=>`${e/t*100}%`,$be=({ticks:e,days:t,today:n,label:r,trackRef:i})=>(0,R.jsxs)(`div`,{className:g(V8,`border-b border-border bg-surface`),children:[(0,R.jsx)(`span`,{className:`hidden truncate px-2 py-1 text-xs font-medium text-muted-foreground sm:block`,children:r}),(0,R.jsx)(`div`,{ref:i,"aria-hidden":!0,className:`relative h-6`,children:e.map(e=>(0,R.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:H8(e.index,t.length),width:H8(e.span,t.length)},children:e.label},e.index))})]}),exe=({ticks:e,days:t,today:n})=>{let r=t.indexOf(n);return(0,R.jsxs)(`div`,{"aria-hidden":!0,className:g(V8,`pointer-events-none absolute inset-0`),children:[(0,R.jsx)(`span`,{className:`hidden sm:block`}),(0,R.jsxs)(`div`,{className:`relative`,children:[r>=0&&(0,R.jsx)(`span`,{className:`absolute inset-y-0 bg-primary/10`,style:{left:H8(r,t.length),width:H8(1,t.length)}}),e.map(e=>(0,R.jsx)(`span`,{className:g(`absolute inset-y-0 w-px bg-border`,(e.minor||e.index===0)&&`hidden sm:block`),style:{left:H8(e.index,t.length)}},e.index))]})]})},txe=({model:e,view:t,display:n,row:r,days:i,movable:a,dragged:o})=>{let s=Xbe(r.record,n,e,i);return(0,R.jsxs)(`div`,{className:g(V8,`relative border-b border-border last:border-b-0`),children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`truncate px-2 pt-1 text-body sm:py-1.5`,children:O8(e,t,n,r)}),(0,R.jsx)(`div`,{className:`relative h-7`,children:s&&(0,R.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2`,style:{left:H8(s.first,i.length),width:H8(s.last-s.first+1,i.length)},children:(0,R.jsx)(A8,{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`)})})})]})},nxe=()=>[{scale:`week`,label:q(`week`)},{scale:`month`,label:q(`month`)},{scale:`quarter`,label:q(`quarter`)}],U8=({model:e,view:t,display:n,fields:r,filter:i,at:a,linkTo:o,now:s=Date.now()})=>{let[c,l]=(0,I.useState)(),u=R8(o?a:c,s),d=B8(u),f=Ybe(u),p=j8({model:e,display:n,range:Kbe(u),fields:r,filter:i}),{moves:m,move:h}=N8(e,n),g=Qbe(T8(M8(p.rows,m),n),e,t,n),_=eT(hS(e.name),`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[v,y]=(0,I.useState)(),b=(0,I.useRef)(!1),x=(0,I.useRef)(0),S=(0,I.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=T_(w_(bv,{activationConstraint:{distance:4}}),w_(Sv,{activationConstraint:{delay:250,tolerance:5}}),w_(fv,{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=Mf(s,Ef()),O=r=>O8(e,t,n,r.row),k=e=>Uf(Date.parse(`${m8(e.day,x.current)}T00:00:00Z`)),A={onDragStart:({active:e})=>q(`pickedUp`,O(e.data.current)),onDragMove:({active:e})=>q(`startsOn`,O(e.data.current),k(e.data.current)),onDragOver:()=>void 0,onDragEnd:({active:e})=>x.current===0?q(`putBack`,O(e.data.current)):q(`wasMovedTo`,O(e.data.current),k(e.data.current)),onDragCancel:({active:e})=>q(`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),ee=({active:t,delta:r})=>{j(),x.current=w(r.x);let{row:i}=t.data.current,a=w8(i.record,n,e);a&&x.current!==0&&h(i,a.first,m8(a.first,x.current))},te=n.group===void 0?t?.names?.plural??K(e.name):t?.fields[n.group]?.label??K(n.group),ne=!p.loading&&!p.error&&p.rows.length===0;return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,R.jsx)(E8,{heading:Jbe(u),unit:u.scale,previous:z8(u,-1),today:R8({scale:u.scale,day:D},s),next:z8(u,1),scales:nxe().map(({scale:e,label:t})=>({view:qbe(u,e,s),label:t,current:u.scale===e})),scalesLabel:q(`timelineScale`),linkTo:o,onView:l}),p.error&&(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:p.error}),p.capped&&(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:q(`capped`,500,u.scale)}),(0,R.jsxs)(fy,{sensors:E,modifiers:[T],onDragStart:M,onDragMove:N,onDragEnd:ee,onDragCancel:j,accessibility:{announcements:A,screenReaderInstructions:{draggable:q(`timelineInstructions`)}},children:[(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[(0,R.jsx)($be,{ticks:f,days:d,today:D,label:te,trackRef:S}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(exe,{ticks:f,days:d,today:D}),p.loading&&(0,R.jsxs)(`div`,{className:`relative flex flex-col gap-2 p-2`,children:[(0,R.jsx)(Uu,{className:`h-4`}),(0,R.jsx)(Uu,{className:`h-4`})]}),ne&&(0,R.jsx)(`p`,{className:`relative px-2 py-3 text-xs text-muted-foreground`,children:q(`nothingIn`,u.scale)}),!p.loading&&g.map(r=>(0,R.jsxs)(`section`,{"aria-label":r.label,className:`relative border-b border-border last:border-b-0`,children:[r.label!==void 0&&(0,R.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,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:r.rows.length})]}),r.rows.map(r=>(0,R.jsx)(txe,{model:e,view:t,display:n,row:r,days:d,movable:_&&tT(r.record,`update`),dragged:()=>b.current},r.key))]},r.key))]})]}),(0,R.jsx)(vy,{children:v&&(0,R.jsx)(k8,{model:e,view:t,display:n,row:v.row,day:v.day})})]})]})},rxe=({list:e,empty:t,loading:n,children:r})=>(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.loading?n:e.error?(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:e.error}):e.rows.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:t}):r}),ixe=({list:e})=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[e.rows.length.toLocaleString(l()),` of `,e.total.toLocaleString(l())]}),e.more&&(0,R.jsx)(V,{size:`sm`,onClick:e.loadMore,children:q(`showMore`)})]}),W8=`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,axe=`relative flex snap-x snap-mandatory gap-3 overflow-x-auto pb-1`,oxe=({model:e,view:t,display:n,list:r,row:i=!1,footer:a=!0})=>{let o=(t?.names?.plural??K(e.name)).toLowerCase();return(0,R.jsxs)(rxe,{list:r,empty:q(`noneMatch`,o),loading:(0,R.jsx)(`div`,{className:W8,children:Array.from({length:6},(e,t)=>(0,R.jsx)(Uu,{className:`h-24`},t))}),children:[(0,R.jsx)(`ul`,{className:i?axe:W8,"aria-label":t?.names?.plural??K(e.name),children:r.rows.map(r=>(0,R.jsx)(`li`,{className:g(i&&`w-64 shrink-0 snap-start`),children:(0,R.jsx)(k6,{model:e,view:t,display:n,row:r,swipe:!i})},r.key))}),a&&(0,R.jsx)(ixe,{list:r})]})},G8=(0,I.createContext)(void 0),sxe=({value:e,children:t})=>(0,R.jsx)(G8.Provider,{value:e,children:t}),cxe=()=>{let e=(0,I.useContext)(G8);if(!e)throw Error(`useListDisplay is used inside a list display, which the list page draws`);return e},lxe=()=>(0,I.useContext)(G8),K8=({display:e,list:t})=>{let{components:n}=tC(),r=n?.[e.component];return r?(0,R.jsx)(sxe,{value:t,children:(0,R.jsx)(`div`,{className:`relative min-w-0 flex-1 overflow-x-auto`,children:(0,R.jsx)(vg,{name:e.component,children:(0,R.jsx)(r,{...Zn(e.props??{})})})})}):(0,R.jsx)(gg,{children:Xh(q(`noComponent`),e.component)})},q8=Un(),uxe={bounds:{south:-90,west:-180,north:90,east:180},zoom:0},dxe=22,J8=e=>Math.floor(e*1e6)/1e6,Y8=e=>Math.ceil(e*1e6)/1e6,X8=e=>((e+180)%360+360)%360-180,fxe=(e,t)=>{let n=[q8.gte(e.latitude,J8(Math.max(t.south,-90))),q8.lte(e.latitude,Y8(Math.min(t.north,90)))];if(t.east-t.west>=360)return q8.and(...n);let r=q8.gte(e.longitude,J8(X8(t.west))),i=q8.lte(e.longitude,Y8(X8(t.east)));return X8(t.west)<=X8(t.east)?q8.and(...n,r,i):q8.and(...n,q8.or(r,i))},pxe=(e,t,n)=>{let r=Fn(fxe(t,n));return e.trim()===``?r:`(${e}) AND ${r}`},mxe=e=>Math.min(Math.max(Math.floor(e),0),dxe),hxe=(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))}},Z8=e=>{if(typeof e==`number`)return e;if(typeof e==`string`&&e.trim()!==``)return Number(e)},Q8=(e,t)=>{let n=Z8(e[t.latitude]),r=Z8(e[t.longitude]);if(n!==void 0&&r!==void 0&&Math.abs(n)<=90&&Math.abs(r)<=180)return{latitude:n,longitude:r}},gxe=6371008.8,$8=64,e5=(e,t)=>t.approximate===void 0?t.exact!==void 0&&e[t.exact]===!1:e[t.approximate]===!0,t5=(e,t)=>{let n=t/gxe,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%$8/$8*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,n5=(e,t)=>Array.isArray(e)&&e.length>=t&&e.every(_xe),r5=e=>Array.isArray(e)&&e.length>0&&e.every(e=>n5(e,4)),vxe=e=>Array.isArray(e)&&e.length>0&&e.every(e=>n5(e,2)),yxe=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch(e){if(e instanceof SyntaxError)return;throw e}},bxe=e=>{let t=yxe(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`&&r5(i)||r===`MultiPolygon`&&Array.isArray(i)&&i.length>0&&i.every(r5)||r===`LineString`&&n5(i,2)||r===`MultiLineString`&&vxe(i))return{type:r,coordinates:i}},xxe=(e,t,n)=>{if(!e5(e,t))return;let r=t.area===void 0?void 0:bxe(e[t.area]);if(r)return r;let i=t.radius===void 0?void 0:Z8(e[t.radius]);return i!==void 0&&Number.isFinite(i)&&i>0?t5(n,i):t.defaultRadius===void 0?void 0:t5(n,t.defaultRadius)},i5=(e,t)=>e.flatMap(e=>{let n=Q8(e.record,t);if(!n)return[];if(!e5(e.record,t))return[{key:e.key,...n}];let r=xxe(e.record,t,n);return[{key:e.key,...n,approximate:!0,...r&&{area:r}}]}),Sxe=(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}))},Cxe=(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)}},a5=(e,t)=>({keys:e.keys,index:((e.index+t)%e.keys.length+e.keys.length)%e.keys.length}),wxe=({model:e,view:t,display:n,fields:r,filter:i,orderBy:a,area:o})=>{let s=U(),{resources:c,views:l}=J(),u={latitude:n.latitude,longitude:n.longitude},d=o?pxe(i,u,o.bounds):``,f=o?mxe(o.zoom):0;return Ah({queryKey:H.map(e.name,`${u.latitude},${u.longitude}`,f,d,a),enabled:o!==void 0,placeholderData:qm,queryFn:async()=>{let n=await s.map(e.name,{...u,zoom:f,filter:d,orderBy:a,labels:W0(c,l,e,r),photos:jx(t)});return{rows:G0(c,e,r,Mx(e,n.items,n.photos),n.labels).map(t=>rS(e,t)),buckets:n.buckets,total:n.totalSize}}})},Txe=(0,I.lazy)(()=>m(()=>import(`./records-map-B0KTc5ES.js`).then(e=>({default:e.RecordsMap})),__vite__mapDeps([5,1,2,6,7,8,3,4,9]))),Exe=250,o5=`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`,s5=({model:e,view:t,display:n,filter:r,orderBy:i,fields:a,at:o,onMove:s,footer:c=!0,flush:u=!1})=>{let d=J().maps,f=d?.style,[p,m]=(0,I.useState)(),[h,_]=(0,I.useState)(),v=M3(h,Exe),[y,b]=(0,I.useState)(o===void 0),x=wxe({model:e,view:t,display:n,fields:a,filter:r,orderBy:i,area:y?uxe:v}),S=x.isPlaceholderData?void 0:x.data,C=x.data?.rows??[],w=x.data?.buckets??[],T=i5(C,n),E=y&&S?hxe(i5(S.rows,n),S.buckets):void 0,D=eS(t,n),O=(t?.names?.plural??K(e.name)).toLowerCase(),k=(t?.names?.singular??K(e.name)).toLowerCase(),A=Cxe(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?q(t===1?`showOneApproximate`:`showOne`,k):t===0?q(`showMany`,e.length,O):t===e.length?q(`showManyApproximate`,e.length,O):q(`showManySomeApproximate`,e.length,O,t)},ee=e=>q(`zoomIn`,e.toLocaleString(l()),e===1?k:O),te=(0,I.useRef)(null),[ne,re]=(0,I.useState)(0);if((0,I.useLayoutEffect)(()=>re(te.current?.offsetHeight??0),[j?.key]),!f)return(0,R.jsx)(gg,{children:q(`needsStyle`)});let ie=S?.total===0;return(0,R.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,R.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,R.jsx)(I.Suspense,{fallback:null,children:(0,R.jsx)(Txe,{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?ne:0,onSelect:e=>m({keys:e,index:0}),onClear:()=>m(void 0),markerLabel:N,bucketLabel:ee})}),x.error&&(0,R.jsx)(`div`,{className:`absolute inset-x-3 top-3 z-10`,children:(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:x.error})}),ie&&(0,R.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-10 flex justify-center`,children:(0,R.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:[q(y?`noneMatch`:`noneHere`,O),!y&&(0,R.jsx)(V,{size:`sm`,onClick:()=>b(!0),children:q(`showAll`)})]})}),A&&j&&(0,R.jsx)(`div`,{ref:te,className:`pointer-events-none absolute inset-x-3 bottom-3 z-10 flex justify-center`,children:(0,R.jsxs)(`div`,{className:`pointer-events-auto flex w-full max-w-[16rem] flex-col gap-2 sm:max-w-xs`,role:`group`,"aria-label":q(`chosen`,k),children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[M.has(j.key)&&(0,R.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,R.jsx)(Bee,{className:`size-3.5`,"aria-hidden":!0}),q(`approximatePosition`)]}),A.keys.length>1&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":q(`previous`),className:o5,onClick:()=>m(a5(A,-1)),children:(0,R.jsx)(Di,{className:`size-4`,"aria-hidden":!0})}),(0,R.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,R.jsx)(`button`,{type:`button`,"aria-label":q(`next`),className:o5,onClick:()=>m(a5(A,1)),children:(0,R.jsx)(ki,{className:`size-4`,"aria-hidden":!0})})]}),(0,R.jsx)(`button`,{type:`button`,"aria-label":q(`close`),className:o5,onClick:()=>m(void 0),children:(0,R.jsx)(ds,{className:`size-4`,"aria-hidden":!0})})]}),(0,R.jsx)(`div`,{className:`shadow-lg`,children:(0,R.jsx)(k6,{model:e,view:t,display:D,row:j})})]})})]}),c&&(0,R.jsx)(`p`,{className:`hidden py-3 text-xs text-muted-foreground md:block`,children:Dxe(x.data,O)})]})},Dxe=(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`},c5=({value:e,options:t,onChange:n,label:r})=>{let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null),s=(0,I.useRef)(null),c=(0,I.useRef)([]),l=t.findIndex(t=>t.value===e),u=t[l];(0,I.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,R.jsxs)(`div`,{ref:o,className:`relative shrink-0`,children:[(0,R.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,R.jsx)(u.icon,{className:`size-3.5`}),u?.label??r,(0,R.jsx)(Ti,{className:`size-3.5 text-muted-foreground`})]}),i&&(0,R.jsx)(`ul`,{role:`menu`,"aria-label":r,onKeyDown:e=>{if(e.key===`Escape`)return d();if(e.key===`Tab`)return a(!1);let n=j3(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,R.jsx)(`li`,{role:`none`,children:(0,R.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,R.jsx)(t.icon,{className:`size-3.5`}):(0,R.jsx)(`span`,{className:`size-3.5`}),(0,R.jsx)(`span`,{className:`flex-1`,children:t.label}),t.value===e&&(0,R.jsx)(Ci,{className:`size-3.5 text-primary-text`})]})},t.value))})]})},Oxe={table:Wo,cards:va,kanban:Io,board:Uee,list:Ta,calendar:vi,timeline:Lee,map:Fa},l5=({view:e,value:t,onChange:n,menu:r=!1,choices:i=Jx(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:Oxe[e.icon]}));return r?(0,R.jsx)(c5,{label:q(`display`),value:t,onChange:n,options:a}):(0,R.jsx)(f,{label:q(`display`),size:`md`,value:t,onChange:n,options:a})},kxe=[[`asc`,`ascending`],[`desc`,`descending`]],u5=({model:e,view:t,display:n,orderBy:r,onChange:i,className:a})=>{let o=aS(r),s=Pae(e,t,n),c=s.includes(o.columnId)?s:[o.columnId,...s],l=e=>t?.fields[e]?.label??K(e);return(0,R.jsx)(`select`,{"aria-label":q(`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=>kxe.map(([t,n])=>(0,R.jsxs)(`option`,{value:`${e} ${t}`,children:[l(e),`, `,q(n)]},`${e} ${t}`)))})},d5=(e,t,n,r)=>e.map(e=>{let i=t.fields[e.id],a=i&&nC(r,i,n?.fields[e.id]);return a?{...e,render:t=>(0,R.jsx)(iC,{shown:a,part:`cell`,field:i,value:t[e.id],fallback:N4(e,e.value?e.value(t):t[e.id])})}:e}),f5=e=>e.includes(`.`),Axe=({model:e,row:t,column:n})=>{let r=Q0(fT(e,rS(e,t).record),n);return r.state===`loading`?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`…`}):r.state===`missing`?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,R.jsx)(J0,{model:r.model,field:r.field,value:r.value})},jxe=(e,t,{resources:n,views:r})=>{let i=xc(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??K(o),kind:`text`,width:200,render:n=>(0,R.jsx)(Axe,{model:e,row:n,column:t})}},p5=(e,t,n,r)=>{let i=new Map(d5(Ex(e,t,[],n.filter(e=>!f5(e))),e,t,r.fieldTypes).map(e=>[e.id,e]));return n.flatMap(t=>f5(t)?[jxe(e,t,r)]:i.get(t)??[])},m5=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.`}}),h5=(e,t,n)=>{if(!(e>=t))return m5(n?`firstOfAbout`:`firstOf`,e,t.toLocaleString(l()))},g5=(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},Mxe=(e,t,n)=>{if(e.open!==void 0)return e.open!==e.field&&g5(t,e.open,n)?e.open:void 0;let r=t.primaryKey.filter(r=>r!==e.field&&r!==t.tenant&&g5(t,r,n));return r.length===1?r[0]:void 0},_5=(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},v5=(e,t)=>(t?.names?.singular??K(e.name)).toLowerCase(),Nxe=({model:e,view:t,opens:n,resources:r,views:i,canUpdate:a})=>{let o=t=>({kind:`record`,resource:e.name,key:px(e,t)}),s=n&&e.fields[n]?.relation?.resource,c=s?r[s]:void 0,l=e=>{let t=n&&c?_5(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=v5(e,t);return{address:u,actions:t=>{let n={label:m5(`open`,d),link:e=>t(o(e))};if(!c)return[n];let r=e=>a&&tT(e,`update`);return[{label:m5(`open`,v5(c,i[c.name])),available:e=>l(e)!==void 0,link:e=>t(l(e))},{label:m5(`edit`,d),available:r,link:n=>t({kind:`record`,resource:e.name,key:px(e,n),edit:!0})},{...n,available:e=>!r(e)}]}}},Pxe=({model:e,filter:t,orderBy:n,limit:r,fields:i})=>{let a=U(),{resources:o,views:s}=J();return Ah({queryKey:[...H.list(e.name,t,n,r,`embedded`),i.join(`,`)],placeholderData:qm,queryFn:async()=>{let c=W0(o,s,e,i),l=jx(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=G0(o,e,i,Mx(e,u.items,u.photos),u.labels).map((t,n)=>({...t,id:fx(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}}})},y5=({view:e,value:t,onChange:n})=>(0,R.jsx)(l5,{view:e,value:t,onChange:n,menu:!Eu()}),Fxe=()=>(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-4 w-full`},t))}),b5=({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}=J(),m=eT(hS(e.name),`update`),{fields:h}=tC(),{go:g,href:_}=gS(),v=Du(),[y,b]=(0,I.useState)(r||iS(e,t)),x=i??Tx(e,t),S=(0,I.useMemo)(()=>p5(e,t,x,{resources:f,views:p,fieldTypes:h}),[e,t,x.join(`,`),f,p,h]),C=(0,I.useMemo)(()=>nS(e,t,S.map(e=>e.id)),[e,t,S]),w=Pxe({model:e,filter:n,orderBy:y,limit:a,fields:C}),T=w.data?.rows,E=(0,I.useMemo)(()=>T&&{total:T.length,rowAt:e=>T[e]},[T]),D=Kx(t,o),O=t?.names?.plural??K(e.name),k=u&&(0,R.jsxs)(_S,{to:p3(e,t,v,l?{filter:l.filter,orderBy:iS(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,R.jsxs)(R.Fragment,{children:[m5(`viewAll`),` `,(0,R.jsx)(`span`,{className:`sr-only`,children:O.toLowerCase()})]}),(0,R.jsx)(Wr,{className:`size-3.5`,"aria-hidden":!0})]});if(w.isPending)return(0,R.jsx)(Fxe,{});if(w.error)return(0,R.jsx)(US,{title:m5(`couldNotLoad`),error:w.error});if(!E||E.total===0){let e=(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:s??m5(`nothingYet`)});return l&&u?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,k]}):e}let A={resource:e.name,rows:w.data.rows.map(t=>rS(e,t)),total:w.data.total,loading:!1,error:null,more:!1,loadMore:()=>void 0},j=Nxe({model:e,view:t,opens:d,resources:f,views:p,canUpdate:m}),M=e=>({href:_(e),onFollow:()=>g(e)}),N=h5(E.total,w.data.total,w.data.estimated);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[D?D.kind===`cards`?(0,R.jsx)(oxe,{model:e,view:t,display:D,list:A,row:c||v,footer:!1}):D.kind===`map`?(0,R.jsx)(s5,{model:e,view:t,display:D,filter:n,orderBy:y,fields:C,footer:!1}):D.kind===`board`?(0,R.jsx)(u8,{model:e,view:t,display:D,fields:C,filter:n,orderBy:y,limit:a}):D.kind===`calendar`?(0,R.jsx)(P8,{model:e,view:t,display:D,fields:C,filter:n}):D.kind===`timeline`?(0,R.jsx)(U8,{model:e,view:t,display:D,fields:C,filter:n}):(0,R.jsx)(K8,{display:D,list:A}):(0,R.jsx)(o3,{fit:!0,columns:S,source:E,latencyMs:0,sort:aS(y),onSortChange:e=>b(oS(e)),onOpenRow:e=>g(j.address(e)),rowLink:e=>M(j.address(e)),rowActions:j.actions(M),rowNumbers:!1,selectable:!1}),N&&u?(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:N}),k]}):k]})},x5=(e,t,n)=>{let r=Du(),i=qve(t),[a,o]=(0,I.useState)(()=>Jve(localStorage,i)),s=(0,I.useCallback)(e=>{o(e),Yve(localStorage,i,e)},[i]);return[f3(e,r,{picked:a,preferred:n}),s]},Ixe=({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]=x5(t,`page:${e.name}:${s??``}:${n}`,o);return(0,R.jsx)(wT,{title:s,description:c,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(y5,{view:t,value:d,onChange:f}),u]}),className:`h-full`,children:(0,R.jsx)(b5,{model:e,view:t,filter:n,sort:r,columns:i,limit:a,display:d,empty:l})})},Lxe=({node:e,slots:t})=>{let n=xT(e),{resources:r,views:i}=J(),a=r[n.resource];return a?(0,R.jsx)(Ixe,{...n,model:a,view:i[a.name],actions:t.actions}):null},S5=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: {}`}}),C5=({link:e})=>e?(0,R.jsx)(`p`,{className:`mt-3 break-all rounded-md border bg-muted px-3 py-2 text-xs`,children:Xh(S5(`passLinkOn`),(0,R.jsx)(`span`,{className:`font-mono`,children:e}))}):null,w5=({title:e,description:t,onInvite:n,beside:r,children:i,incomplete:a=!1})=>{let[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(),{busy:u,error:d,run:f}=dg(),p=()=>f(async()=>{l((await n(o.trim())).link),s(``)});return(0,R.jsxs)(cp,{title:e,description:t,children:[(0,R.jsx)(lp,{message:d}),(0,R.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,R.jsx)(Rd,{"aria-label":S5(`email`),type:`email`,placeholder:`name@example.com`,value:o,onChange:e=>s(e.target.value),wrapperClassName:`flex-1`}),r,(0,R.jsx)(V,{type:`submit`,variant:`primary`,loading:u,disabled:!o.trim()||a,children:S5(`invite`)})]}),i]}),(0,R.jsx)(C5,{link:c})]})},T5=({email:e,gives:t,expiresAt:n,onResend:r,onRevoke:i})=>{let[a,o]=(0,I.useState)(),{busy:s,error:c,run:u}=dg(),d=new Date(n).getTime()<Date.now();return(0,R.jsxs)(`li`,{className:`px-3 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium`,children:e}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t,` · `,d?S5(`expired`):S5(`until`,new Date(n).toLocaleDateString(l()))]})]}),(0,R.jsx)(V,{size:`sm`,loading:s,onClick:()=>void u(async()=>o((await r()).link)),children:S5(`sendAgain`)}),(0,R.jsx)(V,{size:`sm`,variant:`danger`,loading:s,onClick:()=>void u(i),children:S5(`revoke`)})]}),(0,R.jsx)(lp,{message:c}),(0,R.jsx)(C5,{link:a})]})},E5=({roles:e,selected:t,grantable:n,disabled:r,onChange:i})=>(0,R.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,R.jsxs)(`label`,{title:o&&!r?G(`cannotChangeRole`):void 0,className:g(`inline-flex items-center gap-1.5`,o&&`text-muted-foreground`),children:[(0,R.jsx)(tg,{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)})}),Rxe=(e,t)=>t.map(t=>cg(e,t)).join(`, `),D5=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`}}),zxe=({roles:e})=>{let{session:t}=B(),[n,r]=(0,I.useState)([]),[i,a]=(0,I.useState)([]),o=(0,I.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,I.useEffect)(o,[o]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(w5,{title:D5(`inviteSomeone`),description:D5(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,R.jsx)(E5,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,R.jsx)(cp,{title:D5(`notAcceptedYet`),description:i.length>0?D5(`sendingAgain`):D5(`nobodyWaiting`),children:i.length>0&&(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,R.jsx)(T5,{email:n.email,gives:Rxe(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))})})]})},Bxe=({roles:e,onCreated:t})=>{let{session:n}=B(),[r,i]=(0,I.useState)(``),[a,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)([]),{busy:d,error:f,run:p}=dg(),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,R.jsxs)(cp,{title:D5(`addAnAccount`),description:D5(`addDescription`),children:[(0,R.jsx)(lp,{message:f}),(0,R.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,R.jsx)(Rd,{"aria-label":D5(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,R.jsx)(Rd,{"aria-label":D5(`name`),placeholder:D5(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,R.jsx)(Rd,{"aria-label":D5(`password`),type:`password`,autoComplete:`new-password`,placeholder:D5(`passwordOptional`,12),value:s,onChange:e=>c(e.target.value)}),(0,R.jsx)(E5,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,R.jsx)(`div`,{children:(0,R.jsx)(V,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:D5(`addAccount`)})})]})]})},Vxe=a({en:{showMore:`Show more`},nl:{showMore:`Meer tonen`}}),O5=({title:e,description:t,searchLabel:n,placeholder:r,query:i,onQuery:a,list:o,error:s,renderRow:c})=>(0,R.jsxs)(cp,{title:e,description:t,children:[(0,R.jsx)(lp,{message:s}),(0,R.jsx)(Rd,{"aria-label":n,placeholder:r,value:i,onChange:e=>a(e.target.value),leading:(0,R.jsx)(vo,{className:`size-3.5`}),wrapperClassName:`mb-2`}),(0,R.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[o.found.length,` of `,o.total]}),o.found.length>0&&(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:o.found.map(c)}),o.found.length<o.total&&(0,R.jsx)(V,{className:`mt-3`,loading:o.loading,onClick:()=>void o.more(),children:Vxe(`showMore`)})]}),k5=(e,t)=>{let[n,r]=(0,I.useState)([]),[i,a]=(0,I.useState)(0),[o,s]=(0,I.useState)(!1),c=(0,I.useRef)(t);return c.current=t,(0,I.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}},A5=({name:e,email:t,self:n,actions:r,children:i,error:a})=>(0,R.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`span`,{className:`block truncate font-medium`,children:[e,n&&` (you)`]}),(0,R.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t})]}),r]}),i,(0,R.jsx)(lp,{message:a})]}),Hxe=({user:e,roles:t,self:n})=>{let{session:r}=B(),[i,a]=(0,I.useState)(e),{busy:o,error:s,run:c,setError:l}=dg(),u=e=>{if(e.length===0)return l(D5(`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,R.jsx)(A5,{name:i.name,email:i.email,self:n,error:s,actions:(0,R.jsxs)(R.Fragment,{children:[i.blocked&&(0,R.jsx)(dd,{tone:`red`,children:D5(`blocked`)}),!n&&(i.blocked?(0,R.jsx)(V,{size:`sm`,loading:o,onClick:()=>d(!1),children:D5(`unblock`)}):(0,R.jsx)(V,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:D5(`block`)}))]}),children:(0,R.jsx)(E5,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},Uxe=({roles:e,version:t})=>{let{session:n,state:r}=B(),[i,a]=(0,I.useState)(``),o=k5((0,I.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,R.jsx)(O5,{title:D5(`people`),description:D5(`peopleDescription`),searchLabel:D5(`findSomeone`),placeholder:D5(`emailAddress`),query:i,onQuery:a,list:o,renderRow:n=>(0,R.jsx)(Hxe,{user:n,roles:e,self:n.id===s},`${t}/${n.id}`)})},Wxe=()=>{let{session:e}=B(),[t,n]=(0,I.useState)([]),[r,i]=(0,I.useState)();return(0,I.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof Dc?ef(e):D5(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},Gxe={Page:jhe,Grid:whe,Card:ET,Stat:hbe,RecordCard:Phe,Field:yhe,Table:Lxe,CardRow:OT,RecordRow:dbe,Chart:mhe,Progress:Mhe,ModalForm:Ahe,Action:CT,Show:fbe,Link:The,Users:()=>{let{roles:e,error:t}=Wxe(),[n,r]=(0,I.useState)(0);return(0,R.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,R.jsx)(lp,{message:t}),(0,R.jsx)(Uxe,{roles:e,version:n}),(0,R.jsx)(zxe,{roles:e}),(0,R.jsx)(Bxe,{roles:e,onCreated:()=>r(e=>e+1)})]})}},j5=e=>typeof e==`string`||!e.custom&&e.type===`Link`,M5=e=>{let t=[];for(let n of e){let e=t.at(-1);j5(n)&&e&&j5(e[0])?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return j5(n)?(0,R.jsx)(`p`,{className:`leading-6`,children:e.map((e,t)=>typeof e==`string`?(0,R.jsx)(I.Fragment,{children:e},t):(0,R.jsx)(N5,{node:e},t))},t):(0,R.jsx)(N5,{node:n},t)})},Kxe=e=>mc(e)||Array.isArray(e)&&e.length>0&&e.every(mc),qxe=e=>Object.fromEntries(Object.entries(e.props).flatMap(([e,t])=>Kxe(t)?[[e,(0,R.jsx)(R.Fragment,{children:M5(Array.isArray(t)?t:[t])})]]:[])),N5=({node:e})=>{let{components:t}=tC();if(e.custom){let n=t?.[e.type];return n?(0,R.jsx)(vg,{name:e.type,children:(0,R.jsx)(n,{...Zn(e.props),children:e.children.length>0?M5(e.children):void 0})}):(0,R.jsx)(gg,{children:Xh(_g(`noComponent`),e.type)})}let n=Gxe[e.type];return n?(0,R.jsx)(n,{node:e,slots:qxe(e),children:M5(e.children)}):(0,R.jsx)(gg,{children:Xh(_g(`unknownBlock`),e.type)})},P5=({name:e})=>{let t=J().pages[e];return t?(0,R.jsx)(N5,{node:t.tree}):(0,R.jsx)(mS,{title:_g(`notFound`),children:Xh(_g(`noPage`),e)})},F5=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.`}}),Jxe=2e3,I5=(e,t)=>{let n=ub(),[r,i]=(0,I.useState)(`idle`),[a,o]=(0,I.useState)(),s=(0,I.useRef)(void 0);return(0,I.useEffect)(()=>()=>clearTimeout(s.current),[]),{phase:r,message:a,run:async r=>{let a=e===`toast`?n.show({state:`loading`,title:F5(`savingSubject`,t)}):void 0;o(void 0),e===`button`&&i(`saving`);try{return await r(),a!==void 0&&n.update(a,{state:`success`,title:F5(`subjectSaved`,t)}),e===`button`&&(i(`saved`),s.current=setTimeout(()=>i(`idle`),Jxe)),!0}catch(t){if(!Ys(t))throw t;let r=t.status===412?F5(`changedBySomeoneElse`):F5(`couldNotSave`),s=Noe(t);return a!==void 0&&n.update(a,{state:`error`,title:r,description:s}),e===`button`&&(i(`idle`),o(`${r}: ${s}`)),!1}}}},L5=({title:e,eyebrow:t,submit:n,saving:r,disabled:i,error:a,errorTitle:o=FS(`notSaved`),onSubmit:s,onCancel:c,children:l,ref:u})=>{let d=(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c&&(0,R.jsx)(V,{className:`max-sm:min-h-11`,onClick:c,children:FS(`cancel`)}),(0,R.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,R.jsx)(`div`,{className:`mt-4`,children:(0,R.jsx)(US,{title:o,error:a})}),p=(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:l}),m=e=>{e.preventDefault(),s()};return e===void 0?(0,R.jsxs)(`form`,{ref:u,className:`max-w-[760px]`,onSubmit:m,children:[f,p,(0,R.jsx)(`footer`,{className:`border-t pt-6 sm:flex sm:justify-end`,children:d})]}):(0,R.jsx)(`form`,{ref:u,className:`flex-1`,onSubmit:m,children:(0,R.jsxs)(`div`,{className:`mx-auto max-w-[760px] px-4 py-6 md:px-10 md:py-8`,children:[(0,R.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,R.jsxs)(`div`,{children:[t&&(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),(0,R.jsx)(`h1`,{className:`mt-1 text-2xl font-semibold tracking-tight`,children:e})]}),d]}),f,p]})})},Yxe=({noun:e,collection:t,sections:n,saving:r,message:i,onSubmit:a,onCancel:o,ref:s})=>(0,R.jsx)(L5,{ref:s,title:FS(`title`,e),eyebrow:t,submit:FS(`submit`,e),saving:r,error:i?Error(i):void 0,errorTitle:FS(`notCreated`),onSubmit:a,onCancel:o,children:n.map(e=>(0,R.jsx)(mb,{title:e.title,help:e.help,children:(0,R.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:e.fields.map(e=>(0,R.jsx)(pb,{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))}),Xxe=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Zxe=({resource:e,values:t})=>{let n=J(),r=n.resources[e],i=hS(e);return r?eT(i,`create`)?(0,R.jsx)(Qxe,{resource:e,values:t}):(0,R.jsx)(mS,{title:FS(`notAllowed`),children:FS(`cannotCreate`,n.views[e]?.names?.plural.toLowerCase()??e)}):(0,R.jsx)(mS,{title:W(`notFound`),children:W(`noResource`,e)})},Qxe=({resource:e,values:t})=>{let n=J(),r=n.resources[e],i=n.views[e],a=U(),o=Om(),{go:s}=gS(),c=i?.names?.singular??K(e),l=I5(i?.saveFeedback??`toast`,FS(`subject`,c)),u=$ae(r,i),[d,f]=(0,I.useState)(()=>BS(r,u,t)),[p,m]=(0,I.useState)({}),[h,g]=(0,I.useState)(0),_=pC(h);(0,I.useEffect)(()=>{for(let[e,i]of Object.entries(t??{})){let t=n.resources[r.fields[e]?.relation?.resource??``];t&&H0(o,a,t,[i],n.views[t.name]).then(t=>{let n=t.get(i);n&&f(t=>IS(t[e])&&t[e].key===i?{...t,[e]:{key:i,label:n}}:t)})}},[t,n,r,a,o]);let v=(e,t)=>{m(t=>Xxe(t,e)),f(n=>({...n,[e]:t}))},y=()=>l.run(async()=>{let t;try{t=await a.create(e,RS(r,n.resources,d))}catch(e){let t=fC(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:px(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??K(e),c=p[e];return{name:e,label:s,help:i?.fields[e]?.help,required:zS(t),error:c&&dC(t,s,c),wide:!!(i?.fields[e]?.multiline||i?.fields[e]?.markdown),editor:(0,R.jsx)(cC,{field:t,hints:i?.fields[e],value:IS(a)?a.key:a??(t.type!==`boolean`&&``),stored:void 0,relationLabel:IS(a)?a.label:void 0,placeholder:VS(t)?FS(`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,R.jsx)(Yxe,{ref:_,noun:c,collection:i?.names?.plural??K(e),sections:b,saving:l.phase===`saving`,message:l.message,onSubmit:()=>void y(),onCancel:()=>s({kind:`list`,resource:e})})},$xe=({resource:e,values:t})=>{let n=J(),r=n.views[e];return r?.create?n.pages[r.create.page]?(0,R.jsx)(P5,{name:r.create.page}):(0,R.jsx)(mS,{title:FS(`notAllowed`),children:FS(`cannotCreate`,r.names?.plural.toLowerCase()??K(e))}):(0,R.jsx)(Zxe,{resource:e,values:t},new URLSearchParams(t).toString())},eSe=(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)}}))},tSe=(e,t)=>[...new Set(t.filter(t=>!e.includes(t)))],nSe=Un(),rSe=(e,t)=>{let n=U(),[r,i]=(0,I.useState)({}),a=e=>!!e?.search?.length&&e.primaryKey.length===1,o=Oh({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:qm,queryFn:async()=>{let e=i.primaryKey[0],r=cx(i,t[i.name]);return(await n.list(i.name,{filter:Fn(nSe.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??[]}})},iSe=24,aSe=({model:e,resources:t,views:n,view:r,state:i,extras:a})=>{let o=U(),s=Om(),c=e6(r,e),l=e=>r?.fields[e]?.label??K(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=Oh({queries:d.map(({group:t,field:r})=>{let s=K3(c,{...i,facets:{...i.facets,[t]:[]}},a),l=u(r),d=l?.primaryKey.length===1?cx(l,n[l.name]):void 0;return{queryKey:H.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=Oh({queries:c.facets.map(t=>{let r=u(t.id),a=tSe((p(t.id,t.id)??[]).flatMap(e=>e.value===null?[]:[String(e.value)]),i.facets[t.id]??[]);return{queryKey:H.labels(`facet:${e.name}.${t.id}`,a.join(`,`)),enabled:!!r&&a.length>0,queryFn:async()=>[...await H0(s,o,r,a,n[r.name])]}})}),h=rSe(c.facets.map(e=>({id:e.id,target:e.combobox?u(e.id):void 0})),n),g=c.ranges??[],_=Oh({queries:g.map(t=>{let n=K3(c,w3(i,t.id,void 0),a),s=t6(r,t.id)?iSe:1;return{queryKey:H.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`?_s(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?eSe(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:t6(r,e.id)?n.buckets.map(e=>e.count):[],format:n6(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)}))}},R5=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`}}),oSe=Un(),sSe=({blockingPlural:e,noun:t})=>R5(`stillPointAt`,e,t),cSe=({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??K(a),c=sSe({blockingPlural:s,noun:r});if(!o||i===void 0)return{text:c};let l={kind:`list`,resource:a,filter:Fn(oSe.eq(o,i))};return{text:c,link:{label:R5(`show`,s),to:l}}},lSe=({title:e,noun:t,busy:n,onConfirm:r,onCancel:i})=>(0,R.jsx)(sp,{title:R5(`confirmTitle`,e),description:R5(`confirmDescription`,t,e),onClose:i,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:i,children:R5(`cancel`)}),(0,R.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:r,children:R5(`delete`)})]})}),uSe=({title:e,changes:t,busy:n,onReview:r,onDeleteAnyway:i,onCancel:a})=>(0,R.jsx)(sp,{title:R5(`changedTitle`,e),description:R5(`changedDescription`),onClose:a,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:r,children:R5(`reviewChanges`)}),(0,R.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:i,children:R5(`deleteAnyway`)})]}),children:t.length===0?(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:R5(`noVisibleChanges`)}):(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:t.map(e=>(0,R.jsxs)(`li`,{className:`grid grid-cols-[96px_1fr] gap-3 px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,R.jsx)(`span`,{className:`font-medium`,children:e.after})]})]},e.field))})}),z5=e=>{if(e.stage===`confirm`)return(0,R.jsx)(sp,{title:R5(`bulkConfirmTitle`,e.count,e.plural),description:R5(`bulkConfirmDescription`),onClose:e.onCancel,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:e.onCancel,children:R5(`cancel`)}),(0,R.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,onClick:e.onConfirm,children:R5(`deleteCount`,e.count)})]})});if(e.stage===`running`)return(0,R.jsx)(sp,{title:R5(`deleting`),description:R5(`progress`,e.done,e.total),onClose:()=>void 0,actions:(0,R.jsx)(V,{loading:!0,disabled:!0,children:R5(`working`)})});let t=e.total-e.failures.length;return(0,R.jsx)(sp,{title:e.failures.length===0?R5(`deleted`,t):R5(`deletedOf`,t,e.total),description:e.failures.length===0?void 0:R5(`kept`,e.failures.length),onClose:e.onClose,actions:(0,R.jsx)(V,{variant:`primary`,onClick:e.onClose,children:R5(`done`)}),children:e.failures.length>0&&(0,R.jsx)(`ul`,{className:`max-h-48 divide-y overflow-y-auto rounded-md border`,children:e.failures.map(e=>(0,R.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,R.jsx)(`span`,{className:`block text-xs text-danger-text`,children:e.message})]},e.title))})})},dSe=new Set([`updated_at`,`updatedAt`]),fSe=(e,t,n,r)=>Object.values(e.fields).flatMap(e=>{if(dSe.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??K(e.name),before:Ox(e,n[e.name],i),after:Ox(e,r[e.name],i)}]}),pSe=4,B5=({model:e,view:t,onDeleted:n,onReview:r,restore:i})=>{let a=U(),o=Om(),s=ub(),[c,l]=(0,I.useState)(),[u,d]=(0,I.useState)(!1),f=t?.names?.singular??K(e.name),p=t?.names?.plural??K(e.name),{resources:m,views:h}=J(),{href:g,open:_}=gS(),v=(t,n)=>t.blockedBy&&cSe({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 Js))throw e;return e}},x=t=>{y(),l(void 0),n?.(t),s.show({state:`success`,title:R5(`deletedToast`,t.title),...e.softDelete&&i&&{action:{label:R5(`undo`),onClick:()=>{i(t).then(()=>{y(),s.show({state:`success`,title:R5(`restored`,t.title)})},e=>{if(!Ys(e))throw e;y(),s.show({state:e.status===409?`success`:`error`,title:e.status===409?R5(`alreadyBack`,t.title):R5(`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:fSe(e,t,n.snapshot,i)})}catch(e){if(!Ys(e))throw e;l(void 0);let t=v(e,n);s.show({state:`error`,title:R5(`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:R5(`changedSinceLoaded`)}:void 0}catch(t){if(!Ys(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(pSe,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,R.jsxs)(R.Fragment,{children:[c.kind===`confirm`&&(0,R.jsx)(lSe,{title:c.target.title,noun:f,busy:u,onCancel:T,onConfirm:()=>void S(c.target,c.target.etag)}),c.kind===`conflict`&&(0,R.jsx)(uSe,{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,R.jsx)(z5,{stage:`confirm`,count:c.targets.length,plural:p,onCancel:T,onConfirm:()=>void w(c.targets)}),c.kind===`bulk-running`&&(0,R.jsx)(z5,{stage:`running`,done:c.done,total:c.total}),c.kind===`bulk-done`&&(0,R.jsx)(z5,{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})}},V5=e=>{let t=U();return e.softDelete?async n=>void await t.undelete(e.name,n.key):void 0},H5=(e,t,n)=>e?.create?Object.hasOwn(t,e.create.page):eT(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}`}}),U5=e=>typeof e==`object`&&!!e,W5=e=>e===null||typeof e==`string`&&e.trim()===``,G5=e=>e===null?``:U5(e)?e.date.replace(`T`,` `):typeof e==`boolean`?e?`TRUE`:`FALSE`:String(e),K5=e=>e<26?String.fromCharCode(65+e):K5(Math.floor(e/26)-1)+K5(e%26),q5=(e,t)=>e[t]?.trim()?e[t]:$(`column`,K5(t)),mSe=e=>/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,hSe=(e,t)=>{let n=[...t].sort((e,t)=>e.line-t.line).map(t=>[...e.map((e,n)=>G5(t.cells[n]??null)),String(t.line),t.problems.join(`; `)]);return`${[[...e,$(`line`),$(`problems`)],...n].map(e=>e.map(mSe).join(`,`)).join(`\r
|
|
67
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xme(e,t){if(e){if(typeof e==`string`)return b0(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)?b0(e,t):void 0}}function b0(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 Sme(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 Cme(e){if(Array.isArray(e))return e}var wme=()=>(uq(),null);function x0(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var Tme=(0,I.forwardRef)((e,t)=>{var n=(0,I.useRef)(null),r=y0((0,I.useState)({containerWidth:x0(e.style?.width),containerHeight:x0(e.style?.height)}),2),i=r[0],a=r[1],o=(0,I.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,I.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,I.useEffect)(()=>()=>{n.current?.disconnect()},[o]),I.createElement(I.Fragment,null,I.createElement(WM,{width:i.containerWidth,height:i.containerHeight}),I.createElement(`div`,v0({ref:s},e)))}),Eme=(0,I.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=y0((0,I.useState)({containerWidth:x0(n),containerHeight:x0(r)}),2),a=i[0],o=i[1],s=(0,I.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,I.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 I.createElement(I.Fragment,null,I.createElement(WM,{width:a.containerWidth,height:a.containerHeight}),I.createElement(`div`,v0({ref:c},e)))}),Dme=(0,I.forwardRef)((e,t)=>{var n=e.width,r=e.height;return I.createElement(I.Fragment,null,I.createElement(WM,{width:n,height:r}),I.createElement(`div`,v0({ref:t},e)))}),Ome=(0,I.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?I.createElement(Eme,v0({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?I.createElement(Dme,v0({},e,{width:n,height:r,ref:t})):I.createElement(I.Fragment,null,I.createElement(WM,{width:n,height:r}),I.createElement(`div`,v0({ref:t},e)))});function kme(e){return e?Tme:Ome}var Ame=(0,I.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,I.useRef)(null),S=xk(),C=y0((0,I.useState)(null),2),w=C[0],T=C[1],E=y0((0,I.useState)(null),2),D=E[0],O=E[1],k=hme(),A=PM(),j=A?.width>0?A.width:_,M=A?.height>0?A.height:i,N=(0,I.useCallback)(e=>{k(e),typeof t==`function`&&t(e),T(e),O(e),e!=null&&(x.current=e)},[k,t,T,O]),ee=(0,I.useCallback)(e=>{S(j1(e)),S(Y1({handler:a,reactEvent:e}))},[S,a]),te=(0,I.useCallback)(e=>{S(N1(e)),S(Y1({handler:l,reactEvent:e}))},[S,l]),ne=(0,I.useCallback)(e=>{S(yW()),S(Y1({handler:u,reactEvent:e}))},[S,u]),re=(0,I.useCallback)(e=>{S(N1(e)),S(Y1({handler:d,reactEvent:e}))},[S,d]),ie=(0,I.useCallback)(()=>{S(H1())},[S]),ae=(0,I.useCallback)(()=>{S(U1())},[S]),oe=(0,I.useCallback)(e=>{S(V1(e.key))},[S]),se=(0,I.useCallback)(e=>{S(Y1({handler:o,reactEvent:e}))},[S,o]),ce=(0,I.useCallback)(e=>{S(Y1({handler:s,reactEvent:e}))},[S,s]),le=(0,I.useCallback)(e=>{S(Y1({handler:c,reactEvent:e}))},[S,c]),ue=(0,I.useCallback)(e=>{S(Y1({handler:f,reactEvent:e}))},[S,f]),de=(0,I.useCallback)(e=>{S(Y1({handler:h,reactEvent:e}))},[S,h]),P=(0,I.useCallback)(e=>{b&&S(e0(e)),S(Y1({handler:m,reactEvent:e}))},[S,b,m]),fe=(0,I.useCallback)(e=>{S(Y1({handler:p,reactEvent:e}))},[S,p]),pe=kme(v);return I.createElement(RK.Provider,{value:w},I.createElement(YE.Provider,{value:D},I.createElement(pe,{width:j??g?.width,height:M??g?.height,className:qT(`recharts-wrapper`,r),style:gme({position:`relative`,cursor:`default`,width:j,height:M},g),onClick:ee,onContextMenu:se,onDoubleClick:ce,onFocus:ie,onBlur:ae,onKeyDown:oe,onMouseDown:le,onMouseEnter:te,onMouseLeave:ne,onMouseMove:re,onMouseUp:ue,onTouchEnd:fe,onTouchMove:P,onTouchStart:de,ref:N},I.createElement(wme,null),n)))}),jme=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function Mme(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}var S0=(0,I.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=$T(Mme(e,jme));return c?I.createElement(I.Fragment,null,I.createElement(WM,{width:n,height:r}),I.createElement(h0,{otherAttributes:d,title:l,desc:u},a)):I.createElement(Ame,{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},I.createElement(h0,{otherAttributes:d,title:l,desc:u,ref:t},I.createElement(u$,null,a)))});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){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 Pme(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?w0(Object(n),!0).forEach(function(t){Fme(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Fme(e,t,n){return(t=Ime(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ime(e){var t=Lme(e,`string`);return typeof t==`symbol`?t:t+``}function Lme(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 Rme=Pme({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`},o0),T0=(0,I.forwardRef)(function(e,t){var n=iO(e.categoricalChartProps,Rme),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 I.createElement(c0,{preloadedState:{options:c},reduxStoreName:s.id??r},I.createElement(JQ,{chartData:s.data}),I.createElement(l0,{layout:n.layout,margin:n.margin}),I.createElement(d0,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),I.createElement(u0,{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}),I.createElement(S0,C0({},n,{ref:t})))}),zme=[`axis`],Bme=(0,I.forwardRef)((e,t)=>I.createElement(T0,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:zme,tooltipPayloadSearcher:WK,categoricalChartProps:e,ref:t})),Vme=[`axis`,`item`],E0=(0,I.forwardRef)((e,t)=>I.createElement(T0,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Vme,tooltipPayloadSearcher:WK,categoricalChartProps:e,ref:t}));function Hme(e){var t=xk();return(0,I.useEffect)(()=>{t(Xpe(e))},[t,e]),null}var Ume=[`layout`];function D0(){return D0=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},D0.apply(null,arguments)}function Wme(e,t){if(e==null)return{};var n,r,i=Gme(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 Gme(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 O0(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 Kme(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?O0(Object(n),!0).forEach(function(t){qme(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qme(e,t,n){return(t=Jme(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jme(e){var t=Yme(e,`string`);return typeof t==`symbol`?t:t+``}function Yme(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 k0=Kme({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%`},o0),Xme=(0,I.forwardRef)(function(e,t){var n=iO(e.categoricalChartProps,k0),r=n.layout,i=Wme(n,Ume),a=e.chartName,o={chartName:a,defaultTooltipEventType:e.defaultTooltipEventType,validateTooltipEventTypes:e.validateTooltipEventTypes,tooltipPayloadSearcher:e.tooltipPayloadSearcher,eventEmitter:void 0};return I.createElement(c0,{preloadedState:{options:o},reduxStoreName:n.id??a},I.createElement(JQ,{chartData:n.data}),I.createElement(l0,{layout:r,margin:n.margin}),I.createElement(d0,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),I.createElement(u0,{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}),I.createElement(Hme,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),I.createElement(S0,D0({},i,{ref:t})))});function A0(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 j0(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?A0(Object(n),!0).forEach(function(t){Zme(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A0(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Zme(e,t,n){return(t=Qme(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qme(e){var t=$me(e,`string`);return typeof t==`symbol`?t:t+``}function $me(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 ehe=[`item`],the=j0(j0({},k0),{},{layout:`centric`,startAngle:0,endAngle:360}),nhe=(0,I.forwardRef)((e,t)=>{var n=iO(e,the);return I.createElement(Xme,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:ehe,tooltipPayloadSearcher:WK,categoricalChartProps:n,ref:t})}),M0=`flex items-center gap-2 rounded-md px-1 py-0.5`,N0=({resource:e,view:t,filter:n,color:r,label:i,children:a})=>{let o=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`size-2.5 shrink-0 rounded-full`,style:{background:r},"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate group-hover:text-primary-text`,children:i}),a]});return(0,R.jsx)(`li`,{children:n===void 0?(0,R.jsx)(`div`,{className:M0,children:o}):(0,R.jsx)(_S,{to:WT(t,e,n),className:`group ${M0} hover:bg-muted`,children:o})})},rhe=(e,t)=>t>0?`${Math.round(e/t*100)}%`:``,ihe=({active:e,payload:t,measure:n})=>{let r=t?.[0]?.payload;return!e||!r?null:(0,R.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,R.jsx)(`div`,{className:`text-muted-foreground`,children:r.label}),(0,R.jsx)(`div`,{className:`font-semibold tabular-nums`,children:UT(r.value,n)})]})},ahe=({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,R.jsxs)(`div`,{className:`flex flex-col items-center gap-4 sm:flex-row sm:items-center`,children:[(0,R.jsx)(`div`,{className:`size-36 shrink-0`,children:(0,R.jsx)(FM,{width:`100%`,height:`100%`,children:(0,R.jsxs)(nhe,{children:[(0,R.jsx)(GZ,{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,R.jsx)(Oq,{fill:e.color},e.key))}),(0,R.jsx)(Dq,{content:(0,R.jsx)(ihe,{measure:r}),isAnimationActive:!1})]})})}),(0,R.jsx)(`ul`,{className:`flex w-full min-w-0 flex-col gap-0.5`,children:n.map(n=>(0,R.jsxs)(N0,{resource:e,view:t,filter:n.filter,color:n.color,label:n.label,children:[(0,R.jsx)(`span`,{className:`font-medium tabular-nums`,children:UT(n.value,r)}),(0,R.jsx)(`span`,{className:`w-9 text-right text-xs text-muted-foreground tabular-nums`,children:rhe(n.value??0,a)})]},n.key))})]})},P0={hour:`2-digit`,minute:`2-digit`,hour12:!1},F0={day:`numeric`,month:`short`,...P0},ohe={minute:P0,"5_minutes":P0,"15_minutes":P0,hour:P0,day:{day:`numeric`,month:`short`},week:{day:`numeric`,month:`short`},month:{month:`short`,year:`2-digit`},year:{year:`numeric`}},I0={minute:F0,"5_minutes":F0,"15_minutes":F0,hour:F0,day:{day:`numeric`,month:`short`,year:`numeric`},week:{day:`numeric`,month:`short`,year:`numeric`},month:{month:`long`,year:`numeric`},year:{year:`numeric`}},L0=e=>{let t=new Intl.DateTimeFormat(l(),{...e,timeZone:`UTC`});return e=>t.format(e)},R0={fontSize:11,fill:`var(--muted-foreground)`},she=864e5,che=new Set([`minute`,`5_minutes`,`15_minutes`,`hour`]),lhe=(e,t)=>{let n=t.length>1?t.at(-1).at-t[0].at:0;return che.has(e)&&n>=she?F0:ohe[e]},uhe=({active:e,payload:t,measure:n,bucket:r,series:i})=>{let a=t?.[0]?.payload;return!e||!a?null:(0,R.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,R.jsx)(`div`,{className:`text-muted-foreground`,children:r===`week`?PT(`weekOf`,L0(I0[r])(a.at)):L0(I0[r])(a.at)}),i?.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{background:e.color},"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`flex-1`,children:e.label}),(0,R.jsx)(`span`,{className:`font-semibold tabular-nums`,children:UT(a[e.key]??null,e.measure??n)})]},e.key)),i&&(n.kind===`count`||n.kind===`sum`)&&(0,R.jsx)(`div`,{className:`mt-0.5 border-t pt-0.5 font-semibold tabular-nums`,children:UT(a.value,n)}),!i&&(0,R.jsx)(`div`,{className:`font-semibold tabular-nums`,children:UT(a.value,n)})]})},z0=({points:e,measure:t,bucket:n,type:r,series:i,resource:a,view:o})=>{let s=Tu(`(min-width: 640px)`),c=L0(lhe(n,e)),u=(0,R.jsx)(F$,{vertical:!1,stroke:`var(--border)`}),d=(0,R.jsx)(C1,{dataKey:`at`,tickFormatter:c,tick:R0,axisLine:!1,tickLine:!1,minTickGap:s?24:40,height:18}),f=(0,R.jsx)(O1,{width:s?48:36,tick:R0,axisLine:!1,tickLine:!1,tickCount:3,tickFormatter:e=>e.toLocaleString(l(),{notation:`compact`})}),p=(0,R.jsx)(Dq,{cursor:r===`bar`?{fill:`var(--muted)`}:{stroke:`var(--border-strong)`},content:(0,R.jsx)(uhe,{measure:t,bucket:n,...i&&{series:i}}),isAnimationActive:!1}),m=i??[{key:`value`,label:``,color:`var(--chart-1)`}],h=(0,R.jsx)(`div`,{className:`h-40`,children:(0,R.jsx)(FM,{width:`100%`,height:`100%`,children:r===`line`?(0,R.jsxs)(Bme,{data:e,margin:{top:6,right:6,bottom:0,left:0},children:[u,d,f,p,m.map(t=>(0,R.jsx)(Q$,{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,R.jsxs)(E0,{data:e,margin:{top:6,right:0,bottom:0,left:0},barCategoryGap:`22%`,children:[u,d,f,p,m.map((e,t)=>(0,R.jsx)(h1,{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,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h,(0,R.jsx)(`ul`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-sm`,children:i.map(e=>(0,R.jsx)(N0,{resource:a,view:o,color:e.color,label:e.label,...e.filter!==void 0&&{filter:e.filter}},e.key))})]})},dhe=1e-6,fhe=(e,t,n,r,i,a=``)=>{let o=t.map((e,t)=>({key:`s${t}`,label:RT(n,r,e),color:LT(n,r,e.value,t),filter:zT(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=HT(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<dhe?0:l}});return i.kind!==`average`&&l.some(e=>(e.other??0)>0)?{series:[...o,{key:`other`,label:PT(`other`),color:`var(--border-strong)`}],points:l}:{series:o,points:l.map(({other:e,...t})=>t)}},phe=(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]}},B0=(e,t,n)=>{let r=e?.type===`relation`&&e.relation?t[e.relation.resource]:void 0;return r&&r.primaryKey.length===1?cx(r,n[r.name]):void 0},V0=({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=PT(`nothingYet`)})=>{let{resources:f,views:p}=J(),m=e.fields[n],h=m?.type===`date`||m?.type===`timestamp`,g=B0(m,f,p),_=h&&r!==void 0?e.fields[r]:void 0,v=B0(_,f,p),y=_?{splitBy:_.name,splitLimit:8,...v&&{splitLabel:v}}:{},b=h?{granularity:c,range:l,timeZone:Ef(),...y}:{limit:u,...g&&{label:g}},x=MT(e.name,{groupBy:n,filter:s,...a&&{sum:a},...o&&{average:o},...b},!!m),S=phe(e,t,a,o);if(!m)return null;if(x.isPending)return(0,R.jsx)(Uu,{className:`h-36 w-full`});if(x.error)return(0,R.jsx)(`p`,{className:`text-danger-text`,children:PT(`couldNotLoad`)});let{groups:C}=x.data;if(C.every(e=>e.count===0))return(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:d});let w=i===`line`?`line`:`bar`;if(h&&_&&x.data.splits){let{series:n,points:r}=fhe(C,x.data.splits,_,t?.fields[_.name],S,s);return(0,R.jsx)(z0,{points:r,measure:S,bucket:c,type:w,series:n,resource:e.name,view:t})}if(h)return(0,R.jsx)(z0,{points:HT(C,S),measure:S,bucket:c,type:w});let T=VT(C,m,t?.fields[n],S,s);return i===`donut`?(0,R.jsx)(ahe,{resource:e.name,view:t,slices:T,measure:S}):(0,R.jsx)(GT,{resource:e.name,view:t,slices:T,measure:S})},mhe=({node:e,slots:t})=>{let{resource:n,title:r,description:i,actions:a,span:o,...s}=xT(e),{resources:c,views:l}=J(),u=c[n];return u?(0,R.jsx)(wT,{title:r,description:i,actions:t.actions,className:`h-full`,children:(0,R.jsx)(V0,{model:u,view:l[n],...s})}):null},hhe=Un(),H0=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=cx(n,i),c=await e.fetchQuery({queryKey:H.labels(n.name,o.join(`,`)),staleTime:3e5,queryFn:async()=>(await t.list(n.name,{filter:Fn(hhe.in(a,o)),fields:[a,s],pageSize:o.length})).items.map(e=>[String(e[a]),String(e[s])])});return new Map(c)},U0=(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}]:[]}),W0=(e,t,n,r)=>Object.fromEntries(U0(e,n,r).filter(({target:e})=>e.primaryKey.length===1).map(({name:e,target:n})=>[e,cx(n,t[n.name])])),G0=(e,t,n,r,i={})=>{let a=U0(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})},K0=(e,t)=>{let n=String(t);return e&&Object.hasOwn(e,n)?e[n]:void 0},q0=({value:e,hints:t,children:n})=>(0,R.jsx)(dd,{tone:yx(String(e)),color:K0(t?.valueColors,e),shape:t?.badgeShape,children:n}),ghe=({field:e,value:t,known:n})=>{let{resources:r,views:i}=J(),a=U(),o=Om(),s=e.relation?r[e.relation.resource]:void 0,c=String(t),l=Ah({queryKey:H.relatedLabel(s?.name??``,c),enabled:!!s&&n===void 0,queryFn:async()=>(await H0(o,a,s,[c],i[s.name])).get(c)??c});return s?(0,R.jsx)(_S,{to:{kind:`record`,resource:s.name,key:c},className:`font-medium text-primary-text hover:underline`,children:n??l.data??c}):(0,R.jsx)(`span`,{children:c})},_he=({model:e,field:t,value:n,format:r,relationLabel:i})=>{let{views:a}=J(),o={...a[e.name]?.fields[t.name],...r&&{format:r}};if(n==null||n===``)return(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});if(t.type===`relation`)return(0,R.jsx)(ghe,{field:t,value:n,known:i});let s=t.type===`file`?wb(n):void 0;if(s&&`url`in s&&s.url){let e=Mb(n,{width:40,height:40});return(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[e&&(0,R.jsx)(QS,{image:e,className:`size-10 shrink-0 rounded border border-border object-cover`}),(0,R.jsx)(`a`,{href:s.url,target:`_blank`,rel:`noreferrer`,className:`truncate font-medium text-primary-text hover:underline`,children:s.name})]})}if(ox(t,o))return(0,R.jsx)(aC,{source:String(n)});let c=Ox(t,n,o),l=t.type===`text`?hx(o):void 0;return l?(0,R.jsx)(sC,{format:l,value:c}):t.type===`enum`||o.format===`badge`?(0,R.jsx)(q0,{value:n,hints:o,children:c}):(0,R.jsx)(`span`,{title:kx(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})},J0=e=>{let{views:t}=J(),n=rC(e.field,t[e.model.name]?.fields[e.field.name]),r=(0,R.jsx)(_he,{...e});return n?(0,R.jsx)(iC,{shown:n,part:`display`,field:e.field,value:e.value,fallback:r}):r},Y0=(e,t,n)=>{if(!t)return[];let r=xc(e,t.model.name,n);return r.ok?r.steps:[]},X0=(e,t,n,r,i)=>({queryKey:H.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:H.record(a,String(i)),queryFn:()=>e.get(a,String(i))})).record}return r[i.at(-1).field.name]??null}}),Z0=(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}},Q0=(e,t)=>{let{resources:n}=J(),r=Y0(n,e,t);return Z0(e,r,Ah(X0(U(),Om(),e,t,r)))},vhe=(e,t)=>{let{resources:n}=J(),r=U(),i=Om(),a=t.map(t=>Y0(n,e,t)),o=Oh({queries:t.map((t,n)=>X0(r,i,e,t,a[n]))});return t.map((t,n)=>Z0(e,a[n],o[n]))},$0=(e,t)=>{if(t)return t;let n=e.split(`.`).map(e=>K(e).toLowerCase()).join(` `);return n[0].toUpperCase()+n.slice(1)},yhe=({node:e})=>{let{name:t,label:n,format:r}=xT(e),{views:i}=J(),a=Q0($w(),t);if(a.state===`missing`)return null;let o=a.state===`loading`?(0,R.jsx)(Uu,{className:`h-4 w-24`}):(0,R.jsx)(J0,{model:a.model,field:a.field,value:a.value,format:r});if(n===!1)return(0,R.jsx)(`div`,{children:o});let s=n??$0(t,a.state===`ready`?i[a.model.name]?.fields[a.field.name]?.label:void 0);return(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-body text-muted-foreground`,children:s}),(0,R.jsx)(`div`,{className:`mt-0.5 truncate`,children:o})]})},bhe={1:``,2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`sm:grid-cols-2 xl:grid-cols-4`},xhe={1:``,2:`grid-cols-2`,3:`grid-cols-2 xl:grid-cols-3`,4:`grid-cols-2 xl:grid-cols-4`},She={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`},Che=e=>typeof e==`object`&&!e.custom&&e.type===`Stat`,whe=({node:e,children:t})=>{let{columns:n=2}=xT(e),r=e.children,i=r.length>0&&r.every(Che);return(0,R.jsx)(`div`,{className:g(`grid grid-cols-1 gap-4`,i?xhe[n]:bhe[n]),children:t.map((e,t)=>{let n=r[t],i=typeof n==`object`?n.props.span:void 0;return(0,R.jsx)(`div`,{className:g(`min-w-0`,i&&She[i]),children:e},t)})})},e2=`font-medium text-primary-text hover:underline`,The=({node:e})=>{let t=xT(e),n=$w()?.record,r=e.children.filter(e=>typeof e==`string`).join(``);if(t.to){let e=Jn(t.to,n);return(0,R.jsx)(_S,{to:e,className:e2,children:r||ws(e)})}let i=t.href??``;return(0,R.jsx)(`a`,{href:i,className:e2,...i.startsWith(`http`)&&{target:`_blank`,rel:`noreferrer`},children:r||i})},Ehe=(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]:TS(n.record[t])];let i=r.default&&`value`in r.default?r.default.value:void 0;return[t,r.type===`boolean`?!!i:TS(i)]})),Dhe=(e,t,n)=>Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e.fields[t];return IS(r)?r.key===TS(n.record[t])?[]:[[t,i.type===`integer`?Number(r.key):r.key]]:jS(i,r,n.record[t])?[[t,OS(i,r)]]:[]})),Ohe=({model:e,record:t,mode:n,label:r,title:i,fields:a,values:o,onClose:s})=>{let{resources:c,views:l}=J(),u=U(),d=ub(),f=_T(),p=l[e.name],[m,h]=(0,I.useState)(()=>Ehe(e,a,t)),[g,_]=(0,I.useState)({}),[v,y]=(0,I.useState)(0),b=pC(v),[x,S]=(0,I.useState)(),[C,w]=(0,I.useState)(!1),T=async()=>{w(!0),S(void 0),await(n===`create`?u.create(e.name,{...RS(e,c,m),...o}):u.update(e.name,t.key,Dhe(e,m,t),t.etag??`*`)).then(async()=>{await f(e.name),d.show({state:`success`,title:_g(`saved`,i??r)}),s()},e=>{let t=fC(e);_(t),Object.keys(t).length>0&&y(e=>e+1),S(e)}),w(!1)};return(0,R.jsx)(sp,{title:i??r,onClose:s,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:s,children:_g(`cancel`)}),(0,R.jsx)(V,{variant:`primary`,loading:C,onClick:()=>void T(),children:_g(n===`create`?`create`:`save`)})]}),children:(0,R.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,R.jsx)(US,{title:_g(`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??K(n),s=g[n];return(0,R.jsx)(pb,{name:n,label:o,help:p?.fields[n]?.help,error:s&&dC(r,o,s),children:(0,R.jsx)(cC,{field:r,hints:p?.fields[n],value:IS(i)?i.key:i,stored:t?.record[n],relationLabel:IS(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)})]})})},khe=({model:e,recordKey:t,children:n})=>{let r=hT(e,{key:t});return(0,R.jsx)(R.Fragment,{children:n(r.data??void 0)})},Ahe=({node:e})=>{let t=xT(e),n=$w(),{resources:r}=J(),i=r[t.resource??n?.model.name??``],a=hS(i?.name??``),[o,s]=(0,I.useState)(!1);if(!i||!(t.mode===`create`?eT(a,`create`):eT(a,`update`)&&n?.permissions?.update!==!1))return null;let c=e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{size:`sm`,variant:t.variant??`secondary`,disabled:t.mode===`edit`&&!e,onClick:()=>s(!0),children:t.label}),o&&(0,R.jsx)(Ohe,{...t,model:i,record:t.mode===`edit`?e:void 0,onClose:()=>s(!1)})]});return t.mode===`edit`&&t.recordKey!==void 0?(0,R.jsx)(khe,{model:i,recordKey:t.recordKey,children:c}):c(t.mode===`edit`?n:void 0)},jhe=({node:e,children:t,slots:n})=>{let{title:r,description:i}=xT(e);return(0,R.jsx)(`div`,{className:`flex-1`,children:(0,R.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,R.jsx)(Jd,{title:r,subtitle:i,actions:n.actions}),t]})})},t2=(e,t)=>{let n=$w(),r=Q0(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},Mhe=({node:e})=>{let{value:t,max:n,label:r}=xT(e),i=t2(t,0),a=t2(n,100);if(i===void 0||a===void 0)return(0,R.jsx)(Uu,{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,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-body`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:r}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[i.toLocaleString(l()),` / `,a.toLocaleString(l())]})]}),(0,R.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,R.jsx)(`div`,{className:o>=.9?`h-full rounded-full bg-warning`:`h-full rounded-full bg-primary`,style:{width:`${o*100}%`}})})]})},Nhe=({model:e,filter:t,sort:n,recordKey:r,title:i,description:a,empty:o,actions:s,children:c})=>{let l=hT(e,{filter:t,sort:n,key:r}),u=e=>l.data?(0,R.jsx)(Qw,{value:l.data,children:e}):void 0,d=l.isPending?(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(Uu,{className:`h-4 w-1/2`}),(0,R.jsx)(Uu,{className:`h-4 w-1/3`})]}):l.error?(0,R.jsx)(US,{title:_g(`couldNotLoad`),error:l.error}):l.data?u((0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:c})):(0,R.jsx)(TT,{children:o??_g(`nothingYet`)});return(0,R.jsx)(wT,{title:i,description:a,actions:s?u(s):void 0,className:`h-full`,children:d})},Phe=({node:e,children:t,slots:n})=>{let{resource:r,filter:i,sort:a,recordKey:o,title:s,description:c,empty:l}=xT(e),u=J().resources[r];return u?(0,R.jsx)(Nhe,{model:u,filter:i,sort:a,recordKey:o,title:s,description:c,empty:l,actions:n.actions,children:t}):null};function Fhe(e){return Ihe(e)||typeof e==`function`||Lhe(e)}function Ihe(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Lhe(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function n2(e,t){return e==null?null:Fhe(e)?I.createElement(e,t):e}function Rhe(e){if(`cell`in e&&e.cell){let t=e.cell,n=t.column.columnDef,r=t,i=n;return r.getIsAggregated?.()?n2(i.aggregatedCell??n.cell,t.getContext()):r.getIsPlaceholder?.()?null:n2(n.cell,t.getContext())}return`header`in e&&e.header?n2(e.header.column.columnDef.header,e.header.getContext()):`footer`in e&&e.footer?n2(e.footer.column.columnDef.footer,e.footer.getContext()):null}function zhe({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 Bhe(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 r2=[],i2=0,{link:a2,unlink:Vhe,propagate:Hhe,checkDirty:o2,shallowPropagate:s2}=zhe({update(e){return e._update()},notify(e){r2[l2++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,f2(e))}}),c2=0,l2=0,u2,d2=0;function Uhe(e){try{++d2,e()}finally{--d2||p2()}}function f2(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Vhe(n,e)}function p2(){if(!(d2>0)){for(;c2<l2;){let e=r2[c2];r2[c2++]=void 0,e.notify()}c2=0,l2=0}}function Whe(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 u2!==void 0&&a2(i,u2,i2),i._snapshot},subscribe(e){let t=Bhe(e),n={current:!1},r=Ghe(()=>{i.get(),n.current?(u2=void 0,t.next?.(i._snapshot)):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=u2,o=t?.compare??Object.is;if(n)u2=i,++i2,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{u2=a,n&&(i.flags&=-5),f2(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&o2(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&s2(e)}}else e&32&&(i.flags=e&-33);return u2!==void 0&&a2(i,u2,i2),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Hhe(e),s2(e),p2())}},i}function Ghe(e){let t=()=>{let t=u2;u2=n,++i2,n.depsTail=void 0,n.flags=6;try{return e()}finally{u2=t,n.flags&=-5,f2(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&&o2(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,f2(this)}};return t(),n}function m2(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=h2(e);if(n.length!==h2(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 h2(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function Khe(e,t){return e===t}function g2(e,t=e=>e,n){let r=n?.compare??Khe,i=(0,I.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,I.useCallback)(()=>e.get(),[e]);return(0,vk.useSyncExternalStoreWithSelector)(i,a,a,t,r)}function qhe(e){let t=g2(e.source,e.selector,{compare:m2});return typeof e.children==`function`?e.children(t):e.children}function Jhe(e){let t=e;return Object.defineProperty(e,"state",{get(){return e.get()}}),`set`in e&&(t.setState=e.set.bind(e)),t}function Yhe(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 Xhe(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 Zhe(){return Yhe({createAtom:Whe,batch:Uhe})}function _2(e,t){return typeof e==`function`?e(t):e}function v2(e){if(Array.isArray(e))return e.map(v2);if(e&&typeof e==`object`){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=t===null?y2():{},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:v2(e[i]),writable:!0})}return n}return e}function Qhe(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 y2(){return Object.create(null)}function b2(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function x2(e,t){return n=>{(t.options.atoms?.[e]??t.baseAtoms[e]).set(e=>_2(n,e))}}function S2(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 C2(e){return Reflect.ownKeys(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}var $he=3;function ege(e,t){return w2(e,t,$he)}function w2(e,t,n){if(Object.is(e,t))return!0;if(n<=0||!S2(e)||!S2(t)||(Array.isArray(e)||Array.isArray(t))&&(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length))return!1;let r=C2(e),i=C2(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)||!w2(a[i],o[i],n-1))return!1}return!0}function T2(e,t,n,r=ege){let i=`on${t.charAt(0).toUpperCase()}${t.slice(1)}Change`,a=e.options[i];a&&a(e=>{let t=_2(n,e);return r(e,t)?e:t})}function tge(e){return e instanceof Function}function nge(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 rge=({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 ige(e){let t=!1;return()=>{if(!t){t=!0;return}e()}}function E2({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 rge({...a,...s})}function D2(e,t=`_`){let[n,r]=e.split(t);return{fnKey:r,fnName:`${n}.${r}`,parentName:n}}function O2(e,t,n){for(let[r,{fn:i,memoDeps:a}]of Object.entries(n)){let{fnKey:n,fnName:o}=D2(r);t[n]=a?E2({memoDeps:a,fn:i,fnName:o,table:t,feature:e}):i}}function k2(e,t,n,r){for(let[i,{fn:a,memoDeps:o}]of Object.entries(r)){let{fnKey:r,fnName:s}=D2(i);if(o){let i=`_memo_${r}`;t[r]=function(...t){if(!this[i]){let t=this;this[i]=E2({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 A2(e,t,n,...r){return e[t]?.(...r)??n(e,...r)}function age(e){return e.row.getValue(e.column.id)}function oge(e){return e.getValue()??e.table.options.renderFallbackValue}function sge(e){return{table:e.table,column:e.column,row:e.row,cell:e,getValue:()=>e.getValue(),renderValue:()=>e.renderValue()}}var cge={assignCellPrototype:(e,t)=>{k2(`coreCellsFeature`,e,t,{cell_getValue:{fn:e=>age(e)},cell_renderValue:{fn:e=>oge(e)},cell_getContext:{fn:e=>sge(e),memoDeps:e=>[e]}})}};function lge(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 j2(e,t,n){let r=lge(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 uge(){return{start:[],end:[]}}function M2(e){let t=e.table.atoms.columnVisibility?.get();if(!t)return!0;let n=e.columns;return n.length?n.some(e=>A2(e,`getIsVisible`,M2)):(b2(t,e.id)?t[e.id]:void 0)??!0}function dge(e){return e.getAllLeafColumns().filter(e=>A2(e,`getIsVisible`,M2))}function N2(e,t=1){let n=t;for(let r=0;r<e.length;r++){let i=e[r];A2(i,`getIsVisible`,M2)&&i.columns.length&&(n=Math.max(n,N2(i.columns,t+1)))}return n}function fge(e,t){return e?`${e}_${t}`:String(t)}function pge(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 mge(e,t){let n=0;for(let r=0;r<e.length;r++)e[r].column===t&&n++;return n}function P2(e,t,n,r,i,a){let o={depth:t,id:fge(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=j2(n,u,{id:pge(r,t,u.id,a.id),isPlaceholder:d,placeholderId:d?String(mge(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&&P2(s,t-1,n,r,i,a)}function F2(e){for(let t=0;t<e.length;t++){let n=e[t];if(!A2(n.column,`getIsVisible`,M2))continue;let r=0;if(n.subHeaders.length){F2(n.subHeaders);for(let e=0;e<n.subHeaders.length;e++){let t=n.subHeaders[e];A2(t.column,`getIsVisible`,M2)&&(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 I2(e,t,n,r){let i=N2(e),a=[],o=n._headerGroupInstanceInitFns,s=Array(t.length);for(let e=0;e<t.length;e++)e in t&&(s[e]=j2(n,t[e],{depth:i,index:e}));return P2(s,i-1,n,r,a,o),a.reverse(),F2(a[0]?.headers??[]),a}function hge(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 gge(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=hge(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 L2(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 _ge(e,r)}}function _ge(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 vge(e){return[e,...e.columns.flatMap(e=>e.getFlatColumns())]}function yge(e){if(e.columns.length){let t=e.columns.flatMap(e=>e.getLeafColumns());return A2(e.table,`getOrderColumns`,L2)(t)}return[e]}function bge(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 R2(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=gge(e,o,r,n),c=o;s.columns=c.columns?R2(e,c.columns,s,r+1):[],i[a]=s}return i}function xge(e){return R2(e,e.options.columns)}function Sge(e){return e.getAllColumns().flatMap(e=>e.getFlatColumns())}function Cge(e){let t=y2(),n=e.getAllFlatColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function wge(e){let t=e.getAllColumns().flatMap(e=>e.getLeafColumns());return A2(e,`getOrderColumns`,L2)(t)}function Tge(e){let t=y2(),n=e.getAllLeafColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function Ege(e,t){return e.getAllFlatColumnsById()[t]}var Dge={assignColumnPrototype:(e,t)=>{k2(`coreColumnsFeature`,e,t,{column_getFlatColumns:{fn:e=>vge(e),memoDeps:e=>[e.table.options.columns]},column_getLeafColumns:{fn:e=>yge(e),memoDeps:e=>[e.table.atoms.columnOrder?.get(),e.table.atoms.grouping?.get(),e.table.options.columns,e.table.options.groupedColumnMode]}})},constructTableAPIs:e=>{O2(`coreColumnsFeature`,e,{table_getDefaultColumnDef:{fn:()=>bge(e),memoDeps:()=>[e.options.defaultColumn]},table_getAllColumns:{fn:()=>xge(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumns:{fn:()=>Sge(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumnsById:{fn:()=>Cge(e),memoDeps:()=>[e.options.columns]},table_getAllLeafColumns:{fn:()=>wge(e),memoDeps:()=>[e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.columns,e.options.groupedColumnMode]},table_getAllLeafColumnsById:{fn:()=>Tge(e),memoDeps:()=>[e.getAllLeafColumns()]},table_getColumn:{fn:t=>Ege(e,t)}})}};function z2(e,t){for(let n=0;n<e.subHeaders.length;n++)z2(e.subHeaders[n],t);t.push(e)}function Oge(e){let t=[];return z2(e,t),t}function kge(e){return{column:e.column,header:e,table:e.column.table}}function Age(e){let{start:t,end:n}=e.atoms.columnPinning?.get()??uge(),r=e.getAllColumns(),i=A2(e,`getVisibleLeafColumns`,dge);if(!t.length&&!n.length)return I2(r,i,e);let a=e.getAllLeafColumnsById(),o=[];for(let e=0;e<t.length;e++){let n=a[t[e]];n&&A2(n,`getIsVisible`,M2)&&o.push(n)}let s=[];for(let e=0;e<n.length;e++){let t=a[n[e]];t&&A2(t,`getIsVisible`,M2)&&s.push(t)}let c=i.filter(e=>!t.includes(e.id)&&!n.includes(e.id));return I2(r,[...o,...c,...s],e)}function jge(e){return[...e.getHeaderGroups()].reverse()}function Mge(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 Nge(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 Pge={assignHeaderPrototype:(e,t)=>{k2(`coreHeadersFeature`,e,t,{header_getLeafHeaders:{fn:e=>Oge(e),memoDeps:e=>[e.column.table.options.columns]},header_getContext:{fn:e=>kge(e),memoDeps:e=>[e.column.table.options.columns]}})},constructTableAPIs:e=>{O2(`coreHeadersFeature`,e,{table_getHeaderGroups:{fn:()=>Age(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:()=>jge(e),memoDeps:()=>[e.getHeaderGroups()]},table_getFlatHeaders:{fn:()=>Mge(e),memoDeps:()=>[e.getHeaderGroups()]},table_getLeafHeaders:{fn:()=>Nge(e),memoDeps:()=>[e.getHeaderGroups()]}})}};function Fge(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 Ige=(e,t,n,r,i,a,o)=>{let s=Fge(e),c=Object.create(s);c._displayIndexCache=-1,c._uniqueValuesCache=y2(),c._valuesCache=y2(),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},Lge=/([0-9]+)/gm;function B2(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}B2({resolveDataValue:e=>U2(e).toLowerCase(),sort:(e,t)=>W2(e,t)}),B2({resolveDataValue:e=>U2(e),sort:(e,t)=>W2(e,t)}),B2({resolveDataValue:e=>U2(e).toLowerCase(),sort:(e,t)=>H2(e,t)}),B2({resolveDataValue:e=>U2(e),sort:(e,t)=>H2(e,t)}),B2({resolveDataValue:e=>Rge(e),sort:(e,t)=>e>t?1:e<t?-1:0});var V2=B2({sort:(e,t)=>H2(e,t)});function H2(e,t){return e===t?0:e>t?1:-1}function Rge(e){return e instanceof Date?e.getTime():e}function U2(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function W2(e,t){let n=0,r=0,i=e.length,a=t.length;for(;n<i&&r<a;){let i=G2(e.charCodeAt(n)),a=G2(t.charCodeAt(r)),o=K2(e,n,i),s=K2(t,r,a);if(!i&&!a){let i=zge(e,n,o,t,r,s);if(i)return i;n=o,r=s;continue}if(i!==a)return i?1:-1;let c=Bge(e,n,o,t,r,s);if(c)return c;n=o,r=s}return J2(e,n)-J2(t,r)}function G2(e){return e>=48&&e<=57}function K2(e,t,n){let r=t+1;for(;r<e.length&&G2(e.charCodeAt(r))===n;)r++;return r}function zge(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 Bge(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=q2(e,o,n),i=q2(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 q2(e,t,n){let r=0;for(let i=t;i<n;i++)r=r*10+e.charCodeAt(i)-48;return r}function J2(e,t){let n=0,r=t;for(;r<e.length;)n++,r=K2(e,r,G2(e.charCodeAt(r)));return n}function Y2(){return[]}function Vge(e,t){T2(e,`cellSelection`,t?Y2():v2(e.initialState.cellSelection)??Y2())}function Hge(e){e.atoms.cellSelection&&(e.options.autoResetAll??e.options.autoResetCellSelection??!0)&&e._reactivity.schedule(()=>Vge(e))}function Uge(e){e.atoms.expanded&&(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding)&&e._reactivity.schedule(()=>Wge(e))}function Wge(e,t){let n=e.initialState.expanded;T2(e,`expanded`,t?y2():n===!0||Object.assign(y2(),v2(n??{})))}var X2=0;function Gge(e){if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if((e.atoms.pagination?.get()?.pageIndex??X2)===X2)return;Jge(e,!0)}}function Kge(e,t){T2(e,`pagination`,t)}function qge(e,t){Kge(e,n=>{let r=_2(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 Jge(e,t){qge(e,t?X2:e.initialState.pagination?.pageIndex??X2)}function Yge(){return[]}function Z2(e,t){T2(e,`sorting`,t)}function Q2(e,t){Z2(e,t?[]:v2(e.initialState.sorting??[]))}function Xge(e){e.atoms.sorting&&(e.options.autoResetAll??e.options.autoResetSorting??!1)&&Q2(e)}function $2(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(Lge).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 V2}function e4(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 Zge(e){let t=e.table._rowModelFns.sortFns;return tge(e.columnDef.sortFn)?e.columnDef.sortFn:e.columnDef.sortFn===`auto`?$2(e):t?.[e.columnDef.sortFn]??V2}function t4(e,t,n){let r=r4(e,n&&a4(e)),i=t!==void 0;Z2(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&&a4(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 n4(e){return e.columnDef.sortDescFirst??e.table.options.sortDescFirst??e4(e)===`desc`?`desc`:`asc`}function r4(e,t){let n=n4(e),r=o4(e);return r?r!==n&&(e.table.options.enableSortingRemoval??!0)&&(!t||(e.table.options.enableMultiRemove??!0))?!1:r===`desc`?`asc`:`desc`:n}function i4(e){return(e.columnDef.enableSorting??!0)&&(e.table.options.enableSorting??!0)&&!!e.accessorFn}function a4(e){return e.columnDef.enableMultiSort??e.table.options.enableMultiSort??!!e.accessorFn}function o4(e){let t=e.table.atoms.sorting?.get()?.find(t=>t.id===e.id);return t?t.desc?`desc`:`asc`:!1}function Qge(e){return e.table.atoms.sorting?.get()?.findIndex(t=>t.id===e.id)??-1}function $ge(e){Z2(e.table,t=>t.length?t.filter(t=>t.id!==e.id):[])}function e_e(e){let t=i4(e);return n=>{t&&t4(e,void 0,a4(e)?e.table.options.isMultiSortEvent?.(n):!1)}}function t_e(){return e=>E2({feature:`coreRowModelsFeature`,table:e,fnName:`table.getCoreRowModel`,memoDeps:()=>[e.options.data],fn:()=>n_e(e,e.options.data),onAfterUpdate:ige(()=>{Uge(e),Gge(e),Xge(e),Hge(e)})})}function s4(e,t,n,r=0,i){let a=[];for(let o=0;o<n.length;o++){let s=n[o],c=Ige(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=s4(e,t,c.originalSubRows,r+1,c)))}return a}function n_e(e,t){let n={rows:[],flatRows:[],rowsById:y2()};return n.rows=s4(e,n,t),n}function r_e(e){return e._rowModels.coreRowModel||(e._rowModels.coreRowModel=e.options.features.coreRowModel?.(e)??t_e()(e)),e._rowModels.coreRowModel()}function i_e(e){return e.getCoreRowModel()}function a_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 o_e(e){return e.getFilteredRowModel()}function s_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 c_e(e){return e.getGroupedRowModel()}function l_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 u_e(e){return e.getSortedRowModel()}function d_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 f_e(e){return e.getExpandedRowModel()}function p_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 m_e(e){return e.getPaginatedRowModel()}var h_e={constructTableAPIs:e=>{O2(`coreRowModelsFeature`,e,{table_getCoreRowModel:{fn:()=>r_e(e)},table_getPreFilteredRowModel:{fn:()=>i_e(e)},table_getFilteredRowModel:{fn:()=>a_e(e)},table_getPreGroupedRowModel:{fn:()=>o_e(e)},table_getGroupedRowModel:{fn:()=>s_e(e)},table_getPreSortedRowModel:{fn:()=>c_e(e)},table_getSortedRowModel:{fn:()=>l_e(e)},table_getPreExpandedRowModel:{fn:()=>u_e(e)},table_getExpandedRowModel:{fn:()=>d_e(e)},table_getPrePaginatedRowModel:{fn:()=>f_e(e)},table_getPaginatedRowModel:{fn:()=>p_e(e)},table_getRowModel:{fn:()=>m_e(e)}})}};function g_e(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 __e(e,t,n){let r=g_e(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 v_e(e){let t=e.table.getRowsInDisplayOrder(),n=e._displayIndexCache;return t[n]===e?n:-1}function y_e(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 b_e(e,t){if(b2(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 x_e(e,t){if(b2(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 S_e(e,t){return e.getValue(t)??e.table.options.renderFallbackValue}function C_e(e){return nge(e.subRows,e=>e.subRows)}function w_e(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 T_e(e){if(e.parentId)return e.table.getCoreRowModel().rowsById[e.parentId]??e.table.getRow(e.parentId,!0)}function E_e(e){let t=[],n=e;for(;;){let e=n.getParentRow();if(!e)break;t.push(e),n=e}return t.reverse()}function D_e(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=__e(a,e,e.table),n.set(a,o)),r[i]=o}return r}function O_e(e){let t=y2(),n=e.getAllCells();for(let e=0;e<n.length;e++){let r=n[e];t[r.column.id]=r}return t}function k_e(e,t,n,r){return t.options.getRowId?.(e,n,r)??(r?`${r.id}.${n}`:String(n))}function A_e(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 j_e={assignRowPrototype:(e,t)=>{k2(`coreRowsFeature`,e,t,{row_getDisplayIndex:{fn:e=>v_e(e)},row_getAllCellsByColumnId:{fn:e=>O_e(e),memoDeps:e=>[e.getAllCells()]},row_getAllCells:{fn:e=>D_e(e),memoDeps:e=>[e.table.getAllLeafColumns()]},row_getLeafRows:{fn:e=>C_e(e),memoDeps:e=>[e.subRows]},row_getParentRow:{fn:e=>T_e(e)},row_getParentRows:{fn:e=>E_e(e)},row_getUniqueValues:{fn:(e,t)=>x_e(e,t)},row_getValue:{fn:(e,t)=>b_e(e,t)},row_renderValue:{fn:(e,t)=>S_e(e,t)}})},constructTableAPIs:e=>{O2(`coreRowsFeature`,e,{table_getRowsInDisplayOrder:{fn:()=>y_e(e),memoDeps:()=>[e.getPrePaginatedRowModel().rows,e.options.paginateExpandedRows,e.options.paginateExpandedRows===!1?e.atoms.expanded?.get():void 0]},table_getRowId:{fn:(t,n,r)=>k_e(t,e,n,r)},table_getRow:{fn:(t,n)=>A_e(e,t,n)},table_getMaxSubRowDepth:{fn:()=>w_e(e),memoDeps:()=>[e.getCoreRowModel()]}})}};function c4(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 l4(e,t,n=(e,t)=>e===t){e._reactivity.batch(()=>{c4(e,t,n),e._reactivity.commit?.()})}function M_e(e){let t=v2(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 N_e(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 u4(e,t,n){let r=N_e(e,_2(t,e.options));e.optionsStore?e.optionsStore.set(()=>r):e.options=r,n?.syncExternalState!==!1&&l4(e,r.state??null)}var P_e={coreCellsFeature:cge,coreColumnsFeature:Dge,coreHeadersFeature:Pge,coreRowModelsFeature:h_e,coreRowsFeature:j_e,coreTablesFeature:{constructTableAPIs:e=>{O2(`coreTablesFeature`,e,{table_reset:{fn:()=>M_e(e)},table_setOptions:{fn:t=>u4(e,t)}})}}};function F_e(){return{accessor:(e,t)=>typeof e==`function`?{...t,accessorFn:e}:{...t,accessorKey:e},columns:e=>e,display:e=>e,group:e=>e}}function I_e(e){return e}function L_e(e,t={}){return Object.values(e).forEach(e=>{t=e.getInitialState?.(t)??t}),v2(t)}function R_e(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:{...P_e,..._},_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=L_e(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&&b2(i,n)){let e=i[n];return e===void 0?v.initialState[n]:e}return r},{debugName:`table/atoms/${n}`})}c4(v),v.store=Jhe(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:m2,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 z_e(){return y2()}function d4(e,t){e.options.onRowSelectionChange?.(t)}function B_e(e,t){e._lastSelectedRowId=null,d4(e,t?y2():Object.assign(y2(),v2(e.initialState.rowSelection??{})))}function f4(e,t,n){e._lastSelectedRowId=null,d4(e,r=>{if(t=t===void 0?!A2(e,`getIsAllRowsSelected`,h4):t,n?.deselectAll&&!t)return y2();let i=Object.assign(y2(),r),a=e.getPreGroupedRowModel().flatRows;if(t){let e=new Map;a.forEach(t=>{T4(t,e)&&(i[t.id]=!0)})}else a.forEach(e=>{x4(e)&&delete i[e.id]});return i})}function p4(e,t,n){e._lastSelectedRowId=null,d4(e,r=>{let i=t===void 0?!A2(e,`getIsAllPageRowsSelected`,g4):t;if(n?.deselectAll&&!i)return y2();let a=Object.assign(y2(),r);return e.getRowModel().rows.forEach(t=>{w4(a,t.id,i,!0,e,!0)}),a})}function V_e(e){return e.getCoreRowModel()}function H_e(e){let t=e.getCoreRowModel();return A2(e,`getIsSomeRowsSelected`,_4)?O4(t,e):{rows:[],flatRows:[],rowsById:y2()}}function U_e(e){let t=e.getFilteredRowModel();return A2(e,`getIsSomeRowsSelected`,_4)?O4(t,e):{rows:[],flatRows:[],rowsById:y2()}}function W_e(e){let t=e.getSortedRowModel();return A2(e,`getIsSomeRowsSelected`,_4)?O4(t,e):{rows:[],flatRows:[],rowsById:y2()}}function m4(e){return Object.keys(e.atoms.rowSelection?.get()??{})}function h4(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=>!k4(t,n)&&T4(t,e))&&(r=!1)}return r}function g4(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(k4(a,n))!i&&T4(a,r)&&(i=!0);else if(T4(a,r))return!1}return i}function _4(e){return A2(e,`getSelectedRowIds`,m4).length>0}function G_e(e){return e.getPaginatedRowModel().flatRows.filter(e=>x4(e)).some(e=>y4(e)||A2(e,`getIsSomeSelected`,b4))}function K_e(e){return t=>{f4(e,t.target.checked)}}function q_e(e){return t=>{p4(e,t.target.checked)}}function v4(e,t,n){let r=y4(e);d4(e.table,i=>{t=t===void 0?!r:t;let a=Object.assign(y2(),i);return w4(a,e.id,t,(n?.selectChildren??!0)&&C4(e),e.table),!t&&n?.deselectParents&&E4(a,e),a})}function y4(e){return k4(e,e.table.atoms.rowSelection?.get()??{})}function b4(e){return A4(e)===`some`}function J_e(e){return A4(e)===`all`}function x4(e){let t=e.table.options;return typeof t.enableRowSelection==`function`?t.enableRowSelection(e):t.enableRowSelection??!0}function S4(e){let t=e.table.options;return typeof t.enableSubRowSelection==`function`?t.enableSubRowSelection(e):t.enableSubRowSelection??!0}function C4(e){let t=e.table.options;return typeof t.enableMultiRowSelection==`function`?t.enableMultiRowSelection(e):t.enableMultiRowSelection??!0}function Y_e(e,t){let n=x4(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&&C4(e)&&(a.options.isRowRangeSelectionEvent?.(r)??!1))||!X_e(e,s,o,t))&&v4(e,o,t),a._lastSelectedRowId=e.id}}function X_e(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||!C4(s)||!C4(e))return!1;let f=Math.min(c,l),p=Math.max(c,l);return d4(a,e=>{let t=Object.assign(y2(),e);for(let e=f;e<=p;e++){let s=o[e];x4(s)&&C4(s)&&(w4(t,s.id,n,i,a),!n&&r?.deselectParents&&E4(t,s))}return t}),!0}function w4(e,t,n,r,i,a){let o=i.getRow(t,!0);n?(C4(o)||Object.keys(e).forEach(t=>delete e[t]),x4(o)&&(e[t]=!0)):(!a||x4(o))&&delete e[t],r&&o.subRows.length&&S4(o)&&o.subRows.forEach(t=>w4(e,t.id,n,r,i,a))}function T4(e,t){if(!x4(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(!S4(r)){s=!1;break}c=r.parentId}return o.forEach(e=>t.set(e,s)),s}function E4(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 D4(e,t,n,r){let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=k4(o,t);if(s&&(n.push(o),r[o.id]=o),o.subRows.length){let e=D4(o.subRows,t,n,r);if(s){let t=Object.create(Object.getPrototypeOf(o));Qhe(t,o),t.subRows=e,i.push(t)}}else s&&i.push(o)}return i}function O4(e,t){let n=[],r=y2(),i=t.atoms.rowSelection?.get()??{};return{rows:D4(e.rows,i,n,r),flatRows:n,rowsById:r}}function k4(e,t){return!!(b2(t,e.id)&&t[e.id])}function A4(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(x4(o)&&(i=!0,k4(o,t)?n=!0:r=!1),o.subRows.length){let e=A4(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 Z_e={initTableInstanceData:e=>{e._lastSelectedRowId=null},resetTableInstanceData:e=>{e._lastSelectedRowId=null},getInitialState:e=>({rowSelection:z_e(),...e}),getDefaultTableOptions:e=>({onRowSelectionChange:x2(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableRowRangeSelection:!0,enableSubRowSelection:!0,isRowRangeSelectionEvent:e=>{let t=e;return!!(t.shiftKey||t.nativeEvent?.shiftKey)}}),assignRowPrototype:(e,t)=>{k2(`rowSelectionFeature`,e,t,{row_toggleSelected:{fn:(e,t,n)=>v4(e,t,n)},row_getIsSelected:{fn:e=>y4(e)},row_getIsSomeSelected:{fn:e=>b4(e),memoDeps:e=>[e.subRows,e.table.atoms.rowSelection?.get(),e.table.options.enableRowSelection]},row_getIsAllSubRowsSelected:{fn:e=>J_e(e),memoDeps:e=>[e.subRows,e.table.atoms.rowSelection?.get(),e.table.options.enableRowSelection]},row_getCanSelect:{fn:e=>x4(e)},row_getCanSelectSubRows:{fn:e=>S4(e)},row_getCanMultiSelect:{fn:e=>C4(e)},row_getToggleSelectedHandler:{fn:(e,t)=>Y_e(e,t)}})},constructTableAPIs:e=>{O2(`rowSelectionFeature`,e,{table_setRowSelection:{fn:t=>d4(e,t)},table_resetRowSelection:{fn:t=>B_e(e,t)},table_toggleAllRowsSelected:{fn:(t,n)=>f4(e,t,n)},table_toggleAllPageRowsSelected:{fn:(t,n)=>p4(e,t,n)},table_getPreSelectedRowModel:{fn:()=>V_e(e)},table_getSelectedRowModel:{fn:()=>H_e(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getCoreRowModel()]},table_getFilteredSelectedRowModel:{fn:()=>U_e(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getFilteredRowModel()]},table_getGroupedSelectedRowModel:{fn:()=>W_e(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getSortedRowModel()]},table_getSelectedRowIds:{fn:()=>m4(e),memoDeps:()=>[e.atoms.rowSelection?.get()]},table_getIsAllRowsSelected:{fn:()=>h4(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getFilteredRowModel(),e.options.enableRowSelection,e.options.enableSubRowSelection]},table_getIsAllPageRowsSelected:{fn:()=>g4(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getPaginatedRowModel(),e.options.enableRowSelection,e.options.enableSubRowSelection]},table_getIsSomeRowsSelected:{fn:()=>_4(e),memoDeps:()=>[e.atoms.rowSelection?.get()]},table_getIsSomePageRowsSelected:{fn:()=>G_e(e),memoDeps:()=>[e.atoms.rowSelection?.get(),e.getPaginatedRowModel(),e.options.enableRowSelection]},table_getToggleAllRowsSelectedHandler:{fn:()=>K_e(e)},table_getToggleAllPageRowsSelectedHandler:{fn:()=>q_e(e)}})}},Q_e={getInitialState(e){return{sorting:Yge(),...e}},getDefaultColumnDef(){return{sortFn:`auto`,sortUndefined:1}},getDefaultTableOptions(e){return{autoResetSorting:!1,onSortingChange:x2(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}},assignColumnPrototype(e,t){k2(`rowSortingFeature`,e,t,{column_getAutoSortFn:{fn:e=>$2(e)},column_getAutoSortDir:{fn:e=>e4(e)},column_getSortFn:{fn:e=>Zge(e)},column_toggleSorting:{fn:(e,t,n)=>t4(e,t,n)},column_getFirstSortDir:{fn:e=>n4(e)},column_getNextSortingOrder:{fn:(e,t)=>r4(e,t)},column_getCanSort:{fn:e=>i4(e)},column_getCanMultiSort:{fn:e=>a4(e)},column_getIsSorted:{fn:e=>o4(e)},column_getSortIndex:{fn:e=>Qge(e)},column_clearSorting:{fn:e=>$ge(e)},column_getToggleSortingHandler:{fn:e=>e_e(e)}})},constructTableAPIs(e){O2(`rowSortingFeature`,e,{table_setSorting:{fn:t=>Z2(e,t)},table_resetSorting:{fn:t=>Q2(e,t)}})}},$_e=typeof window>`u`?I.useEffect:I.useLayoutEffect;function eve(e,t){let[{table:n,rootSource:r}]=(0,I.useState)(()=>{let t=R_e({...e,features:{coreReactivityFeature:Zhe(),...e.features}});return t.Subscribe=(e=>qhe({...e,source:e.source??t.store})),t.FlexRender=Rhe,{table:t,rootSource:Xhe(t.store,m2)}}),i=n;u4(i,t=>({...t,...e}),{syncExternalState:!1});let a=i.options.state,o=r.get(),s=g2(r,t,{compare:m2});return $_e(()=>{r.markCommitted(o),l4(i,a??null,m2)}),(0,I.useMemo)(()=>({...n,options:e,state:s}),[n,e,s])}var tve=e=>t=>{let n=t.currentTarget;n.scrollWidth>Math.ceil(n.getBoundingClientRect().width)?n.title=e:n.removeAttribute(`title`)},j4=({text:e,className:t})=>(0,R.jsx)(`span`,{className:g(`truncate`,t),onMouseEnter:tve(e),children:e}),M4=e=>(0,R.jsx)(`span`,{className:`text-faint-foreground`,children:e}),N4=(e,t)=>{if(t==null)return M4(`—`);let n=Rb(e,t)??``;switch(e.kind){case`text`:return e.link?(0,R.jsx)(sC,{format:e.link,value:n,className:`block min-w-0 truncate`}):(0,R.jsx)(j4,{text:n});case`id`:return(0,R.jsx)(j4,{text:n,className:`font-mono text-xs text-muted-foreground`});case`money`:return(0,R.jsx)(`span`,{className:`tabular-nums`,children:n});case`date`:return(0,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n});case`datetime`:return(0,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,title:e.relative?Kf(Number(t)):Ib(`shownIn`,Ff(Number(t),Ef())),children:n});case`number`:return(0,R.jsx)(`span`,{className:`tabular-nums`,children:n});case`signed`:return(0,R.jsx)(`span`,{className:g(`tabular-nums`,Number(t)<0?`text-danger-text`:`text-success-text`),children:n});case`percent`:return Number(t)===0?M4(`—`):(0,R.jsx)(`span`,{className:`tabular-nums`,children:n});case`status`:return(0,R.jsx)(dd,{tone:e.tones?.[String(t)]??`neutral`,color:K0(e.colors,t),shape:e.shape,children:n});case`relation`:return(0,R.jsx)(j4,{text:n,className:`font-medium text-primary-text hover:underline`});case`boolean`:return t?(0,R.jsx)(`span`,{className:`inline-flex size-4 items-center justify-center rounded-full bg-success-soft text-success-text`,children:(0,R.jsx)(Ci,{className:`size-3`,strokeWidth:3})}):M4(Ib(`no`));case`file`:{let e=wb(t);if(!e)return M4(`—`);if(`missing`in e)return(0,R.jsx)(j4,{text:e.name,className:`text-danger-text`});let n=Mb(t,{width:20,height:20});return(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[n?(0,R.jsx)(QS,{image:n,className:`size-5 shrink-0 rounded-sm object-cover`}):(0,R.jsx)(Xa,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(j4,{text:e.name})]})}case`user`:{let e=Ly(String(t));return(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-2 truncate`,children:[(0,R.jsx)(nd,{initials:e.initials,hue:e.hue,size:`xs`,className:`ring-0`}),(0,R.jsx)(j4,{text:e.name,className:`text-muted-foreground`})]})}}},nve=I_e({rowSortingFeature:Q_e,rowSelectionFeature:Z_e}),P4=F_e(),rve=e=>P4.columns(e.map(e=>P4.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):N4(e,t.getValue())}))),ive=(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}]}),ave=({total:e,selectedCount:t,bulkActions:n=[],className:r})=>(0,R.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,R.jsxs)(`span`,{className:`flex items-center tabular-nums`,children:[Tf(e),t>0&&(0,R.jsx)(`span`,{className:`ml-3 font-medium text-primary-text`,children:Ib(`selected`,Sf(t))}),t>0&&n.map(e=>(0,R.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))]})}),ove=(e,t)=>typeof e.label==`string`?e.label:e.label(t),sve=(e,t)=>e.filter(e=>e.available?.(t)??!0),cve=({row:e,actions:t})=>{let{open:n,setOpen:r,place:i,button:a,menu:o}=xS();return(0,R.jsxs)(`div`,{className:`relative flex justify-center bg-inherit`,onClick:e=>e.stopPropagation(),children:[(0,R.jsx)(`button`,{ref:a,type:`button`,"aria-label":Ib(`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,R.jsx)(Yi,{className:`size-4`})}),n&&(0,ps.createPortal)((0,R.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=ove(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,R.jsx)(`li`,{role:`none`,children:t.link?(0,R.jsx)(Ku,{role:`menuitem`,to:t.link(e),onClick:()=>r(!1),className:o,children:i}):(0,R.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)]})},lve=e=>52+Math.ceil(String(e).length*1.33)*7,F4=.6,I4=(e,t)=>Math.max(e.minWidth??0,e.width*t),uve=(e,t)=>e.fixed?`${Math.max(e.minWidth??0,e.width)}px`:`minmax(${I4(e,t)}px, ${e.width}fr)`,L4=(e,t,n=0,r=F4)=>`${t}px ${e.map(e=>uve(e,r)).join(` `)}${n>0?` ${n}px`:``}`,dve=(e,t,n=0,r=F4)=>t+n+e.reduce((e,t)=>e+(t.fixed?Math.max(t.minWidth??0,t.width):I4(t,r)),0),fve=()=>{let e=(0,I.useRef)(null),t=(0,I.useRef)(null),[n,r]=(0,I.useState)({scrolled:!1,more:!1}),i=(0,I.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,I.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}},pve=`protobase:pinned:`,mve=(e,t)=>`${pve}${e}:${t}`,hve=(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),gve=(e,t,n)=>u(()=>e.setItem(t,JSON.stringify(n)),void 0),_ve=(e,t=[])=>{let[n,r]=(0,I.useState)(()=>e?hve(localStorage,e):void 0),i=(0,I.useCallback)(t=>{r(t),e&&gve(localStorage,e,t)},[e]);return[n??t,i]},vve=e=>{let t=e.findIndex(e=>e.title);return t<0||t>1?[]:e.slice(0,t+1).map(e=>e.id)},yve=e=>Object.fromEntries(e.map(({id:e,width:t,minWidth:n,fixed:r})=>[e,{width:t,minWidth:n,fixed:r}])),bve=(e,t)=>{let n=e.map(e=>e.id).sort().join(` `),[r,i]=(0,I.useState)(),a=r?.key===n?r:void 0;!a&&t.length>0&&i({key:n,sizes:yve(tx(e,t))});let o=a?.sizes;return(0,I.useMemo)(()=>o?e.map(e=>({...e,...o[e.id]})):e,[e,o])},R4=e=>e===`money`||e===`number`||e===`signed`||e===`percent`,z4=()=>Ib(`unsortable`),xve=({header:e,pinned:t,sortable:n,onTogglePin:r})=>{let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null);return(0,I.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,R.jsxs)(`div`,{ref:o,className:`relative ml-auto shrink-0`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":Ib(`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,R.jsx)(Yi,{className:`size-3.5`})}),i&&(0,R.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,R.jsx)(`li`,{role:`none`,children:(0,R.jsx)(`span`,{role:`menuitem`,"aria-disabled":`true`,className:`block min-h-9 whitespace-nowrap px-3 py-1.5 text-muted-foreground`,children:z4()})}),(0,R.jsx)(`li`,{role:`none`,children:(0,R.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:Ib(t?`unpin`:`pinToLeft`)})})]})]})},Sve=({sorted:e})=>e===`asc`?(0,R.jsx)(Xr,{className:`size-3 text-foreground`}):e===`desc`?(0,R.jsx)(Br,{className:`size-3 text-foreground`}):(0,R.jsx)(ji,{className:`size-3 opacity-0 group-hover/head:opacity-100`}),B4=({spec:e})=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.header}),e.highlight&&(0,R.jsx)(`span`,{className:`rounded bg-primary px-1 text-[10px] font-semibold uppercase leading-4 text-primary-foreground`,children:Ib(`new`)})]}),Cve=({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,R.jsxs)(`div`,{className:`grid h-8 shrink-0 items-center border-b bg-surface text-body font-medium text-muted-foreground`,style:{gridTemplateColumns:L4(t,n,a,o)},role:`row`,children:[(0,R.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,R.jsx)(tg,{checked:!1,indeterminate:r>0,label:Ib(r>0?`clearSelection`:`noRowsSelected`),disabled:r===0,onChange:d,className:g(r===0&&`opacity-60`)}),n>40&&(0,R.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,R.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,R.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`,R4(e.kind)&&`justify-end`,`hover:text-foreground`,t&&`text-foreground`),children:[(0,R.jsx)(B4,{spec:e}),(0,R.jsx)(Sve,{sorted:t})]}):(0,R.jsx)(`div`,{title:z4(),className:g(`flex h-full min-w-0 flex-1 items-center gap-1 pl-3 pr-1 text-left`,R4(e.kind)&&`justify-end`),children:(0,R.jsx)(B4,{spec:e})}),(0,R.jsx)(`div`,{className:`pr-1.5`,children:(0,R.jsx)(xve,{header:e.header,pinned:r,sortable:!!e.sortable,onTogglePin:()=>u(e.id)})})]},e.id)}),a?(0,R.jsx)(`div`,{className:`sticky right-0 z-10 h-full bg-inherit`}):null]}),V4=e=>({gridTemplateColumns:L4(e.specs,e.gutter,e.trailing,e.minScale),height:e.height,transform:`translateY(${e.offset}px)`}),H4=(e,t)=>g(`flex h-full min-w-0 items-center overflow-hidden whitespace-nowrap px-3`,R4(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)]`),U4=(e,t)=>t&&e.id in t?{left:t[e.id]}:void 0,W4=({width:e,index:t,selectable:n,selected:r,onToggle:i,edge:a})=>(0,R.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,R.jsx)(tg,{checked:!!r,label:Ib(`selectRow`,t+1)}),e>40&&(0,R.jsx)(`span`,{className:`min-w-6 text-right text-[11px] tabular-nums text-faint-foreground`,children:Sf(t+1)})]}),wve=(e,t,n)=>({gridTemplateColumns:L4(e.specs,e.gutter,e.trailing,e.minScale),height:e.height,top:e.offset,transform:t===0?void 0:`translateY(${t}px)`,transition:n}),Tve=e=>t=>{t.target.closest(`a`)||e()},G4=({cells:e,selected:t,onToggle:n,onOpen:r,menu:i,handle:a,rowRef:o,dragY:s,transition:c,dragging:l,...u})=>(0,R.jsxs)(`div`,{ref:o,role:`row`,onClick:r&&Tve(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?V4(u):wve(u,s,c),children:[a?(0,R.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,R.jsx)(W4,{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,R.jsx)(`div`,{role:n?`gridcell`:`cell`,...n,className:g(H4(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:U4(e,u.pins),children:t},e.id)),i&&(0,R.jsx)(`div`,{className:`sticky right-0 z-10 flex h-full items-center justify-center bg-inherit`,children:i})]}),K4=[`w-3/4`,`w-1/2`,`w-2/3`,`w-5/6`,`w-2/5`],Eve=e=>(0,R.jsxs)(`div`,{role:`row`,"aria-busy":!0,className:`absolute inset-x-0 top-0 grid items-center border-b bg-background`,style:V4(e),children:[(0,R.jsx)(W4,{width:e.gutter,index:e.index,selectable:!1,edge:e.scrolled&&!e.lastPinned}),e.specs.map((t,n)=>(0,R.jsx)(`div`,{className:H4(t,e),style:U4(t,e.pins),children:(0,R.jsx)(Uu,{className:g(`h-2.5`,K4[(e.index+n)%K4.length],R4(t.kind)&&`ml-auto`)})},t.id))]}),Dve=(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}}},q4=(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)},J4=(e,t)=>Math.max(0,Math.min(40,e-t*40)),Y4=({total:e,rowAt:t,loadRows:n,revision:r,latencyMs:i},a,o)=>{let s=(0,I.useMemo)(()=>Dve(40,60),[t,n]),[c,l]=(0,I.useState)(0),u=Math.floor(a/40),d=Math.floor(o/40),f=!n&&i===0;(0,I.useEffect)(()=>{if(f)return;let r=q4(u*40,d*40,40).filter(e=>!s.hasPage(e)),a=t=>J4(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,I.useRef)(r);return(0,I.useEffect)(()=>{if(!n||r===p.current)return;p.current=r;let t=q4(u*40,d*40,40);s.keepOnly(t);for(let r of t.filter(e=>s.hasPage(e)))n(r*40,J4(e,r)).then(e=>{s.setPage(r,e),l(e=>e+1)})},[s,r,n,u,d,e]),(0,I.useCallback)(e=>f?t(e):s.get(e),[s,f,t,c])},Ove=1e7,X4=(e,t,n)=>{let r=e*t,i=Math.min(r,Ove);return{rowHeight:t,trueHeight:r,contentHeight:i,scaled:r>i,maxTop:Math.max(0,r-n),maxScroll:Math.max(0,i-n)}},kve=(e,t)=>!e.scaled||t<=0?t:t>=e.maxScroll?e.maxTop+t-e.maxScroll:t/e.maxScroll*e.maxTop,Z4=(e,t)=>!e.scaled||t<=0?t:t>=e.maxTop?e.maxScroll+t-e.maxTop:t/e.maxTop*e.maxScroll,Ave=(e,t,n,r)=>{let i=t*e.rowHeight;return e.scaled?i-n+r:i},Q4=(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)}},jve=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},$4=e=>e===(document.scrollingElement??document.documentElement),Mve=e=>$4(e)?window:e,e3=e=>Number.parseFloat(e)||0,Nve=e=>{let t=getComputedStyle(e),n=$4(e)?{top:0,height:e.clientHeight}:{top:e.getBoundingClientRect().top+e.clientTop,height:e.clientHeight},r=e3(t.scrollPaddingTop);return{top:n.top+r,height:Math.max(0,n.height-r-e3(t.scrollPaddingBottom))}},t3=6,n3=(e,t,n)=>{let r=X4(t,n,e.height),i=kve(r,e.position);return{geometry:r,top:i,topIndex:Math.floor(Math.max(0,i)/n),...Q4(t,i,n,e.height,t3)}},r3=({total:e,rowHeight:t,initialIndex:n,inset:r=0,settle:i,ready:a=!0,onScroll:o})=>{let s=(0,I.useRef)(null),c=(0,I.useRef)(null),[l,u]=(0,I.useState)({position:0,height:0}),d=(0,I.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,I.useCallback)(()=>{let e=s.current;if(!e||!c.current)return;let t=Nve(c.current),n=d.current.inset;return{position:t.top+n-e.getBoundingClientRect().top,height:Math.max(0,t.height-n)}},[]),p=(0,I.useRef)({pending:!0,laidOut:!1}),m=(0,I.useRef)(l);m.current=l;let h=(0,I.useCallback)(()=>{let e=f();if(!e)return;let t=m.current,{total:n,rowHeight:r,onScroll:i}=d.current,a=n3(t,n,r),o=n3(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,I.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+=Z4(X4(n,r,e.height),i*r)-e.position:e.position>0&&(t.scrollTop=0)},[f]);(0,I.useLayoutEffect)(()=>{let e=s.current;if(!e)return;let t=jve(e);c.current=t;let n=Mve(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,I.useLayoutEffect)(()=>{g(),h()});let _=(0,I.useCallback)(e=>{let t=f();if(!t||!c.current)return;let n=X4(d.current.total,d.current.rowHeight,t.height);c.current.scrollTop+=Z4(n,e)-t.position,h()},[f,h]),v=n3(l,e,t),y=i?i(v.top):v.top,{first:b,last:x}=i?Q4(e,y,t,l.height,t3):v,S=Array.from({length:x-b+1},(e,t)=>({index:b+t,offset:Ave(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:_}},Pve=e=>e===`ArrowUp`||e===`ArrowDown`||e===`ArrowLeft`||e===`ArrowRight`,Fve=(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},Ive=(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)},i3=e=>`${e.index}:${e.column}`,Lve=({editor:e,columns:t,total:n,rowAt:r,onOpenRow:i,container:a})=>{let[o,s]=(0,I.useState)(),[c,l]=(0,I.useState)(!1),u=(0,I.useRef)(!1),d=(0,I.useRef)(!1);if((0,I.useEffect)(()=>{if(!o||c||!u.current)return;u.current=!1;let e=a.current?.querySelector(`[data-cell="${i3(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?Ive(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":i3(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!==i3(o))return;let a=e.key===`Tab`?e.shiftKey?`ArrowLeft`:`ArrowRight`:e.key;if(Pve(a)){let i=Fve(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)}}},Rve=({ids:e,rowAt:t,reorder:n,children:r})=>{let i=T_(w_(bv,{activationConstraint:{distance:4}}),w_(Sv,{activationConstraint:{delay:250,tolerance:5}}),w_(fv,{coordinateGetter:Ay})),a=t=>e.indexOf(String(t)),o=e=>{let r=t(a(e));return r?n.label(r):Ib(`row`)};return(0,R.jsx)(fy,{sensors:i,collisionDetection:P_,onDragEnd:({active:e,over:t})=>{t&&e.id!==t.id&&n.onMove(a(e.id),a(t.id))},accessibility:{announcements:{onDragStart:({active:t})=>Ib(`pickedUp`,o(t.id),a(t.id)+1,e.length),onDragOver:({active:t,over:n})=>n?Ib(`isOver`,o(t.id),a(n.id)+1,e.length):void 0,onDragEnd:({active:t,over:n})=>n?Ib(`droppedAt`,o(t.id),a(n.id)+1,e.length):Ib(`putBack`,o(t.id)),onDragCancel:({active:e})=>Ib(`cancelled`,o(e.id),a(e.id)+1)},screenReaderInstructions:{draggable:Ib(`reorderInstructions`)}},children:(0,R.jsx)(Ey,{items:e,strategy:Cy,children:r})})},zve=({row:e,label:t,...n})=>{let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,transition:c,isDragging:l}=Oy({id:e.id}),u=(0,R.jsx)(`button`,{ref:o,type:`button`,"aria-label":Ib(`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,R.jsx)(aa,{className:`size-4`})});return(0,R.jsx)(G4,{...n,rowRef:a,handle:u,dragY:s?.y??0,transition:c,dragging:l})},a3=32,o3=({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=!Eu(),D=(h??(E?[]:vve(e))).join(` `),[O,k]=_ve(m,(0,I.useMemo)(()=>D?D.split(` `):[],[D])),A=(0,I.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,ee]=(0,I.useState)(n?[{id:n.columnId,desc:n.direction===`desc`}]:[]),te=o?[{id:o.columnId,desc:o.direction===`desc`}]:N,ne=e=>{let t=typeof e==`function`?e(te):e,n=t[0];s&&n&&s({columnId:n.id,direction:n.desc?`desc`:`asc`}),o||ee(t)},[re,ie]=(0,I.useState)({}),ae=(0,I.useMemo)(()=>rve(A),[A]),oe=te[0],se=!!(!o&&n&&oe&&oe.id===n.columnId&&(oe.desc?`desc`:`asc`)!==n.direction),ce=t.rowAt,le=(0,I.useCallback)(e=>ce(se?M-1-e:e),[ce,se,M]),[ue]=(0,I.useState)(r),{ref:de,geometry:P,rows:fe,first:pe,last:me}=r3({total:M,rowHeight:T,initialIndex:ue,inset:a3,onScroll:i&&(e=>i(e/T))}),he=E||!_?40:lve(M),F=Y4({total:M,rowAt:ce?le:void 0,loadRows:t.loadRows,revision:t.revision,latencyMs:a},pe,me),ge=(0,I.useCallback)(e=>{let t=F(e),n=t&&f?.get(t.id);return n?{...t,...n}:t},[F,f]),_e=fe.map(({index:e,offset:t})=>({index:e,offset:t,row:ge(e)})),ve=(0,I.useMemo)(()=>_e.flatMap(({row:e})=>e?[e]:[]),[ge,pe,me]),ye=bve(A,ve),be=eve({features:nve,columns:ae,data:ve,state:{sorting:te,rowSelection:re},onSortingChange:ne,onRowSelectionChange:ie,manualSorting:!0,enableMultiSort:!1,enableSortingRemoval:!1,getRowId:e=>e.id}),xe=new Map(be.getRowModel().rows.map(e=>[e.id,e])),Se=Object.keys(re).length,Ce=(0,I.useRef)(new Map);for(let e of be.getRowModel().rows)e.getIsSelected()&&Ce.current.set(e.id,e.original);let we=u&&u.length>0?40:0,Te=E?1:F4,Ee=fve(),De=(0,I.useRef)(null),Oe=()=>{Ee.onScroll(),De.current&&Ee.ref.current&&(De.current.scrollLeft=Ee.ref.current.scrollLeft)},[ke,Ae]=(0,I.useState)({});(0,I.useLayoutEffect)(()=>{let e=De.current?.querySelector(`[role=row]`);if(!e)return;let t=he,n={};for(let r of j)n[r]=t,t+=e.querySelector(`[data-col-id="${r}"]`)?.offsetWidth??0;JSON.stringify(ke)!==JSON.stringify(n)&&Ae(n)});let je=j.at(-1),Me=e=>k(O.includes(e)?O.filter(t=>t!==e):[...O,e]),Ne=be.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)}))),Pe=(0,I.useRef)(null),Fe=Lve({editor:d,columns:(0,I.useMemo)(()=>A.map(e=>e.id),[A]),total:M,rowAt:ge,onOpenRow:c,container:Pe}),Ie=(A.find(e=>e.title)??A[0])?.id,Le=dve(ye,he,we,Te),Re=S===`own`,ze=(0,R.jsx)(`div`,{ref:De,className:g(`sticky z-20 shrink-0 overflow-hidden`,Re?`top-0`:`top-[var(--pb-sticky-top,0px)]`),children:(0,R.jsx)(`div`,{style:{minWidth:Le},children:(0,R.jsx)(Cve,{cells:Ne,specs:ye,gutter:he,trailing:we,minScale:Te,pins:ke,lastPinned:je,scrolled:Ee.scrolled,onTogglePin:Me,selectable:w,selectedCount:Se,onClearSelection:()=>ie({})})})}),Be=_e.map(({index:e,offset:t,row:n})=>{let r={specs:ye,gutter:he,index:e,offset:t,height:T,selectable:w,trailing:we,minScale:Te,scrolled:Ee.scrolled,pins:ke,lastPinned:je},i=n?xe.get(n.id):void 0;if(!i||!n)return(0,R.jsx)(Eve,{...r},`skeleton-${e}`);let a=we?sve(u,n):[],o={...r,selected:i.getIsSelected(),onToggle:()=>i.toggleSelected(),onOpen:c?()=>c(n):void 0,menu:a.length>0?(0,R.jsx)(cve,{row:n,actions:a}):void 0,cells:i.getAllCells().map(t=>{let r=(0,R.jsx)(be.FlexRender,{cell:t}),i=!!d?.editable(n,t.column.id),a=l&&t.column.id===Ie&&!i?(0,R.jsx)(Ku,{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),...Fe?Fe.cell(e,n,t.column.id,a):{content:a}}})};return b?(0,R.jsx)(zve,{...o,row:n,label:b.label(n)},n.id):(0,R.jsx)(G4,{...o},n.id)}),Ve=(0,R.jsx)(`div`,{ref:Ee.attach,onScroll:Oe,className:`overflow-x-auto overflow-y-hidden overscroll-x-contain [-webkit-overflow-scrolling:touch]`,children:(0,R.jsx)(`div`,{ref:de,className:`relative`,style:{minWidth:Le,height:P.contentHeight},children:b?(0,R.jsx)(Rve,{ids:Array.from({length:M},(e,t)=>ge(t)?.id??`missing-${t}`),rowAt:ge,reorder:b,children:Be}):Be})});return(0,R.jsxs)(`div`,{ref:Pe,role:`grid`,"aria-rowcount":M,onKeyDown:Fe?.onKeyDown,className:g(`flex flex-col rounded-lg border bg-background`,Re?`min-h-0 overflow-hidden`:`overflow-clip`,C),style:x&&Re?{height:a3+M*T+2}:void 0,children:[(0,R.jsxs)(`div`,{className:g(`relative`,Re&&`flex min-h-0 flex-1 flex-col`),children:[Re?(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,children:[ze,Ve]}):(0,R.jsxs)(R.Fragment,{children:[ze,Ve]}),Ee.more&&(0,R.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,R.jsx)(ave,{total:M,className:Re?void 0:`sticky bottom-[var(--pb-sticky-bottom,0px)] z-20`,selectedCount:Se,bulkActions:ive(p??[],Object.keys(re).flatMap(e=>Ce.current.get(e)??[])).map(({action:e,rows:t,skipped:n})=>({label:e.label(t.length),destructive:e.destructive,onRun:()=>{e.onRun(t,n),ie({}),Ce.current.clear()}}))})]})},Bve=500,s3=async(e,t,n)=>{let r=[],i={},a;do{let o=await e.search(t,{...n,pageSize:Bve,...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}},c3=Un(),l3=(...e)=>{let t=e.filter(e=>!!e);return t.length===1?t[0]:t.map(e=>`(${e})`).join(` AND `)},u3=e=>e==null?void 0:String(e),Vve=(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=u3(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},Hve=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 s3(e,a.name,{filter:l3(Fn(c3.in(i.field,r)),i.filter),fields:[i.field,o]})).items.flatMap(e=>{let t=u3(e[i.field]),n=u3(e[o]);return t===void 0||n===void 0?[]:[[t,n]]})},Uve=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 Hve(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=W0(t,n,s,u),f=await s3(e,s.name,{filter:l3(Fn(c3.in(a.field,l)),a.filter),...a.sort&&{orderBy:a.sort},fields:u,labels:d});return Vve(c,G0(t,s,u,f.items,f.labels),a.field)},Wve=5e3,Gve=({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?H.page(i.name,o,s,40,e):[...H.page(i.name,o,s,40,e),l],d=W0(n,r,i,a),f=jx(r[i.name]),p=async e=>e.nextPageToken===``?e.items.length:e.totalSizeEstimate>Wve?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=>fx(i,e)),_=G0(n,i,a,Mx(i,h.items,h.photos),h.labels),v=await Promise.all(c.map(e=>Uve({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}},d3=({resources:e,views:t,model:n,columns:r,filter:i,orderBy:a,related:o})=>{let s=U(),c=Om(),l=r.join(`,`),u=JSON.stringify(o??[]),d=(0,I.useMemo)(()=>Gve({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=Ah({queryKey:[...H.first(n.name,i,a),l],queryFn:async()=>(await c.invalidateQueries({queryKey:H.pages(n.name,i,a),refetchType:`none`}),d.page(0))});return{source:(0,I.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:[...H.first(n.name,i,a),l]}},Kve=`protobase:embedded-display:`,qve=e=>`${Kve}${e}`,Jve=(e,t)=>u(()=>e.getItem(t)??void 0,void 0),Yve=(e,t,n)=>u(()=>e.setItem(t,n),void 0),f3=(e,t,{picked:n,preferred:r})=>{let i=Jx(e).map(e=>e.name);return n!==void 0&&i.includes(n)?n:Bx(e,t,r!==void 0&&i.includes(r)?r:void 0)},p3=(e,t,n,{resource:r=e.name,...i})=>lS({kind:`list`,resource:r},i,{...cS(e,t,n),display:Bx(t,n)}),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`}}),m3=`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`,h3=({chips:e,className:t})=>(0,R.jsx)(`ul`,{className:g(`flex flex-wrap gap-1.5`,t),"aria-label":Q(`filters`),children:e.map(e=>(0,R.jsx)(`li`,{className:m3,children:e.label},e.key))}),g3=({chips:e})=>(0,R.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,t)=>(0,R.jsxs)(`span`,{className:m3,children:[t>0&&(0,R.jsx)(`span`,{className:`sr-only`,children:`, `}),e.label]},e.key))}),Xve=e=>e.map(e=>e.label).join(`, `),_3=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`}}),Zve=`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`,v3=({chips:e,lockedLabels:t=[],onRemove:n,onClear:r,scroll:i})=>e.length===0&&t.length===0?null:(0,R.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,R.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,R.jsx)(ite,{className:`size-3 text-muted-foreground`}),e]},e)),e.map(e=>(0,R.jsxs)(`span`,{className:Zve,children:[e.label,(0,R.jsx)(`button`,{type:`button`,"aria-label":_3(`remove`,e.label),onClick:()=>n(e.key),className:`rounded-full p-0.5 hover:bg-primary-border/60`,children:(0,R.jsx)(ds,{className:`size-3`})})]},e.key)),e.length>0&&(0,R.jsx)(`button`,{type:`button`,onClick:r,className:`ml-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:_3(`clearAll`)})]}),Qve=[`today`,`7d`,`30d`,`year`],$ve=new Set([`today`,`yesterday`,`24h`,`7d`,`30d`,`90d`,`month`,`quarter`,`year`]),y3=e=>$ve.has(e)?_3(e):void 0,eye=({value:e,presets:t=Qve,onChange:n})=>(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let r=y3(t);return(0,R.jsx)(`button`,{type:`button`,disabled:!r,title:r?void 0:_3(`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??_3(`unsupported`,t)},t)})}),b3=({label:e,onRemove:t})=>(0,R.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,R.jsx)(`span`,{className:`truncate`,children:e}),(0,R.jsx)(`button`,{type:`button`,"aria-label":Bd(`remove`,e),className:`rounded p-0.5 hover:bg-primary-border/60`,onMouseDown:e=>e.preventDefault(),onClick:t,children:(0,R.jsx)(ds,{className:`size-3`})})]}),x3={facets:{},toggles:[]},S3=(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}}},C3=(e,t)=>({...e,toggles:e.toggles.includes(t)?e.toggles.filter(e=>e!==t):[...e.toggles,t]}),w3=(e,t,n)=>{let{[t]:r,...i}=e.ranges??{};return{...e,ranges:n?{...i,[t]:n}:i}},T3=(e,t)=>e.options.find(e=>e.value===t)?.label??e.labels?.[t]??t,E3=(e,t)=>{let n=e.facets.flatMap(e=>(t.facets[e.id]??[]).map(t=>({key:`facet:${e.id}:${t}`,label:`${e.label}: ${T3(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:y3(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]},D3=(e,t)=>{if(t===`date`)return{...e,date:void 0};let[n,r,i]=t.split(`:`);if(n===`range`)return w3(e,r,void 0);if(n===`toggle`)return C3(e,r);if(n===`facet`)return S3(e,r,i);throw Error(`Unknown filter chip key: ${t}`)},O3=(e,t)=>e.toLowerCase().includes(t.trim().toLowerCase()),tye=(e,t)=>e.onSearch?e.options:e.options.filter(e=>O3(e.label,t)),nye=(e,t,n)=>t===0?-1:n===`ArrowDown`?e<0?0:(e+1)%t:e<0?t-1:(e-1+t)%t,rye=({config:e,selected:t,onToggle:n,inline:r=!1})=>{let i=(0,I.useId)(),a=(0,I.useRef)(null),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(-1),f=r||c,p=tye(e,o),m=(0,I.useRef)(e.onSearch);m.current=e.onSearch,(0,I.useEffect)(()=>()=>m.current?.(``),[]);let h=t=>{s(t),d(-1),e.onSearch?.(t)};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.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,R.jsx)(vo,{className:`size-3.5 shrink-0 text-muted-foreground`}),t.map(t=>(0,R.jsx)(b3,{label:T3(e,t),onRemove:()=>n(t)},t)),(0,R.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?``:_3(`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(nye(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,R.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,R.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,R.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,R.jsx)(Ci,{className:`size-3`,strokeWidth:3})}),(0,R.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:Sf(e.count)})]},e.value)}),p.length===0&&(0,R.jsx)(`li`,{className:`px-1.5 py-1 text-xs text-faint-foreground`,children:_3(`noMatches`)})]})]})},iye=({config:e,selected:t,onToggle:n})=>{let[r,i]=(0,I.useState)(``),a=e.options.filter(e=>O3(e.label,r));return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.searchable&&(0,R.jsx)(Rd,{wrapperClassName:`mb-1 h-7`,leading:(0,R.jsx)(vo,{className:`size-3.5`}),placeholder:_3(`searchIn`,e.label),value:r,onChange:e=>i(e.target.value)}),a.map(e=>(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-1 hover:bg-muted`,children:[(0,R.jsx)(tg,{checked:t.includes(e.value),onChange:()=>n(e.value),label:e.label}),(0,R.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.count!==void 0&&(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-faint-foreground`,children:Sf(e.count)})]},e.value)),a.length===0&&(0,R.jsx)(`span`,{className:`px-1 py-1 text-xs text-faint-foreground`,children:_3(`noMatches`)})]})},k3=({label:e,activeCount:t,width:n=240,defaultOpen:r=!1,children:i})=>{let[a,o]=(0,I.useState)(r),[s,c]=(0,I.useState)(!1),l=(0,I.useRef)(null);return(0,I.useLayoutEffect)(()=>{a&&l.current&&c(l.current.getBoundingClientRect().left+n>document.documentElement.clientWidth)},[a,n]),(0,I.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,R.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,R.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,R.jsx)(`span`,{className:`rounded-full bg-primary px-1.5 text-[11px] leading-4 text-primary-foreground`,children:t}),(0,R.jsx)(Ti,{className:`size-3.5 text-muted-foreground`})]}),a&&(0,R.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})]})},A3=({title:e,children:t})=>(0,R.jsxs)(`section`,{className:`flex flex-col gap-2 border-b py-3 last:border-b-0`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),t]}),j3=(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}},aye=({items:e,onPick:t,close:n})=>{let r=(0,I.useRef)([]);return(0,I.useEffect)(()=>r.current[0]?.focus(),[]),(0,R.jsx)(`ul`,{role:`menu`,"aria-label":_3(`moreFilters`),onKeyDown:t=>{if(t.key===`Escape`)return n();let i=j3(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,R.jsx)(`li`,{role:`none`,children:(0,R.jsx)(`button`,{ref:e=>{r.current[i]=e},type:`button`,role:`menuitem`,className:Gae,onClick:()=>{n(),t(e.key)},children:e.label})},e.key))})},oye=({items:e,onPick:t})=>e.length===0?null:(0,R.jsx)(k3,{label:_3(`moreFilters`),activeCount:0,children:n=>(0,R.jsx)(aye,{items:e,onPick:t,close:n})}),M3=(e,t)=>{let[n,r]=(0,I.useState)(e);return(0,I.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n},sye=(e,t,n,r,i)=>{let a=n+(r-n)*e/t;return n+(r-n)*(e+1)/t>i[0]&&a<i[1]},N3=(e,t,n)=>n===t?0:(e-t)/(n-t),cye=(e,t,n)=>t===0?[Math.min(n,e[1]),e[1]]:[e[0],Math.max(n,e[0])],lye=1e3,uye=({config:e,value:t,onChange:n})=>{let{min:r,max:i,step:a,histogram:o,format:s}=e,[c,l]=(0,I.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=M3(c,lye);return(0,I.useEffect)(()=>{p&&f()},[p]),(0,R.jsxs)(`div`,{className:`w-full`,children:[(0,R.jsxs)(`div`,{className:`px-[7px]`,children:[o.length>0&&(0,R.jsx)(`div`,{className:`mb-1 flex h-12 items-end gap-0.5`,children:o.map((e,t)=>(0,R.jsx)(`span`,{className:g(`flex-1 rounded-t-sm`,sye(t,o.length,r,i,u)?`bg-primary/70`:`bg-border`),style:{height:`${Math.max(6,e/d*100)}%`}},t))}),(0,R.jsxs)(`div`,{className:`relative h-4`,children:[(0,R.jsx)(`span`,{className:`absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-border`}),(0,R.jsx)(`span`,{className:`absolute top-1/2 h-1 -translate-y-1/2 rounded-full bg-primary`,style:{left:`${N3(u[0],r,i)*100}%`,right:`${100-N3(u[1],r,i)*100}%`}})]})]}),(0,R.jsx)(`div`,{className:`relative -mt-4 h-4`,children:[0,1].map(t=>(0,R.jsx)(`input`,{type:`range`,className:`pb-range`,"aria-label":_3(t===0?`minimum`:`maximum`,e.label),min:r,max:i,step:a,value:u[t],onChange:e=>l(cye(u,t,Number(e.target.value))),onPointerUp:f,onTouchEnd:f,onBlur:f},t))}),(0,R.jsxs)(`div`,{className:`mt-2 flex justify-between text-xs tabular-nums text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:s(u[0])}),(0,R.jsx)(`span`,{children:s(u[1])})]})]})},dye=e=>[...new Set(e.map(e=>e.key.split(`:`).slice(0,2).join(`:`)))],P3=(e,t)=>{let n=t.filter(t=>!e.includes(t));return n.length===0?e:[...e,...n]},fye=(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:_3(`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}},F3=({label:e,checked:t,onChange:n})=>(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between gap-3 py-1`,children:[(0,R.jsx)(`span`,{children:e}),(0,R.jsx)(WS,{checked:t,onChange:n,label:e})]}),I3=(e,t)=>e.some(e=>e.length>0)||!!t,L3=({groups:e,trailing:t})=>{if(!I3(e,t))return null;let n=e.filter(e=>e.length>0);return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.map((e,t)=>(0,R.jsxs)(I.Fragment,{children:[t>0&&(0,R.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`}),e]},t)),t&&(0,R.jsx)(`div`,{className:`flex min-w-32 flex-1 justify-end`,children:t})]})},pye=(e,t,n)=>{let[r,i]=(0,I.useState)(t??x3);return[e??r,e=>{i(e),n?.(e)}]},R3=({config:e,layout:t,value:n,defaultValue:r,onChange:i,lockedLabels:a,defaultOpenMenu:o,fullWidth:s,leading:c,trailing:l})=>{let[u,d]=pye(n,r,i),f=E3(e,u),p=dye(f),[m,h]=(0,I.useState)(()=>p),[g,_]=(0,I.useState)();(0,I.useEffect)(()=>h(e=>P3(e,p)),[p.join(`,`)]);let v=(0,R.jsx)(v3,{chips:f,lockedLabels:a,onRemove:e=>d(D3(u,e)),onClear:()=>d(x3)}),y=(e,t=!1)=>{let n=u.facets[e.id]??[],r=t=>d(S3(u,e.id,t));return e.combobox?(0,R.jsx)(rye,{config:e,selected:n,onToggle:r,inline:t}):(0,R.jsx)(iye,{config:e,selected:n,onToggle:r})},b=e.ranges??[],x=e=>(0,R.jsx)(uye,{config:e,value:u.ranges?.[e.id],onChange:t=>d(w3(u,e.id,t))}),S=e.datePresets&&(0,R.jsx)(eye,{value:u.date,presets:Array.isArray(e.datePresets)?e.datePresets:void 0,onChange:e=>d({...u,date:e})}),C=(e.toggles??[]).map(e=>(0,R.jsx)(F3,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(C3(u,e.id))},e.id));if(t===`panel`)return(0,R.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,R.jsx)(`div`,{className:`flex items-center justify-between pb-1`,children:(0,R.jsx)(`h2`,{className:`font-semibold`,children:_3(`filters`)})}),(f.length>0||(a?.length??0)>0)&&(0,R.jsx)(`div`,{className:`border-b pb-3`,children:v}),c,e.facets.map(e=>(0,R.jsx)(A3,{title:e.label,children:y(e)},e.id)),b.map(e=>(0,R.jsx)(A3,{title:e.label,children:x(e)},e.id)),S&&(0,R.jsx)(A3,{title:_3(`date`),children:S}),C.length>0&&(0,R.jsx)(A3,{title:_3(`showOnly`),children:C})]});let{shown:w,more:T}=fye(e,m),E=e=>{h(t=>P3(t,[e])),_(e)},D=[...e.facets.filter(e=>w.has(`facet:${e.id}`)).map(e=>(0,R.jsx)(k3,{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,R.jsx)(k3,{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,R.jsx)(I.Fragment,{children:S},`date`)]:[]],O=(e.toggles??[]).filter(e=>w.has(`toggle:${e.id}`)).map(e=>(0,R.jsx)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:(0,R.jsx)(F3,{label:e.label,checked:u.toggles.includes(e.id),onChange:()=>d(C3(u,e.id))})},e.id)),k=[c?[(0,R.jsx)(I.Fragment,{children:c},`leading`)]:[],D,O,T.length>0?[(0,R.jsx)(oye,{items:T,onPick:E},`more`)]:[]];return!I3(k,l)&&f.length===0&&!a?.length?null:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(L3,{groups:k,trailing:l}),v]})},z3=Un(),B3={start:0,end:0},V3={"24h":{amount:24,unit:`h`},"7d":{amount:7,unit:`d`},"30d":{amount:30,unit:`d`},"90d":{amount:90,unit:`d`}},mye=e=>new Date(e).toISOString().replace(`.000Z`,`Z`),H3=(e,t,n)=>{let r=Mf(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},U3=[`year`,`quarter`,`month`,`yesterday`,`today`],W3=(e,t,n)=>t===`date`?e:mye(Pf(e,n)),G3=(e,t,n)=>t===`date`?{kind:`string`,value:W3(e,t,n),span:B3}:{kind:`timestamp`,value:W3(e,t,n),span:B3},hye=(e,t,n,r,i)=>{if(t in V3)return[z3.gte(e,z3.ago(t))];let a=z3.gte(e,G3(H3(t,n,i),r,i));return t===`yesterday`?[a,z3.lt(e,G3(H3(`today`,n,i),r,i))]:[a]},gye=(e,t,n=new Date,r=Ef())=>{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=>z3.eq(e.value,!0));return t.length===0?[]:[t.length===1?t[0]:z3.or(...t)]}return[n.length===1?z3.eq(e.id,n[0]):z3.in(e.id,n)]}),a=(e.ranges??[]).flatMap(e=>{let n=t.ranges?.[e.id];return n?[z3.gte(e.id,n[0]),z3.lte(e.id,n[1])]:[]}),o=e.dateField&&t.date?hye(e.dateField,t.date,n,e.dateKind,r):[],s=(e.toggles??[]).filter(e=>t.toggles.includes(e.id)).map(e=>z3.eq(e.id,!0));return[...i,...a,...o,...s]},_ye=e=>e.length===0?``:Fn(z3.and(...e)),K3=(e,t,n=[],r=new Date,i=Ef())=>_ye([...gye(e,t,r,i),...n]),q3=e=>e.kind===`and`?e.args.flatMap(q3):[e],J3=e=>e.field.path.join(`.`),vye=e=>e.kind===`compare`&&e.op===`=`&&e.value.kind===`boolean`&&e.value.value,yye=(e,t)=>{let n=e.kind===`or`?e.args:[e];if(!n.every(vye))return;let r=n.map(J3),i=t.get(r[0]);return i!==void 0&&r.every(e=>t.get(e)===i)?{group:i,fields:r}:void 0},Y3=e=>e.kind===`number`?String(e.raw):e.kind===`string`?String(e.value):void 0,X3=(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(V3).find(([,n])=>n.amount===e&&n.unit===t)?.[0]}if(r.kind===`timestamp`)return U3.find(e=>W3(H3(e,t,n),`timestamp`,n)===r.value);if(r.kind===`string`)return U3.find(e=>H3(e,t,n)===r.value)},Z3=(e,t,n=new Date,r=Ef())=>{let i=Yt(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?q3(i.ast):[]){let i=yye(t,c);if(i&&!a.facets[i.group])a.facets[i.group]=i.fields;else if(t.kind===`compare`&&s.has(J3(t))&&t.op===`=`&&Y3(t.value)!==void 0)a.facets[J3(t)]=[...a.facets[J3(t)]??[],Y3(t.value)];else if(t.kind===`in`&&s.has(J3(t))&&t.values.every(e=>Y3(e)!==void 0))a.facets[J3(t)]=[...a.facets[J3(t)]??[],...t.values.map(e=>Y3(e))];else if(t.kind===`compare`&&e.dateField===J3(t)&&t.op===`>=`&&X3(t,n,r)&&!a.date)a.date=X3(t,n,r),f=t;else if(t.kind===`compare`&&e.dateField===J3(t)&&t.op===`<`&&(t.value.kind===`timestamp`||t.value.kind===`string`)&&t.value.value===W3(H3(`today`,n,r),t.value.kind===`string`?`date`:`timestamp`,r))p=t;else if(t.kind===`compare`&&l.has(J3(t))&&t.op===`=`&&t.value.kind===`boolean`&&t.value.value)a.toggles.push(J3(t));else if(t.kind===`compare`&&u.has(J3(t))&&(t.op===`>=`||t.op===`<=`)&&t.value.kind===`number`){let e=d.get(J3(t))??{clauses:[]};t.op===`>=`?e.low=t.value.value:e.high=t.value.value,e.clauses.push(t),d.set(J3(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}},bye=[`integer`,`bigint`,`decimal`],xye=(e,t)=>{let n=e?.fields[t]?.type;return n!==void 0&&bye.includes(n)},Q3=(e,t)=>e.kind===`range`||e.kind===`facets`&&xye(t,e.field),$3=e=>e.secondary?{secondary:!0}:{},Sye=e=>({id:e.field,label:e.field,min:0,max:0,step:1,histogram:[],format:String,...$3(e)}),e6=(e,t)=>{let n=e?.filters??[],r=n.find(e=>e.kind===`dateRange`);return{facets:n.flatMap(e=>e.kind===`facets`&&!Q3(e,t)?[{id:e.field,label:e.field,options:[],searchable:e.search,...t?.fields[e.field]?.type===`relation`&&{combobox:!0},...$3(e)}]:e.kind===`flags`?[{id:e.fields.join(`|`),label:e.label,options:e.fields.map(e=>({value:e,label:e,count:0})),flags:!0,...$3(e)}]:[]),ranges:n.flatMap(e=>e.kind!==`flags`&&Q3(e,t)?[Sye(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,...$3(e)}]:[])}},t6=(e,t)=>(e?.filters??[]).some(e=>e.kind===`range`&&e.field===t&&e.histogram),n6=(e,t)=>{let n=e?.fields[t],r=n?.suffix??``;return e=>`${n?.prefix===`€`?yf(e*100).replace(`.00`,``):String(e)}${r}`},r6=Un(),Cye={start:0,end:0},wye=(e,t,n)=>{let r=Z3(e6(t,e),n);return r.ok?Object.fromEntries(Object.entries(r.state.facets).filter(([t,n])=>e.fields[t]?.type===`relation`&&n.length>0)):{}},Tye=(e,t,n)=>{let r=e=>t?.fields[e]?.label??K(e),i=e6(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,_s(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:n6(t,e.id)})),toggles:i.toggles?.map(e=>({...e,label:r(e.id)}))}},i6=(e,t,n,r={})=>{let i=Tye(e,t,r),a=Z3(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[...E3(i,a.state),...o]},Eye=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]))}])),Dye=(e,t,n)=>{if(typeof n!=`string`||n===``)return e;let r=r6.gt(t,{kind:`timestamp`,value:new Date(n).toISOString(),span:Cye}),i=Yt(e);if(!i.ok)throw Error(`The saved filter cannot be read: ${i.errors.map(e=>e.message).join(`; `)}`);return Fn(i.ast?r6.and(i.ast,r):r)},Oye=(e,t)=>typeof t!=`string`||t===``?!0:typeof e!=`string`||e===``?!1:new Date(e).getTime()>new Date(t).getTime(),a6=(e,t)=>{let n=U(),r=Om(),{resources:i,views:a}=J(),o=a[e.name],s=Object.entries(wye(e,o,t)),c=Oh({queries:s.map(([t,o])=>{let s=i[e.fields[t].relation.resource];return{queryKey:H.labels(`chips:${e.name}.${t}`,o.join(`,`)),enabled:s!==void 0,queryFn:async()=>Object.fromEntries(await H0(r,n,s,o,a[s.name]))}})});return i6(e,o,t,Object.fromEntries(s.flatMap(([e],t)=>c[t]?.data?[[e,c[t].data]]:[])))},kye=(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}}),o6=e=>{let t=Om();return(0,I.useCallback)(n=>t.setQueryData(H.recordPreview(e.name,ur(px(e,n))),kye(e,n)),[t,e])},s6={wallet:dte,"file-text":ra,send:So,ruler:go,bed:ni,bath:ei,house:$ee,"door-open":Gee,"land-plot":nte,leaf:ba,tag:cte,key:pa,calendar:vi,heart:ca,bell:ii,bookmark:fi,"external-link":Zi,ban:Qr,play:ste,stop:Ro,power:ao,restart:mo,terminal:lte,camera:Fee,"hard-drive":Qee,server:wo,network:Ka,archive:Rr,copy:zi,"arrow-right-left":Hr,download:Gi,upload:ns,cpu:Wee,memory:La,plug:to,wrench:fte},c6=e=>e!==void 0&&Object.hasOwn(s6,e)?s6[e]:void 0,l6=({benefits:e})=>e&&e.length>0?(0,R.jsx)(`ul`,{className:`flex flex-col gap-2 text-left`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(Ci,{className:`mt-0.5 size-4 shrink-0 text-primary`,"aria-hidden":!0}),e]},e))}):null,u6=({prompt:e})=>{let{canSignUp:t}=B(),{link:n}=ng(),r=op({variant:`primary`}),i=e.signUp?(0,R.jsx)(`a`,{href:e.signUp.href,target:`_blank`,rel:`noreferrer`,className:r,children:e.signUp.label}):t&&(0,R.jsx)(Ku,{to:n(`sign-up`),className:r,children:z(`createAnAccount`)});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Ku,{to:n(),className:i?op():r,children:z(`signIn`)}),i]})},d6=e=>{let{prompt:t}=e,n=(0,I.useId)();if(e.as===`dialog`)return(0,R.jsx)(Mw,{title:t.title,description:t.description,open:e.open,onClose:e.onClose,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:e.onClose,children:z(`notNow`)}),(0,R.jsx)(u6,{prompt:t})]}),children:(0,R.jsx)(l6,{benefits:t.benefits})});let r=c6(t.icon)??Aa;return(0,R.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,R.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,R.jsx)(r,{className:`size-6`,"aria-hidden":!0})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`h1`,{id:n,className:`text-lg font-semibold`,children:t.title}),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:t.description})]}),(0,R.jsx)(l6,{benefits:t.benefits}),(0,R.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,R.jsx)(u6,{prompt:t})})]})},Aye=Un(),f6=e=>{if(typeof e==`string`||typeof e==`number`)return e;if(e&&typeof e==`object`&&`id`in e)return f6(e.id)},jye=(e,t,n)=>n.flatMap(n=>{let r=f6(n[t]);return r===void 0?[]:[{key:ur(px(e,n)),target:r}]}),Mye=(e,t)=>e.find(e=>ur(e.target)===t),Nye=(e,t)=>[...e,{key:``,target:t}],Pye=(e,t)=>e.filter(e=>ur(e.target)!==t),p6=(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:Aye.in(n,r)},m6=(e,t)=>H.list(e,``,``,500,`saved:${t}`),h6=(e,t,n)=>{let r=U(),i=J().resources[e];return Ah({queryKey:m6(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 jye(i,t,n)}})},g6=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`}}),Fye=e=>e instanceof Error?e.message:g6(`somethingWrong`),Iye=(e,t,n)=>{let r=J(),i=U(),a=Om(),o=ub(),s=_T(),{resource:c,field:l}=e,u=r.permissions[c],d=r.resources[c]!==void 0&&u!==void 0&&eT(u,`create`)&&eT(u,`delete`),f=r.signIn?.[c]?.signIn,p=h6(c,l,d),m=p.data&&Mye(p.data,t),h=m6(c,l),g=jh({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?Pye(r,t):Nye(r,n)),{before:r}},onError:(e,t,n)=>{a.setQueryData(h,n?.before),o.show({state:`error`,title:g6(t?`couldNotTakeOff`:`couldNotSave`),description:Fye(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)}},Lye=({favorite:e,recordKey:t,target:n,className:r})=>{let i=Iye(e,t,n),[a,o]=(0,I.useState)(!1);if(!i.mode)return null;let s=e.label??g6(`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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":s,"aria-haspopup":`dialog`,className:c,onClick:()=>o(!0),children:(0,R.jsx)(ca,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(d6,{as:`dialog`,prompt:i.prompt,open:a,onClose:()=>o(!1)})]}):(0,R.jsx)(`button`,{type:`button`,"aria-label":s,"aria-pressed":i.saved,"aria-disabled":!i.ready,className:c,onClick:()=>i.ready&&i.toggle(),children:(0,R.jsx)(ca,{className:g(`size-4`,i.saved&&`fill-current text-danger`),"aria-hidden":!0})})},_6=6,Rye=(e,t,n)=>{let r=e.bottom+_6;return{top:r+t.height>n.height-_6?Math.max(_6,e.top-_6-t.height):r,left:Math.max(_6,Math.min(e.left,n.width-_6-t.width))}},v6=(e,t)=>{let n=zx(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},zye=(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:tS(r,n[r.name],v6(n[r.name],e.status))}]:[]}),Bye=a({en:{none:e=>`No ${e}`},nl:{none:e=>`Geen ${e}`}}),Vye=(e,{values:t,label:n,singular:r,plural:i})=>{if(e.length===0)return Bye(`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(`, `)}`},y6=`flex shrink-0 items-center justify-center rounded-full p-0.5 pointer-coarse:p-1.5`,b6=`size-2.5 rounded-full`,x6=`flex min-w-0 items-center gap-0.5`,Hye=150,S6=288,Uye=({shown:e,row:t,target:n,view:r,column:i,Card:a,onEnter:o,onLeave:s})=>{let c=(0,I.useRef)(null),[l,u]=(0,I.useState)();return(0,I.useLayoutEffect)(()=>{c.current&&u(Rye(e.dot,{width:S6,height:c.current.offsetHeight},{width:window.innerWidth,height:window.innerHeight}))},[e]),(0,ps.createPortal)((0,R.jsx)(`div`,{ref:c,"data-dot-card":!0,onMouseEnter:o,onMouseLeave:s,style:{width:S6,...l??{visibility:`hidden`,top:0,left:0}},className:`fixed z-50 rounded-lg shadow-pop`,children:(0,R.jsx)(a,{model:n,view:r,display:v6(r,i.status),row:t})}),document.body)},C6=({column:e,records:t,target:n,view:r,wrap:i=!1,Card:a})=>{let o=(0,I.useMemo)(()=>t.map(e=>rS(n,e)),[t,n]),[s,c]=(0,I.useState)(),l=(0,I.useRef)(void 0),u=(0,I.useRef)(`mouse`),d=(0,I.useRef)(null),f=n.fields[e.status],p=r?.fields[e.status],m=t=>f?Ox(f,t.record[e.status],p):``,h=lx(n,r),_=e=>e.labels[h]??String(e.record[h]??e.key),v=(r?.names?.singular??K(n.name)).toLowerCase(),y=(r?.names?.plural??K(n.name)).toLowerCase(),b=Vye(o.map(t=>t.record[e.status]),{values:f?.enumValues??[],label:e=>f?Ox(f,e,p):e,singular:v,plural:y}),x=()=>window.clearTimeout(l.current),S=()=>{x(),l.current=window.setTimeout(()=>c(void 0),Hye)},C=(e,t)=>{x(),c({key:e,dot:t.getBoundingClientRect()})};(0,I.useEffect)(()=>x,[]),(0,I.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,R.jsxs)(`div`,{ref:d,className:g(x6,i&&`pointer-events-none flex-wrap`),onClick:e=>e.stopPropagation(),onPointerDown:e=>u.current=e.pointerType,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:b}),o.map(t=>{let r=t.record[e.status],i=K0(p?.valueColors,r);return(0,R.jsx)(_S,{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(y6,`pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`),children:(0,R.jsx)(`span`,{"aria-hidden":!0,style:i===void 0?void 0:{backgroundColor:i},className:g(b6,i===void 0&&ld[yx(String(r))],s?.key===t.key&&`ring-2 ring-foreground/30`)})},t.key)}),s&&E&&(0,R.jsx)(Uye,{shown:s,row:E,target:n,view:r,column:e,Card:a,onEnter:x,onLeave:S})]})},Wye=({count:e})=>(0,R.jsx)(`span`,{"aria-hidden":!0,className:g(x6,`invisible flex-wrap`),children:Array.from({length:e},(e,t)=>(0,R.jsx)(`span`,{className:y6,children:(0,R.jsx)(`span`,{className:b6})},t))}),w6=`flex flex-col gap-1.5`,Gye=({dots:e})=>(0,R.jsx)(`span`,{className:w6,children:e.map(({column:e,records:t})=>(0,R.jsx)(Wye,{count:t.length},e.name))}),Kye=({dots:e,Card:t})=>{let{resources:n,views:r}=J();return(0,R.jsx)(`div`,{className:`pointer-events-none absolute inset-x-[calc(0.75rem+1px)] bottom-[calc(0.75rem+1px)] ${w6}`,children:e.map(({column:e,records:i})=>{let a=n[e.resource];return a&&(0,R.jsx)(C6,{column:e,records:i,target:a,view:r[a.name],Card:t,wrap:!0},e.name)})})},qye=(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}]:[]}),T6=({value:e})=>{let t=Mb(e,{width:320,height:240});return t?(0,R.jsx)(QS,{image:t,loading:`lazy`,className:`size-full object-cover`}):null},E6=({children:e})=>(0,R.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}),Jye=({value:e})=>(0,R.jsx)(E6,{children:(0,R.jsx)(T6,{value:e})}),Yye=10,Xye=(e,t)=>{let n=Sb(e)?e.uri:void 0,r=t.filter(e=>Sb(e)&&e.uri!==n);return(n===void 0?r:[e,...r]).slice(0,Yye)},Zye=(e,t)=>t===0?0:(e%t+t)%t,Qye=(e,t,n)=>t<=0||n===0?0:Math.min(n-1,Math.max(0,Math.round(e/t))),D6=`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`,O6=`[@media(hover:none)]:opacity-100`,$ye=({photos:e,cover:t,swipe:n=!0,children:r})=>{let i=(0,I.useRef)(null),a=(0,I.useRef)(void 0),[o,s]=(0,I.useState)(0),c=Xye(t,e),l=e=>{let t=i.current;t&&t.scrollTo({left:e*t.clientWidth})},u=e=>{a.current=Zye((a.current??o)+e,c.length),l(a.current)},d=()=>{a.current=void 0},f=e=>{s(Qye(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,R.jsx)(E6,{children:(0,R.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,R.jsx)(`span`,{className:`block size-full shrink-0 snap-start snap-always`,children:(0,R.jsx)(T6,{value:e})},t))})});return(0,R.jsxs)(R.Fragment,{children:[r(p),c.length>1&&(0,R.jsxs)(`div`,{className:`group/arrows pointer-events-none absolute inset-x-px top-px aspect-[4/3]`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":q(`previousPhoto`),className:g(D6,!n&&O6,`left-2`),onClick:()=>u(-1),children:(0,R.jsx)(Di,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(`button`,{type:`button`,"aria-label":q(`nextPhoto`),className:g(D6,!n&&O6,`right-2`),onClick:()=>u(1),children:(0,R.jsx)(ki,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsxs)(`span`,{className:`absolute inset-x-0 bottom-2 flex justify-center`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:q(`photoOf`,o+1,c.length)}),(0,R.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,R.jsx)(`span`,{className:g(`size-1.5 rounded-full`,t===o?`bg-foreground`:`bg-foreground/35`)},t))})]})]})]})},ebe=({icon:e,children:t})=>{let n=c6(e);return(0,R.jsxs)(`dd`,{className:`flex items-center gap-1 tabular-nums`,children:[n&&(0,R.jsx)(n,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t]})},k6=({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}=Xx(e,t,n),m=e=>t?.fields[e]?.label??K(e),h=n=>{let i=e.fields[n];if(!i)return``;let a=r.record[n];return r.labels[n]===void 0&&ox(i,t?.fields[n])&&typeof a==`string`&&a!==``?ax(a):r.labels[n]??Ox(i,a,t?.fields[n])},{fields:g,components:_}=tC(),v=o6(e),y=n.card===void 0?void 0:_?.[n.card],b=n=>{let i=e.fields[n],a=i&&nC(g,i,t?.fields[n]);return a?(0,R.jsx)(iC,{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||!ox(i,t?.fields[n])||nC(g,i,t?.fields[n])||typeof a!=`string`||a===``?b(n):(0,R.jsx)(aC,{source:a,inLink:!0})},S=n=>{let i=e.fields[n],a=t?.fields[n],o=r.record[n];return!i||a?.format!==`badge`||nC(g,i,a)||o==null||o===``?b(n):(0,R.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||nC(g,i,t?.fields[n]))return(0,R.jsx)(`strong`,{className:`font-semibold text-foreground`,children:b(n)});let a=$x(i,r.record[n],t?.fields[n]);return(0,R.jsxs)(R.Fragment,{children:[(0,R.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=Qx(r,l),k=Zx(r,f),A=o!==void 0||w!==void 0,j=n.favorite,M=y?[]:qye(t,n,r),N=e=>(0,R.jsxs)(R.Fragment,{children:[A&&e,(0,R.jsxs)(`span`,{className:`flex items-start justify-between gap-2 ${j&&!A?`pr-8`:``}`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:b(s)}),u!==void 0&&T!=null&&(0,R.jsx)(q0,{value:T,hints:t?.fields[u],children:h(u)})]}),c!==void 0&&(0,R.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,R.jsx)(`span`,{className:`truncate tabular-nums text-muted-foreground`,children:C(O)}),d.length>0&&(0,R.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:Zx(r,d).map(e=>(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`dt`,{className:`sr-only`,children:m(e)}),(0,R.jsx)(ebe,{icon:t?.fields[e]?.icon,children:S(e)})]},e))}),E.length>0&&(0,R.jsx)(`ul`,{className:`flex flex-wrap gap-1`,"aria-label":q(`features`),children:E.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(dd,{dot:!1,children:m(e)})},e))}),k.length>0&&(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground ${d.length>0?``:`mt-auto`}`,children:k.map((e,t)=>(0,R.jsxs)(`span`,{children:[t>0&&(0,R.jsx)(`span`,{"aria-hidden":!0,children:` • `}),b(e)]},e))}),M.length>0&&(0,R.jsx)(Gye,{dots:M})]}),ee=t=>(0,R.jsxs)(_S,{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,R.jsx)(dd,{tone:`blue`,className:`self-start`,children:a}),y?(0,R.jsx)(vg,{name:n.card,fallback:N(t),children:(0,R.jsx)(y,{row:r})}):N(t)]});return(0,R.jsxs)(`div`,{className:w?`group/card relative h-full`:j||a||M.length>0?`relative h-full`:`h-full`,children:[w?(0,R.jsx)($ye,{photos:r.photos??[],cover:D,swipe:i,children:ee},r.key):ee((0,R.jsx)(Jye,{value:D})),a&&A&&(0,R.jsx)(dd,{tone:`blue`,className:`pointer-events-none absolute top-2 left-2 shadow-sm`,children:a}),M.length>0&&(0,R.jsx)(Kye,{dots:M,Card:k6}),j&&(0,R.jsx)(Lye,{favorite:j,recordKey:r.key,target:px(e,r.record),className:A?void 0:`right-1.5 top-1.5`})]})},A6=268,j6=3,M6=(e,t,n)=>{let r=Math.floor(Math.max(0,e)/A6),i=Math.ceil((Math.max(0,e)+t)/A6);return{start:Math.max(0,r-j6),end:Math.min(n,i+j6)}},N6=e=>e*A6,tbe=e=>{let t=(0,I.useRef)(null),[n,r]=(0,I.useState)({left:0,width:0});(0,I.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]=[M6(t.left,t.width,e),M6(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,N6(e)-12),a=e=>t.current?.scrollBy({left:e*Math.max(N6(1),n.width-12),behavior:`smooth`});return{ref:t,...M6(n.left,n.width,e),back:n.left>0,on:n.left+n.width<i-1,page:a}},P6=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}.`}}),F6=`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`,I6=({cards:e})=>e>0?(0,R.jsx)(`li`,{"aria-hidden":!0,className:`shrink-0`,style:{width:N6(e)-12}}):null,nbe=({model:e,view:t,display:n,source:r,label:i,isNew:a})=>{let{total:o}=r,s=tbe(o),c=Y4({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,R.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,R.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,R.jsx)(I6,{cards:s.start}),l.map(r=>{let i=c(r);if(!i)return(0,R.jsx)(`li`,{"aria-hidden":!0,className:`shrink-0`,style:{width:256},children:(0,R.jsx)(Uu,{className:`h-full min-h-24 rounded-lg`})},`skeleton-${r}`);let s=rS(e,i);return(0,R.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,R.jsx)(k6,{model:e,view:t,display:n,row:s,swipe:!1,mark:a?.(s)?P6(`new`):void 0})},s.key)}),(0,R.jsx)(I6,{cards:o-s.end})]}),s.back&&(0,R.jsx)(`button`,{type:`button`,"aria-label":P6(`previous`,i.toLowerCase()),onClick:()=>s.page(-1),className:`${F6} -left-3`,children:(0,R.jsx)(Di,{className:`size-4`,"aria-hidden":!0})}),s.on&&(0,R.jsx)(`button`,{type:`button`,"aria-label":P6(`next`,i.toLowerCase()),onClick:()=>s.page(1),className:`${F6} -right-3`,children:(0,R.jsx)(ki,{className:`size-4`,"aria-hidden":!0})})]})},rbe=Un(),ibe=(e,t)=>{if(!t)return e;let n=Yt(e);if(!n.ok)throw Error(`The filter cannot be read: ${n.errors.map(e=>e.message).join(`; `)}`);return Fn(n.ast?rbe.and(n.ast,t):t)},abe=(e,t)=>{let n=zx(e).filter(e=>e.kind===`cards`);return n.find(e=>e.name===t)??n[0]??{kind:`cards`,name:`cards`}},obe=()=>(0,R.jsx)(`div`,{className:`flex gap-3 overflow-hidden`,children:Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-24 w-64 shrink-0`},t))}),L6=({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}=J(),g=Du(),_=abe(t,i),v=r||iS(e,t),y=d3({resources:m,views:h,model:e,columns:(0,I.useMemo)(()=>nS(e,t,[]),[e,t]),filter:(0,I.useMemo)(()=>ibe(n,f),[n,f]),orderBy:v}),b=a6(e,n),x=(t?.names?.singular??K(e.name)).toLowerCase(),S=t?.names?.plural??K(e.name),C=y.source?.total,w=(0,I.useMemo)(()=>y.source&&{...y.source,total:Math.min(y.source.total,a??1/0)},[y.source,a]);return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[o&&b.length>0||C!==void 0||c?(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[o&&b.length>0?(0,R.jsx)(h3,{chips:b}):(0,R.jsx)(`span`,{}),(0,R.jsxs)(`p`,{className:`flex flex-wrap gap-x-3 text-muted-foreground`,children:[c&&(0,R.jsx)(`span`,{children:c}),C!==void 0&&(0,R.jsx)(`span`,{className:`tabular-nums`,children:`${C.toLocaleString(l())} ${C===1?x:S.toLowerCase()}`})]})]}):null,y.isLoading?(0,R.jsx)(obe,{}):y.error?(0,R.jsx)(US,{title:P6(`couldNotLoad`),error:y.error}):!w||w.total===0?(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:s??P6(`noneMatch`,S.toLowerCase())}):(0,R.jsx)(nbe,{model:e,view:t,display:_,source:w,label:S,isNew:u}),(0,R.jsxs)(_S,{to:p3(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,R.jsxs)(R.Fragment,{children:[P6(`viewAll`),` `,(0,R.jsx)(`span`,{className:`sr-only`,children:S.toLowerCase()})]}),(0,R.jsx)(Wr,{className:`size-3.5`,"aria-hidden":!0})]})]})},sbe=({model:e,view:t,empty:n,...r})=>{let{resources:i,views:a}=J(),o=sS(i,a,e.name),s=h6(e.name,t.listOf,!0),c=(t.names?.plural??K(e.name)).toLowerCase();if(!o.listOf)return null;if(s.error)return(0,R.jsx)(US,{title:P6(`couldNotLoadYour`,c),error:s.error});if(!s.data)return(0,R.jsx)(Uu,{className:`h-24`});let l=p6(o.model,s.data);return l?(0,R.jsx)(L6,{...r,model:o.model,view:o.view,filter:``,scope:l,list:e.name,empty:n}):(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:n??P6(`noneYet`,c)})},cbe=e=>H.list(e,``,``,500,`saved-searches`),R6=(e,t)=>{let n=U(),{resources:r,views:i}=J(),a=r[e];return Ah({queryKey:cbe(e),enabled:t&&a!==void 0,queryFn:async()=>{let t=[],r;do{let o=await n.list(e,{pageSize:500,orderBy:iS(a,i[e]),...r&&{pageToken:r}});t.push(...o.items),r=o.nextPageToken||void 0}while(r);return t}})},z6=({model:e,of:t,target:n,targetView:r,row:i,recordKey:a})=>{let o=U(),s=_T(),c=String(i[t.filter]??``),l=a6(n,c),u=t.name===void 0?void 0:i[t.name],d=typeof u==`string`&&u!==``?u:void 0,f=t.unseen,p=jh({mutationFn:t=>o.update(e.name,a,{[f.seenAt]:t},i.etag??`*`),onSettled:()=>s(e.name)}),m=Ah({...pT(o,n,f?Dye(c,f.field,i[f.seenAt]):``),enabled:f!==void 0}),h=(r?.names?.plural??K(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=>Oye(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??Xve(l),body:g}},lbe=({model:e,view:t,target:n,targetView:r,row:i})=>{let a=ur(px(e,i)),{name:o,chips:s,title:c,body:l}=z6({model:e,of:t.searchesOf,target:n,targetView:r,row:i,recordKey:a});return(0,R.jsxs)(`section`,{"aria-label":c,className:`flex flex-col gap-3 py-4 first:pt-0 last:pb-0`,children:[(0,R.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:(0,R.jsx)(_S,{to:{kind:`record`,resource:e.name,key:a},className:`hover:underline`,children:o??(0,R.jsx)(g3,{chips:s})})}),(0,R.jsx)(L6,{...l})]})},ube=({model:e,view:t,empty:n})=>{let{resources:r,views:i}=J(),a=t.searchesOf,o=r[a.resource],s=R6(e.name,!0),c=(t.names?.plural??K(e.name)).toLowerCase();return o?s.error?(0,R.jsx)(US,{title:Q(`couldNotLoadYour`,c),error:s.error}):s.data?s.data.length===0?(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:n??Q(`noneYet`,c)}):(0,R.jsx)(`div`,{className:`flex flex-col divide-y`,children:s.data.map(n=>(0,R.jsx)(lbe,{model:e,view:t,target:o,targetView:i[a.resource],row:n},ur(px(e,n))))}):(0,R.jsx)(Uu,{className:`h-40`}):null},dbe=({node:e,slots:t})=>{let{resource:n,filter:r=``,sort:i,limit:a,display:o,title:s,description:c,empty:l}=xT(e),{resources:u,views:d}=J(),f=u[n];if(!f)return null;let p=d[f.name];return(0,R.jsx)(wT,{title:s,description:c,actions:t.actions,children:p?.searchesOf?(0,R.jsx)(ube,{model:f,view:p,empty:l}):p?.listOf===void 0?(0,R.jsx)(L6,{model:f,view:p,filter:r,sort:i,limit:a,display:o,empty:l}):(0,R.jsx)(sbe,{model:f,view:p,limit:a,display:o,empty:l})})},B6=(e,t)=>{let{resources:n}=J(),r=U(),i=JSON.stringify(e),a=(0,I.useMemo)(()=>JSON.parse(i).map(vc),[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=bc(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=vhe(t,l),f=Oh({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 yc(e,t)})},fbe=({node:e,children:t})=>{let{when:n}=xT(e),[r]=B6([n],$w());return r?(0,R.jsx)(R.Fragment,{children:t}):null},V6=`text-2xl font-semibold tracking-tight tabular-nums`,pbe=({model:e,filter:t})=>{let{views:n}=J(),r=mT(e,t);return r.isPending?(0,R.jsx)(Uu,{className:`h-8 w-16`}):r.error?(0,R.jsx)(`span`,{className:`text-danger-text`,children:_g(`couldNotCount`)}):(0,R.jsx)(_S,{to:WT(n[e.name],e.name,t),className:`${V6} hover:text-primary-text after:absolute after:inset-0 after:content-['']`,children:r.data.toLocaleString(l())})},mbe=({field:e,format:t})=>{let n=Q0($w(),e);return n.state===`loading`?(0,R.jsx)(Uu,{className:`h-8 w-16`}):n.state===`missing`?null:(0,R.jsx)(`span`,{className:V6,children:(0,R.jsx)(J0,{model:n.model,field:n.field,value:n.value,format:t})})},hbe=({node:e})=>{let{label:t,value:n,resource:r,filter:i,field:a,format:o,description:s}=xT(e),{resources:c}=J(),l=r===void 0?void 0:c[r];return(0,R.jsxs)(wT,{className:`relative h-full`,bodyClassName:`flex flex-col`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground break-words`,children:t}),(0,R.jsxs)(`div`,{className:`mt-auto pt-1`,children:[n!==void 0&&(0,R.jsx)(`span`,{className:V6,children:n}),l&&(0,R.jsx)(pbe,{model:l,filter:i}),a!==void 0&&(0,R.jsx)(mbe,{field:a,format:o})]}),s&&(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s})]})},H6=(e,t)=>{let n=e.position;if(!n||!eT(t,`update`))return;let r=e.fields[n.field];return r&&!r.readOnly?n.field:void 0},U6=(e,t)=>e.position?.within===void 0?H6(e,t):void 0,gbe=(e,t,n)=>t.position?.within!==void 0&&e.field===t.position.within&&!e.through&&!e.from&&!e.filter?H6(t,n):void 0,_be=(e,t,n,r)=>{if(t===void 0||e?.list?.drag?.rank!==!0||r!==``)return!1;let i=aS(n);return i.columnId===t&&i.direction===`asc`},W6=e=>e===null?`none`:`value:${e}`,G6=e=>e.data.current?.sortable!==void 0,K6=e=>{let t=Xie(e),n=t.find(e=>e.data?.droppableContainer&&G6(e.data.droppableContainer));return n?[n]:t.length>0?t:F_(e)},vbe=(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=>!G6(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=q6(o,n,d.id)[0];return{x:d.rect.left+(d.rect.width-t.width)/2,y:f?.rect.top??d.rect.top}},q6=(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),ybe=(e,t)=>{let n=e.code===`ArrowDown`?1:e.code===`ArrowUp`?-1:0;if(n===0)return vbe(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=q6(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}},J6=(e,t,n,r)=>{let i=Mh({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=>rS(e,t))),total:a[0]?.total??0,loading:i.isPending,error:i.error,more:i.hasNextPage,loadMore:()=>void i.fetchNextPage()}},bbe=({model:e,by:t,value:n,fields:r,filter:i,orderBy:a})=>{let{resources:o,views:s}=J(),c=d3({resources:o,views:s,model:e,columns:r,filter:Ix(i,t,n),orderBy:a});return J6(e,c.page,c.key,!0)},xbe=(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))]},Sbe=({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=bbe({model:e,by:n.by,value:r.value,fields:i,filter:a,orderBy:o}),m=Lx(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=xbe([...y,...b],x?.order).slice(0,s),{setNodeRef:C,isOver:w}=gy({id:W6(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??K(e.name)).toLowerCase(),D=t?.fields[n.by];return(0,R.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,R.jsxs)(`header`,{className:`flex items-center justify-between gap-2 px-1 pt-0.5`,children:[(0,R.jsx)(`h2`,{className:`min-w-0 truncate text-body font-medium`,children:r.value===null?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:r.label}):(0,R.jsx)(q0,{value:r.value,hints:D,children:r.label})}),!p.loading&&(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:T.toLocaleString(l())})]}),p.loading?Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-20`},t)):p.error?(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:p.error}):S.length===0?(0,R.jsx)(`p`,{className:`px-1 py-4 text-center text-xs text-muted-foreground`,children:q(`noPlural`,E)}):(0,R.jsx)(Ey,{id:W6(r.value),items:S.map(e=>e.key),strategy:Cy,children:(0,R.jsx)(`ul`,{className:`-mb-2 flex flex-col`,children:S.map(n=>(0,R.jsx)(Cbe,{model:e,view:t,card:m,row:n,column:r,rows:S,draggable:(u||d)&&tT(n.record,`update`),placeable:d,dragged:f},n.key))})}),s===void 0&&p.more&&(0,R.jsx)(V,{size:`sm`,variant:`ghost`,onClick:p.loadMore,children:q(`showMore`)})]})},Cbe=({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:_}=Oy({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,R.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,R.jsx)(k6,{model:e,view:t,display:n,row:r,swipe:!1})})},Y6=e=>e.kind===`and`?e.args.flatMap(Y6):[e],X6=e=>e.kind===`string`?String(e.value):void 0,wbe=(e,t)=>{if(e.kind===`compare`&&e.op===`=`&&e.field.path.join(`.`)===t){let t=X6(e.value);return t===void 0?void 0:[t]}if(e.kind===`in`&&e.field.path.join(`.`)===t){let t=e.values.map(X6);return t.every(e=>e!==void 0)?t:void 0}},Tbe=(e,t,n)=>{let r=Yt(e);if(!r.ok||!r.ast)return n;let i=Y6(r.ast).map(e=>wbe(e,t)).filter(e=>e!==void 0);return n.filter(e=>i.every(t=>e.value!==null&&t.includes(e.value)))},Z6=(e,t)=>t!==null&&Object.hasOwn(e,t)?e[t]:void 0,Q6=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.`}}),$6=(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:px(e,r),data:Object.fromEntries(a.map(e=>[e,t[e]])),etag:i}]}),e8=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},t8=(e,t)=>t===void 0?e:`(${e}) AND (${t})`,n8=async(e,t,n,r)=>{let i=t.position?.after;if(!i)return{after:[],before:[]};let a=t.primaryKey[0],o=px(t,r),s=e=>ur([e]),c=await e8(e,i.resource,t8(Fn(Wn.or(Wn.eq(i.field,o),Wn.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([e8(e,t.name,t8(Fn(Wn.in(a,[o,...u])),i.while)),d.length===0?[]:e8(e,t.name,Fn(Wn.in(a,d)))]),m=e=>{let r=ur(px(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):[]}},r8=e=>typeof e==`number`&&Number.isInteger(e),i8=(e,t,n)=>{let r=0;for(;r<t&&r8(e[r])&&(r===0||e[r]>e[r-1]);)r+=1;let i=e.length;for(;i-1>n&&r8(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}},Ebe=(e,t,n)=>{let r=e.findIndex(e=>e.key===t.key);return r===-1?[...e.slice(0,n),t,...e.slice(n)]:yy(e,r,n)},a8=(e,t,n)=>{let r=e.findIndex(e=>e.key===t.key);return{order:Ebe(e,t,n),first:r===-1?n:Math.min(r,n),last:r===-1?n:Math.max(r,n)}},o8=e=>typeof e.record.etag==`string`?e.record.etag:`*`,Dbe=(e,t,n,r,i,a,o,s,c)=>{let l=(r.record[t]??null)!==i.value,u=i8(a.map(e=>e.record[n]),o,s),d=a.slice(u.first,u.last+1),f=e=>l&&e.key===r.key?`*`:o8(e),p=(t,r)=>({op:`reorder`,resource:e.name,field:n,keys:t.map(t=>px(e,t.record)),start:r,etags:Object.fromEntries(t.map(t=>[ur(px(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:px(e,r.record),data:{[t]:i.value},etag:o8(r)},...h]:h},Obe=(e,t,n)=>{let r=new Map(t.map(t=>[ur(px(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(ur(px(e,t)),{record:t,etag:r})}return[...i].flatMap(([e,t])=>{let n=r.get(e);return n?[{before:n,...t}]:[]})},s8=a({en:{dependsOn:(e,t)=>`${e} depends on ${t}.`},nl:{dependsOn:(e,t)=>`${e} hangt af van ${t}.`}}),c8=e=>e!=null&&e!==``,kbe=({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}=a8(n,r,l),f=i.map(e=>e.record[t]),p=i8(f,u,d),m=new Map(i.map((t,n)=>[ur(px(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(ur(px(e,r.record)))),_=a.after.filter(e=>c8(h(e))&&Number(h(e))>=g),v=a.before.find(e=>c8(h(e))&&Number(h(e))<=g),y=v?s8(`dependsOn`,v.title,o):_[0]&&s8(`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=>!c8(h(e))||Number(h(e))>b))return{place:{index:l,bump:b},reason:c}}return{reason:c}},Abe=({model:e,view:t,by:n,rank:r,drop:i,labelOf:a,titleOf:o})=>{let s=U(),c=ub(),l=_T(),[u,d]=(0,I.useState)([]),f=(0,I.useRef)(void 0),p=e=>d(t=>t.filter(t=>t.row.key!==e)),m=r?[n,r]:[n],h=jh({mutationFn:e=>e(),onError:e=>c.show({state:`error`,title:q(`couldNotUndo`),description:Rx(e)}),onSettled:()=>l(e.name)}),g=async(t,r)=>{let a=i&&Z6(i,r.value);if(!a)throw Error(`The column ${r.label} takes no cards`);let o=px(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($6(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 n8(s,e,t,n.record),u=kbe({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?Q6(`notMoved`):Q6(`movedToPlace`,u.place.index+1),description:u.reason}),!d)return u.place.index!==a.index&&v(n,i,a8(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}=a8(a.rows,t,o.index);return _(Obe(e,c,await s.batchWrite(Dbe(e,n,r,t,i,c,l,u,o.bump))),i)},x=jh({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,px(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&&a8(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?q(`orderChanged`):q(`stayedIn`,a(i)):q(`movedTo`,a(i));if(!o){c.show({state:`success`,title:l});return}let u=c.show({state:`success`,title:l,action:{label:q(`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?q(`couldNotReorder`):q(`couldNotMoveTo`,r.label);c.show({state:`error`,title:i,description:Rx(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}})}},l8=(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}},u8=({model:e,view:t,display:n,fields:r,filter:i,orderBy:a,limit:o})=>{let s=Px(e,t,n),c=Tbe(i,n.by,s),l=Lx(e,t,n),u=hS(e.name),{boardDrops:d}=tC(),f=t?.list?.drag,p=typeof f?.board==`string`?f.board:void 0,m=p===void 0?void 0:d?.[p],h=t=>eT(u,`update`)&&(f?.board===!0?!e.fields[n.by]?.readOnly:m!==void 0&&Z6(m,t)!==void 0),g=c.some(e=>h(e.value)),_=Fx(e),v=f?.rank===!0&&_!==void 0&&U6(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}=Abe({model:e,view:t,by:n.by,rank:_,drop:m,labelOf:b,titleOf:x}),[w,T]=(0,I.useState)(),E=(0,I.useRef)(!1),D=T_(w_(bv,{activationConstraint:{distance:4}}),w_(Sv,{activationConstraint:{delay:250,tolerance:5}}),w_(fv,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:ybe}));if(p!==void 0&&!m)return(0,R.jsx)(gg,{children:Xh(q(`noDrop`),p)});let O=e=>c.find(t=>W6(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:q(`noColumn`)};let n=v?l8(t,e):void 0;if(!n)return{over:O(t.id)?.label??q(`noColumn`)};let r=n.rows.some(t=>t.key===e.key)?n.rows.length:n.rows.length+1;return{over:q(`placeOf`,n.column.label,n.index+1,r),place:q(`place`,n.column.label,n.index+1)}},M=(e,t)=>{let n=(v?l8(t,e)?.column:void 0)??O(t.id);return n!==void 0&&n.value!==k(e)&&!A(e,n)};return(0,R.jsxs)(fy,{sensors:D,collisionDetection:K6,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?l8(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})=>q(`pickedUp`,x(e.data.current.row)),onDragOver:({active:e,over:t})=>q(`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 q(`putBack`,x(n));let r=j(n,t);return q(`wasMovedTo`,x(n),r.place??r.over)},onDragCancel:({active:e})=>q(`cancelled`,x(e.data.current.row))},screenReaderInstructions:{draggable:q(v?g?`boardAnywhere`:`boardWithin`:`boardAcross`)}},children:[(0,R.jsx)(`div`,{className:`relative min-w-0 flex-1 overflow-x-auto`,children:(0,R.jsx)(`div`,{className:`flex snap-x items-start gap-3 pb-2`,children:c.map(a=>(0,R.jsx)(Sbe,{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},W6(a.value)))})}),(0,R.jsx)(vy,{children:w&&(0,R.jsx)(k6,{model:e,view:t,display:l,row:w,swipe:!1})})]})},d8=864e5,f8=e=>new Date(e).toISOString().slice(0,10),p8=e=>Date.parse(`${e}T00:00:00Z`),m8=(e,t)=>f8(p8(e)+t*d8),h8=e=>m8(e,-((new Date(p8(e)).getUTCDay()+6)%7)),g8=(e,t=0)=>{let n=new Date(p8(e));return f8(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1))},_8=({scale:e,day:t})=>({scale:e,day:e===`month`?g8(t):h8(t)}),v8=(e,t,n=Ef())=>_8(e??{scale:`month`,day:Mf(t,n)}),y8=(e,t,n=Ef())=>_8({scale:e,day:Mf(t,n)}),b8=(e,t)=>e.scale===`month`?{scale:`month`,day:g8(e.day,t)}:{scale:`week`,day:m8(h8(e.day),7*t)},x8=e=>{let t=h8(e.scale===`month`?g8(e.day):e.day),n=(p8(e.scale===`month`?m8(h8(m8(g8(e.day,1),-1)),6):m8(t,6))-p8(t))/d8+1;return Array.from({length:n},(e,n)=>m8(t,n))},jbe=e=>{let t=x8(e);return{from:t[0],to:m8(t.at(-1),1)}},S8=(e,t)=>t.fields[e.start]?.type===`timestamp`,Mbe=(e,t,n,r=Ef())=>{let i=S8(e,t),a=e=>new Date(Pf(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=Wn.and(Wn.gte(e.start,o(n.from)),Wn.lt(e.start,o(n.to)));if(e.end===void 0)return Fn(s);let c=i?Wn.gt(e.end,o(n.from)):Wn.gte(e.end,o(n.from));return Fn(Wn.or(s,Wn.and(Wn.lt(e.start,o(n.from)),c)))},Nbe=(e,t)=>e===``?t:`(${e}) AND (${t})`,C8=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},w8=(e,t,n,r=Ef())=>{let i=C8(e[t.start]);if(i===void 0)return;let a=S8(t,n),o=e=>a?Mf(e,r):f8(e),s=o(i),c=t.end===void 0?void 0:C8(e[t.end]),l=c===void 0?s:o(a?c-1:c);return{first:s,last:l<s?s:l}},Pbe=(e,t,n,r,i=Ef())=>{let a=w8(e,t,n,i);return a?r.filter(e=>e>=a.first&&e<=a.last):[]},T8=(e,t)=>e.toSorted((e,n)=>(C8(e.record[t.start])??0)-(C8(n.record[t.start])??0)),Fbe=(e,t,n,r,i=Ef())=>{let a=new Map(r.map(e=>[e,[]]));for(let o of T8(e,t))for(let e of Pbe(o.record,t,n,r,i))a.get(e).push(o);return a},Ibe=(e,t,n,r,i,a=Ef())=>{let o=(p8(i)-p8(r))/d8,s=S8(t,n),c=e=>{let t=C8(e);if(t!==void 0)return s?new Date(Nf(t+Af(t,a)+o*d8,a)).toISOString():m8(f8(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}}},E8=({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,R.jsx)(_S,{to:s(e),className:t,"aria-label":n,"aria-current":i?`page`:void 0,children:r}):(0,R.jsx)(`button`,{type:`button`,className:t,"aria-label":n,"aria-pressed":i,onClick:()=>l?.(e),children:r}),d=op({variant:`secondary`,size:`sm`});return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium`,children:e}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u(n,d,q(`previousPeriod`,t),(0,R.jsx)(Di,{className:`size-3.5`})),u(r,d,q(`today`),q(`today`)),u(i,d,q(`nextPeriod`,t),(0,R.jsx)(ki,{className:`size-3.5`}))]}),(0,R.jsx)(`span`,{role:`group`,"aria-label":o,className:c.group(),children:a.map(e=>(0,R.jsx)(I.Fragment,{children:u(e.view,c.option(e.current),e.label,e.label,e.current)},e.label))})]})]})},Lbe=e=>{let t=x8(e),n=e=>Date.parse(`${e}T00:00:00Z`);return e.scale===`month`?qf(n(e.day)):Qf(n(t[0]),n(t.at(-1)))},Rbe=({view:e,now:t,linkTo:n,onView:r})=>{let i=e.scale===`month`&&Mf(t,Ef()).startsWith(e.day.slice(0,7)),a=n=>n===`week`&&i?y8(`week`,t):v8({scale:n,day:e.day},t),o=(t,n)=>({view:a(t),label:n,current:e.scale===t});return(0,R.jsx)(E8,{heading:Lbe(e),unit:e.scale===`month`?`month`:`week`,previous:b8(e,-1),today:y8(e.scale,t),next:b8(e,1),scales:[o(`month`,q(`month`)),o(`week`,q(`week`))],scalesLabel:q(`calendarScale`),linkTo:n,onView:r})},zbe=`day:`,D8=e=>`${zbe}${e}`,Bbe=(e,t)=>`${e}@${t}`,Vbe=(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(D8(m8(o,a)));if(s)return{x:s.left+(s.width-n.width)/2,y:s.top+4}},Hbe=({day:e,count:t,children:n,more:r,inMonth:i,today:a,week:o})=>{let{setNodeRef:s,isOver:c}=gy({id:D8(e)}),l=Date.parse(`${e}T00:00:00Z`);return(0,R.jsxs)(`section`,{ref:s,"aria-label":`${Zf(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,R.jsxs)(`header`,{className:g(`flex items-center gap-1 px-0.5 text-xs`,i?`text-foreground`:`text-muted-foreground`),children:[o&&(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:Xf(l)}),(0,R.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]})},O8=(e,t,n,r)=>{let i=n.title??lx(e,t),a=e.fields[i],o=r.labels[i]??(a?Ox(a,r.record[i],t?.fields[i]):``);return o===``?r.key:o},Ube=(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 Mf(a,Ef())===r?$f(a):void 0},k8=({model:e,view:t,display:n,row:r,day:i,className:a})=>{let o=o6(e),s=Ube(e,n,r,i);return(0,R.jsxs)(_S,{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,R.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:s}),(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:O8(e,t,n,r)})]})},A8=({movable:e,dragged:t,...n})=>{let{setNodeRef:r,setActivatorNodeRef:i,listeners:a,isDragging:o}=my({id:Bbe(n.row.key,n.day),data:{row:n.row,day:n.day},disabled:!e});return(0,R.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,R.jsx)(k8,{...n})})},j8=({model:e,display:t,range:n,fields:r,filter:i})=>{let{resources:a,views:o}=J(),s=d3({resources:a,views:o,model:e,columns:r,filter:Nbe(i,Mbe(t,e,n)),orderBy:`${t.start} asc`}),c=J6(e,s.page,s.key,!0),l=c.more&&!c.loading&&c.rows.length<500;(0,I.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}},M8=(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)},N8=(e,t)=>{let n=U(),r=ub(),i=_T(),[a,o]=(0,I.useState)([]),s=e=>o(t=>t.filter(t=>t.key!==e)),c=jh({mutationFn:({row:t,patch:r})=>{let i=typeof t.record.etag==`string`?t.record.etag:`*`;return n.update(e.name,px(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:q(`couldNotMoveTo`,Uf(Date.parse(`${n}T00:00:00Z`))),description:Rx(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:Ibe(n.record,t,e,r,i),to:i})}},Wbe=3,P8=({model:e,view:t,display:n,fields:r,filter:i,at:a,linkTo:o,now:s=Date.now()})=>{let[c,l]=(0,I.useState)(),u=v8(o?a:c,s),d=x8(u),f=j8({model:e,display:n,range:jbe(u),fields:r,filter:i}),{moves:p,move:m}=N8(e,n),h=Fbe(M8(f.rows,p),n,e,d),_=eT(hS(e.name),`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[v,y]=(0,I.useState)(),b=(0,I.useRef)(!1),x=T_(w_(bv,{activationConstraint:{distance:4}}),w_(Sv,{activationConstraint:{delay:250,tolerance:5}}),w_(fv,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:Vbe})),S=Mf(s,Ef()),C=u.scale===`week`,w=e=>Uf(Date.parse(`${String(e).slice(D8(``).length)}T00:00:00Z`)),T=r=>O8(e,t,n,r.row),E={onDragStart:({active:e})=>q(`pickedUp`,T(e.data.current)),onDragOver:({active:e,over:t})=>q(`isOver`,T(e.data.current),t?w(t.id):q(`noDay`)),onDragEnd:({active:e,over:t})=>t?q(`wasMovedTo`,T(e.data.current),w(t.id)):q(`putBack`,T(e.data.current)),onDragCancel:({active:e})=>q(`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(D8(``).length):void 0;i&&i!==r&&m(n,r,i)},A=(e,t)=>{let n=v8({scale:`week`,day:e},s),r=q(`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,R.jsx)(_S,{to:o(n),className:i,children:r}):(0,R.jsx)(`button`,{type:`button`,className:i,onClick:()=>l(n),children:r})};return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,R.jsx)(Rbe,{view:u,now:s,linkTo:o,onView:l}),f.error&&(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:f.error}),f.capped&&(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:q(`capped`,500,u.scale)}),(0,R.jsxs)(fy,{sensors:x,collisionDetection:K6,onDragStart:O,onDragEnd:k,onDragCancel:D,accessibility:{announcements:E,screenReaderInstructions:{draggable:q(`calendarInstructions`)}},children:[(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[!C&&(0,R.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,R.jsx)(`span`,{className:`bg-surface px-1.5 py-1 text-xs font-medium text-muted-foreground`,children:Xf(Date.parse(`${e}T00:00:00Z`))},e))}),(0,R.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,Wbe);return(0,R.jsx)(Hbe,{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,R.jsx)(Uu,{className:`h-4`}):a.map(i=>(0,R.jsx)(A8,{model:e,view:t,display:n,row:i,day:r,movable:_&&tT(i.record,`update`),dragged:()=>b.current},i.key))},r)})})]}),(0,R.jsx)(vy,{children:v&&(0,R.jsx)(k8,{model:e,view:t,display:n,row:v.row,day:v.day})})]})]})},Gbe=864e5,F8=e=>Date.parse(`${e}T00:00:00Z`),I8=(e,t=0)=>{let n=new Date(F8(e));return new Date(Date.UTC(n.getUTCFullYear(),Math.floor(n.getUTCMonth()/3)*3+3*t,1)).toISOString().slice(0,10)},L8=({scale:e,day:t})=>({scale:e,day:e===`week`?h8(t):e===`month`?g8(t):I8(t)}),R8=(e,t,n=Ef())=>L8(e??{scale:`month`,day:Mf(t,n)}),z8=(e,t)=>{let{scale:n,day:r}=L8(e);return{scale:n,day:n===`week`?m8(r,7*t):n===`month`?g8(r,t):I8(r,t)}},B8=e=>{let t=L8(e).day,n=(F8(z8(e,1).day)-F8(t))/Gbe;return Array.from({length:n},(e,n)=>m8(t,n))},Kbe=e=>({from:L8(e).day,to:z8(e,1).day}),qbe=(e,t,n,r=Ef())=>{let i=Mf(n,r),a=B8(e);return L8({scale:t,day:i>=a[0]&&i<=a.at(-1)?i:a[0]})},Jbe=e=>{let t=B8(e);return e.scale===`week`?Qf(F8(t[0]),F8(t.at(-1))):e.scale===`month`?qf(F8(t[0])):Yf(F8(t[0]),F8(g8(t.at(-1))))},Ybe=e=>{let t=B8(e);if(e.scale===`week`)return t.map((e,t)=>({index:t,span:1,label:`${Xf(F8(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:Jf(F8(t[e]))}))},Xbe=(e,t,n,r,i=Ef())=>{let a=w8(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}},Zbe=`none`,Qbe=(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?Zbe:`value:${String(e)}`,c=n?q(`noValue`,o?.label??K(i)):t.labels[i]??Ox(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)},V8=`grid grid-cols-1 sm:grid-cols-[12rem_minmax(0,1fr)]`,H8=(e,t)=>`${e/t*100}%`,$be=({ticks:e,days:t,today:n,label:r,trackRef:i})=>(0,R.jsxs)(`div`,{className:g(V8,`border-b border-border bg-surface`),children:[(0,R.jsx)(`span`,{className:`hidden truncate px-2 py-1 text-xs font-medium text-muted-foreground sm:block`,children:r}),(0,R.jsx)(`div`,{ref:i,"aria-hidden":!0,className:`relative h-6`,children:e.map(e=>(0,R.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:H8(e.index,t.length),width:H8(e.span,t.length)},children:e.label},e.index))})]}),exe=({ticks:e,days:t,today:n})=>{let r=t.indexOf(n);return(0,R.jsxs)(`div`,{"aria-hidden":!0,className:g(V8,`pointer-events-none absolute inset-0`),children:[(0,R.jsx)(`span`,{className:`hidden sm:block`}),(0,R.jsxs)(`div`,{className:`relative`,children:[r>=0&&(0,R.jsx)(`span`,{className:`absolute inset-y-0 bg-primary/10`,style:{left:H8(r,t.length),width:H8(1,t.length)}}),e.map(e=>(0,R.jsx)(`span`,{className:g(`absolute inset-y-0 w-px bg-border`,(e.minor||e.index===0)&&`hidden sm:block`),style:{left:H8(e.index,t.length)}},e.index))]})]})},txe=({model:e,view:t,display:n,row:r,days:i,movable:a,dragged:o})=>{let s=Xbe(r.record,n,e,i);return(0,R.jsxs)(`div`,{className:g(V8,`relative border-b border-border last:border-b-0`),children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`truncate px-2 pt-1 text-body sm:py-1.5`,children:O8(e,t,n,r)}),(0,R.jsx)(`div`,{className:`relative h-7`,children:s&&(0,R.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2`,style:{left:H8(s.first,i.length),width:H8(s.last-s.first+1,i.length)},children:(0,R.jsx)(A8,{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`)})})})]})},nxe=()=>[{scale:`week`,label:q(`week`)},{scale:`month`,label:q(`month`)},{scale:`quarter`,label:q(`quarter`)}],U8=({model:e,view:t,display:n,fields:r,filter:i,at:a,linkTo:o,now:s=Date.now()})=>{let[c,l]=(0,I.useState)(),u=R8(o?a:c,s),d=B8(u),f=Ybe(u),p=j8({model:e,display:n,range:Kbe(u),fields:r,filter:i}),{moves:m,move:h}=N8(e,n),g=Qbe(T8(M8(p.rows,m),n),e,t,n),_=eT(hS(e.name),`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[v,y]=(0,I.useState)(),b=(0,I.useRef)(!1),x=(0,I.useRef)(0),S=(0,I.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=T_(w_(bv,{activationConstraint:{distance:4}}),w_(Sv,{activationConstraint:{delay:250,tolerance:5}}),w_(fv,{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=Mf(s,Ef()),O=r=>O8(e,t,n,r.row),k=e=>Uf(Date.parse(`${m8(e.day,x.current)}T00:00:00Z`)),A={onDragStart:({active:e})=>q(`pickedUp`,O(e.data.current)),onDragMove:({active:e})=>q(`startsOn`,O(e.data.current),k(e.data.current)),onDragOver:()=>void 0,onDragEnd:({active:e})=>x.current===0?q(`putBack`,O(e.data.current)):q(`wasMovedTo`,O(e.data.current),k(e.data.current)),onDragCancel:({active:e})=>q(`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),ee=({active:t,delta:r})=>{j(),x.current=w(r.x);let{row:i}=t.data.current,a=w8(i.record,n,e);a&&x.current!==0&&h(i,a.first,m8(a.first,x.current))},te=n.group===void 0?t?.names?.plural??K(e.name):t?.fields[n.group]?.label??K(n.group),ne=!p.loading&&!p.error&&p.rows.length===0;return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,R.jsx)(E8,{heading:Jbe(u),unit:u.scale,previous:z8(u,-1),today:R8({scale:u.scale,day:D},s),next:z8(u,1),scales:nxe().map(({scale:e,label:t})=>({view:qbe(u,e,s),label:t,current:u.scale===e})),scalesLabel:q(`timelineScale`),linkTo:o,onView:l}),p.error&&(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:p.error}),p.capped&&(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:q(`capped`,500,u.scale)}),(0,R.jsxs)(fy,{sensors:E,modifiers:[T],onDragStart:M,onDragMove:N,onDragEnd:ee,onDragCancel:j,accessibility:{announcements:A,screenReaderInstructions:{draggable:q(`timelineInstructions`)}},children:[(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[(0,R.jsx)($be,{ticks:f,days:d,today:D,label:te,trackRef:S}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(exe,{ticks:f,days:d,today:D}),p.loading&&(0,R.jsxs)(`div`,{className:`relative flex flex-col gap-2 p-2`,children:[(0,R.jsx)(Uu,{className:`h-4`}),(0,R.jsx)(Uu,{className:`h-4`})]}),ne&&(0,R.jsx)(`p`,{className:`relative px-2 py-3 text-xs text-muted-foreground`,children:q(`nothingIn`,u.scale)}),!p.loading&&g.map(r=>(0,R.jsxs)(`section`,{"aria-label":r.label,className:`relative border-b border-border last:border-b-0`,children:[r.label!==void 0&&(0,R.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,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:r.rows.length})]}),r.rows.map(r=>(0,R.jsx)(txe,{model:e,view:t,display:n,row:r,days:d,movable:_&&tT(r.record,`update`),dragged:()=>b.current},r.key))]},r.key))]})]}),(0,R.jsx)(vy,{children:v&&(0,R.jsx)(k8,{model:e,view:t,display:n,row:v.row,day:v.day})})]})]})},rxe=({list:e,empty:t,loading:n,children:r})=>(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.loading?n:e.error?(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:e.error}):e.rows.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:t}):r}),ixe=({list:e})=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[e.rows.length.toLocaleString(l()),` of `,e.total.toLocaleString(l())]}),e.more&&(0,R.jsx)(V,{size:`sm`,onClick:e.loadMore,children:q(`showMore`)})]}),W8=`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,axe=`relative flex snap-x snap-mandatory gap-3 overflow-x-auto pb-1`,oxe=({model:e,view:t,display:n,list:r,row:i=!1,footer:a=!0})=>{let o=(t?.names?.plural??K(e.name)).toLowerCase();return(0,R.jsxs)(rxe,{list:r,empty:q(`noneMatch`,o),loading:(0,R.jsx)(`div`,{className:W8,children:Array.from({length:6},(e,t)=>(0,R.jsx)(Uu,{className:`h-24`},t))}),children:[(0,R.jsx)(`ul`,{className:i?axe:W8,"aria-label":t?.names?.plural??K(e.name),children:r.rows.map(r=>(0,R.jsx)(`li`,{className:g(i&&`w-64 shrink-0 snap-start`),children:(0,R.jsx)(k6,{model:e,view:t,display:n,row:r,swipe:!i})},r.key))}),a&&(0,R.jsx)(ixe,{list:r})]})},G8=(0,I.createContext)(void 0),sxe=({value:e,children:t})=>(0,R.jsx)(G8.Provider,{value:e,children:t}),cxe=()=>{let e=(0,I.useContext)(G8);if(!e)throw Error(`useListDisplay is used inside a list display, which the list page draws`);return e},lxe=()=>(0,I.useContext)(G8),K8=({display:e,list:t})=>{let{components:n}=tC(),r=n?.[e.component];return r?(0,R.jsx)(sxe,{value:t,children:(0,R.jsx)(`div`,{className:`relative min-w-0 flex-1 overflow-x-auto`,children:(0,R.jsx)(vg,{name:e.component,children:(0,R.jsx)(r,{...Zn(e.props??{})})})})}):(0,R.jsx)(gg,{children:Xh(q(`noComponent`),e.component)})},q8=Un(),uxe={bounds:{south:-90,west:-180,north:90,east:180},zoom:0},dxe=22,J8=e=>Math.floor(e*1e6)/1e6,Y8=e=>Math.ceil(e*1e6)/1e6,X8=e=>((e+180)%360+360)%360-180,fxe=(e,t)=>{let n=[q8.gte(e.latitude,J8(Math.max(t.south,-90))),q8.lte(e.latitude,Y8(Math.min(t.north,90)))];if(t.east-t.west>=360)return q8.and(...n);let r=q8.gte(e.longitude,J8(X8(t.west))),i=q8.lte(e.longitude,Y8(X8(t.east)));return X8(t.west)<=X8(t.east)?q8.and(...n,r,i):q8.and(...n,q8.or(r,i))},pxe=(e,t,n)=>{let r=Fn(fxe(t,n));return e.trim()===``?r:`(${e}) AND ${r}`},mxe=e=>Math.min(Math.max(Math.floor(e),0),dxe),hxe=(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))}},Z8=e=>{if(typeof e==`number`)return e;if(typeof e==`string`&&e.trim()!==``)return Number(e)},Q8=(e,t)=>{let n=Z8(e[t.latitude]),r=Z8(e[t.longitude]);if(n!==void 0&&r!==void 0&&Math.abs(n)<=90&&Math.abs(r)<=180)return{latitude:n,longitude:r}},gxe=6371008.8,$8=64,e5=(e,t)=>t.approximate===void 0?t.exact!==void 0&&e[t.exact]===!1:e[t.approximate]===!0,t5=(e,t)=>{let n=t/gxe,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%$8/$8*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,n5=(e,t)=>Array.isArray(e)&&e.length>=t&&e.every(_xe),r5=e=>Array.isArray(e)&&e.length>0&&e.every(e=>n5(e,4)),vxe=e=>Array.isArray(e)&&e.length>0&&e.every(e=>n5(e,2)),yxe=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch(e){if(e instanceof SyntaxError)return;throw e}},bxe=e=>{let t=yxe(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`&&r5(i)||r===`MultiPolygon`&&Array.isArray(i)&&i.length>0&&i.every(r5)||r===`LineString`&&n5(i,2)||r===`MultiLineString`&&vxe(i))return{type:r,coordinates:i}},xxe=(e,t,n)=>{if(!e5(e,t))return;let r=t.area===void 0?void 0:bxe(e[t.area]);if(r)return r;let i=t.radius===void 0?void 0:Z8(e[t.radius]);return i!==void 0&&Number.isFinite(i)&&i>0?t5(n,i):t.defaultRadius===void 0?void 0:t5(n,t.defaultRadius)},i5=(e,t)=>e.flatMap(e=>{let n=Q8(e.record,t);if(!n)return[];if(!e5(e.record,t))return[{key:e.key,...n}];let r=xxe(e.record,t,n);return[{key:e.key,...n,approximate:!0,...r&&{area:r}}]}),Sxe=(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}))},Cxe=(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)}},a5=(e,t)=>({keys:e.keys,index:((e.index+t)%e.keys.length+e.keys.length)%e.keys.length}),wxe=({model:e,view:t,display:n,fields:r,filter:i,orderBy:a,area:o})=>{let s=U(),{resources:c,views:l}=J(),u={latitude:n.latitude,longitude:n.longitude},d=o?pxe(i,u,o.bounds):``,f=o?mxe(o.zoom):0;return Ah({queryKey:H.map(e.name,`${u.latitude},${u.longitude}`,f,d,a),enabled:o!==void 0,placeholderData:qm,queryFn:async()=>{let n=await s.map(e.name,{...u,zoom:f,filter:d,orderBy:a,labels:W0(c,l,e,r),photos:jx(t)});return{rows:G0(c,e,r,Mx(e,n.items,n.photos),n.labels).map(t=>rS(e,t)),buckets:n.buckets,total:n.totalSize}}})},Txe=(0,I.lazy)(()=>m(()=>import(`./records-map-XhlRSjHH.js`).then(e=>({default:e.RecordsMap})),__vite__mapDeps([5,1,2,6,7,8,3,4,9]))),Exe=250,o5=`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`,s5=({model:e,view:t,display:n,filter:r,orderBy:i,fields:a,at:o,onMove:s,footer:c=!0,flush:u=!1})=>{let d=J().maps,f=d?.style,[p,m]=(0,I.useState)(),[h,_]=(0,I.useState)(),v=M3(h,Exe),[y,b]=(0,I.useState)(o===void 0),x=wxe({model:e,view:t,display:n,fields:a,filter:r,orderBy:i,area:y?uxe:v}),S=x.isPlaceholderData?void 0:x.data,C=x.data?.rows??[],w=x.data?.buckets??[],T=i5(C,n),E=y&&S?hxe(i5(S.rows,n),S.buckets):void 0,D=eS(t,n),O=(t?.names?.plural??K(e.name)).toLowerCase(),k=(t?.names?.singular??K(e.name)).toLowerCase(),A=Cxe(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?q(t===1?`showOneApproximate`:`showOne`,k):t===0?q(`showMany`,e.length,O):t===e.length?q(`showManyApproximate`,e.length,O):q(`showManySomeApproximate`,e.length,O,t)},ee=e=>q(`zoomIn`,e.toLocaleString(l()),e===1?k:O),te=(0,I.useRef)(null),[ne,re]=(0,I.useState)(0);if((0,I.useLayoutEffect)(()=>re(te.current?.offsetHeight??0),[j?.key]),!f)return(0,R.jsx)(gg,{children:q(`needsStyle`)});let ie=S?.total===0;return(0,R.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,R.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,R.jsx)(I.Suspense,{fallback:null,children:(0,R.jsx)(Txe,{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?ne:0,onSelect:e=>m({keys:e,index:0}),onClear:()=>m(void 0),markerLabel:N,bucketLabel:ee})}),x.error&&(0,R.jsx)(`div`,{className:`absolute inset-x-3 top-3 z-10`,children:(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:x.error})}),ie&&(0,R.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-10 flex justify-center`,children:(0,R.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:[q(y?`noneMatch`:`noneHere`,O),!y&&(0,R.jsx)(V,{size:`sm`,onClick:()=>b(!0),children:q(`showAll`)})]})}),A&&j&&(0,R.jsx)(`div`,{ref:te,className:`pointer-events-none absolute inset-x-3 bottom-3 z-10 flex justify-center`,children:(0,R.jsxs)(`div`,{className:`pointer-events-auto flex w-full max-w-[16rem] flex-col gap-2 sm:max-w-xs`,role:`group`,"aria-label":q(`chosen`,k),children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[M.has(j.key)&&(0,R.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,R.jsx)(Bee,{className:`size-3.5`,"aria-hidden":!0}),q(`approximatePosition`)]}),A.keys.length>1&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":q(`previous`),className:o5,onClick:()=>m(a5(A,-1)),children:(0,R.jsx)(Di,{className:`size-4`,"aria-hidden":!0})}),(0,R.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,R.jsx)(`button`,{type:`button`,"aria-label":q(`next`),className:o5,onClick:()=>m(a5(A,1)),children:(0,R.jsx)(ki,{className:`size-4`,"aria-hidden":!0})})]}),(0,R.jsx)(`button`,{type:`button`,"aria-label":q(`close`),className:o5,onClick:()=>m(void 0),children:(0,R.jsx)(ds,{className:`size-4`,"aria-hidden":!0})})]}),(0,R.jsx)(`div`,{className:`shadow-lg`,children:(0,R.jsx)(k6,{model:e,view:t,display:D,row:j})})]})})]}),c&&(0,R.jsx)(`p`,{className:`hidden py-3 text-xs text-muted-foreground md:block`,children:Dxe(x.data,O)})]})},Dxe=(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`},c5=({value:e,options:t,onChange:n,label:r})=>{let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null),s=(0,I.useRef)(null),c=(0,I.useRef)([]),l=t.findIndex(t=>t.value===e),u=t[l];(0,I.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,R.jsxs)(`div`,{ref:o,className:`relative shrink-0`,children:[(0,R.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,R.jsx)(u.icon,{className:`size-3.5`}),u?.label??r,(0,R.jsx)(Ti,{className:`size-3.5 text-muted-foreground`})]}),i&&(0,R.jsx)(`ul`,{role:`menu`,"aria-label":r,onKeyDown:e=>{if(e.key===`Escape`)return d();if(e.key===`Tab`)return a(!1);let n=j3(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,R.jsx)(`li`,{role:`none`,children:(0,R.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,R.jsx)(t.icon,{className:`size-3.5`}):(0,R.jsx)(`span`,{className:`size-3.5`}),(0,R.jsx)(`span`,{className:`flex-1`,children:t.label}),t.value===e&&(0,R.jsx)(Ci,{className:`size-3.5 text-primary-text`})]})},t.value))})]})},Oxe={table:Wo,cards:va,kanban:Io,board:Uee,list:Ta,calendar:vi,timeline:Lee,map:Fa},l5=({view:e,value:t,onChange:n,menu:r=!1,choices:i=Jx(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:Oxe[e.icon]}));return r?(0,R.jsx)(c5,{label:q(`display`),value:t,onChange:n,options:a}):(0,R.jsx)(f,{label:q(`display`),size:`md`,value:t,onChange:n,options:a})},kxe=[[`asc`,`ascending`],[`desc`,`descending`]],u5=({model:e,view:t,display:n,orderBy:r,onChange:i,className:a})=>{let o=aS(r),s=Pae(e,t,n),c=s.includes(o.columnId)?s:[o.columnId,...s],l=e=>t?.fields[e]?.label??K(e);return(0,R.jsx)(`select`,{"aria-label":q(`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=>kxe.map(([t,n])=>(0,R.jsxs)(`option`,{value:`${e} ${t}`,children:[l(e),`, `,q(n)]},`${e} ${t}`)))})},d5=(e,t,n,r)=>e.map(e=>{let i=t.fields[e.id],a=i&&nC(r,i,n?.fields[e.id]);return a?{...e,render:t=>(0,R.jsx)(iC,{shown:a,part:`cell`,field:i,value:t[e.id],fallback:N4(e,e.value?e.value(t):t[e.id])})}:e}),f5=e=>e.includes(`.`),Axe=({model:e,row:t,column:n})=>{let r=Q0(fT(e,rS(e,t).record),n);return r.state===`loading`?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`…`}):r.state===`missing`?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,R.jsx)(J0,{model:r.model,field:r.field,value:r.value})},jxe=(e,t,{resources:n,views:r})=>{let i=xc(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??K(o),kind:`text`,width:200,render:n=>(0,R.jsx)(Axe,{model:e,row:n,column:t})}},p5=(e,t,n,r)=>{let i=new Map(d5(Ex(e,t,[],n.filter(e=>!f5(e))),e,t,r.fieldTypes).map(e=>[e.id,e]));return n.flatMap(t=>f5(t)?[jxe(e,t,r)]:i.get(t)??[])},m5=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.`}}),h5=(e,t,n)=>{if(!(e>=t))return m5(n?`firstOfAbout`:`firstOf`,e,t.toLocaleString(l()))},g5=(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},Mxe=(e,t,n)=>{if(e.open!==void 0)return e.open!==e.field&&g5(t,e.open,n)?e.open:void 0;let r=t.primaryKey.filter(r=>r!==e.field&&r!==t.tenant&&g5(t,r,n));return r.length===1?r[0]:void 0},_5=(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},v5=(e,t)=>(t?.names?.singular??K(e.name)).toLowerCase(),Nxe=({model:e,view:t,opens:n,resources:r,views:i,canUpdate:a})=>{let o=t=>({kind:`record`,resource:e.name,key:px(e,t)}),s=n&&e.fields[n]?.relation?.resource,c=s?r[s]:void 0,l=e=>{let t=n&&c?_5(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=v5(e,t);return{address:u,actions:t=>{let n={label:m5(`open`,d),link:e=>t(o(e))};if(!c)return[n];let r=e=>a&&tT(e,`update`);return[{label:m5(`open`,v5(c,i[c.name])),available:e=>l(e)!==void 0,link:e=>t(l(e))},{label:m5(`edit`,d),available:r,link:n=>t({kind:`record`,resource:e.name,key:px(e,n),edit:!0})},{...n,available:e=>!r(e)}]}}},Pxe=({model:e,filter:t,orderBy:n,limit:r,fields:i})=>{let a=U(),{resources:o,views:s}=J();return Ah({queryKey:[...H.list(e.name,t,n,r,`embedded`),i.join(`,`)],placeholderData:qm,queryFn:async()=>{let c=W0(o,s,e,i),l=jx(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=G0(o,e,i,Mx(e,u.items,u.photos),u.labels).map((t,n)=>({...t,id:fx(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}}})},y5=({view:e,value:t,onChange:n})=>(0,R.jsx)(l5,{view:e,value:t,onChange:n,menu:!Eu()}),Fxe=()=>(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-4 w-full`},t))}),b5=({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}=J(),m=eT(hS(e.name),`update`),{fields:h}=tC(),{go:g,href:_}=gS(),v=Du(),[y,b]=(0,I.useState)(r||iS(e,t)),x=i??Tx(e,t),S=(0,I.useMemo)(()=>p5(e,t,x,{resources:f,views:p,fieldTypes:h}),[e,t,x.join(`,`),f,p,h]),C=(0,I.useMemo)(()=>nS(e,t,S.map(e=>e.id)),[e,t,S]),w=Pxe({model:e,filter:n,orderBy:y,limit:a,fields:C}),T=w.data?.rows,E=(0,I.useMemo)(()=>T&&{total:T.length,rowAt:e=>T[e]},[T]),D=Kx(t,o),O=t?.names?.plural??K(e.name),k=u&&(0,R.jsxs)(_S,{to:p3(e,t,v,l?{filter:l.filter,orderBy:iS(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,R.jsxs)(R.Fragment,{children:[m5(`viewAll`),` `,(0,R.jsx)(`span`,{className:`sr-only`,children:O.toLowerCase()})]}),(0,R.jsx)(Wr,{className:`size-3.5`,"aria-hidden":!0})]});if(w.isPending)return(0,R.jsx)(Fxe,{});if(w.error)return(0,R.jsx)(US,{title:m5(`couldNotLoad`),error:w.error});if(!E||E.total===0){let e=(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:s??m5(`nothingYet`)});return l&&u?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,k]}):e}let A={resource:e.name,rows:w.data.rows.map(t=>rS(e,t)),total:w.data.total,loading:!1,error:null,more:!1,loadMore:()=>void 0},j=Nxe({model:e,view:t,opens:d,resources:f,views:p,canUpdate:m}),M=e=>({href:_(e),onFollow:()=>g(e)}),N=h5(E.total,w.data.total,w.data.estimated);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[D?D.kind===`cards`?(0,R.jsx)(oxe,{model:e,view:t,display:D,list:A,row:c||v,footer:!1}):D.kind===`map`?(0,R.jsx)(s5,{model:e,view:t,display:D,filter:n,orderBy:y,fields:C,footer:!1}):D.kind===`board`?(0,R.jsx)(u8,{model:e,view:t,display:D,fields:C,filter:n,orderBy:y,limit:a}):D.kind===`calendar`?(0,R.jsx)(P8,{model:e,view:t,display:D,fields:C,filter:n}):D.kind===`timeline`?(0,R.jsx)(U8,{model:e,view:t,display:D,fields:C,filter:n}):(0,R.jsx)(K8,{display:D,list:A}):(0,R.jsx)(o3,{fit:!0,columns:S,source:E,latencyMs:0,sort:aS(y),onSortChange:e=>b(oS(e)),onOpenRow:e=>g(j.address(e)),rowLink:e=>M(j.address(e)),rowActions:j.actions(M),rowNumbers:!1,selectable:!1}),N&&u?(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:N}),k]}):k]})},x5=(e,t,n)=>{let r=Du(),i=qve(t),[a,o]=(0,I.useState)(()=>Jve(localStorage,i)),s=(0,I.useCallback)(e=>{o(e),Yve(localStorage,i,e)},[i]);return[f3(e,r,{picked:a,preferred:n}),s]},Ixe=({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]=x5(t,`page:${e.name}:${s??``}:${n}`,o);return(0,R.jsx)(wT,{title:s,description:c,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(y5,{view:t,value:d,onChange:f}),u]}),className:`h-full`,children:(0,R.jsx)(b5,{model:e,view:t,filter:n,sort:r,columns:i,limit:a,display:d,empty:l})})},Lxe=({node:e,slots:t})=>{let n=xT(e),{resources:r,views:i}=J(),a=r[n.resource];return a?(0,R.jsx)(Ixe,{...n,model:a,view:i[a.name],actions:t.actions}):null},S5=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: {}`}}),C5=({link:e})=>e?(0,R.jsx)(`p`,{className:`mt-3 break-all rounded-md border bg-muted px-3 py-2 text-xs`,children:Xh(S5(`passLinkOn`),(0,R.jsx)(`span`,{className:`font-mono`,children:e}))}):null,w5=({title:e,description:t,onInvite:n,beside:r,children:i,incomplete:a=!1})=>{let[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(),{busy:u,error:d,run:f}=dg(),p=()=>f(async()=>{l((await n(o.trim())).link),s(``)});return(0,R.jsxs)(cp,{title:e,description:t,children:[(0,R.jsx)(lp,{message:d}),(0,R.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,R.jsx)(Rd,{"aria-label":S5(`email`),type:`email`,placeholder:`name@example.com`,value:o,onChange:e=>s(e.target.value),wrapperClassName:`flex-1`}),r,(0,R.jsx)(V,{type:`submit`,variant:`primary`,loading:u,disabled:!o.trim()||a,children:S5(`invite`)})]}),i]}),(0,R.jsx)(C5,{link:c})]})},T5=({email:e,gives:t,expiresAt:n,onResend:r,onRevoke:i})=>{let[a,o]=(0,I.useState)(),{busy:s,error:c,run:u}=dg(),d=new Date(n).getTime()<Date.now();return(0,R.jsxs)(`li`,{className:`px-3 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium`,children:e}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[t,` · `,d?S5(`expired`):S5(`until`,new Date(n).toLocaleDateString(l()))]})]}),(0,R.jsx)(V,{size:`sm`,loading:s,onClick:()=>void u(async()=>o((await r()).link)),children:S5(`sendAgain`)}),(0,R.jsx)(V,{size:`sm`,variant:`danger`,loading:s,onClick:()=>void u(i),children:S5(`revoke`)})]}),(0,R.jsx)(lp,{message:c}),(0,R.jsx)(C5,{link:a})]})},E5=({roles:e,selected:t,grantable:n,disabled:r,onChange:i})=>(0,R.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,R.jsxs)(`label`,{title:o&&!r?G(`cannotChangeRole`):void 0,className:g(`inline-flex items-center gap-1.5`,o&&`text-muted-foreground`),children:[(0,R.jsx)(tg,{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)})}),Rxe=(e,t)=>t.map(t=>cg(e,t)).join(`, `),D5=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`}}),zxe=({roles:e})=>{let{session:t}=B(),[n,r]=(0,I.useState)([]),[i,a]=(0,I.useState)([]),o=(0,I.useCallback)(()=>void t.users.invitations().then(a,()=>a([])),[t]);return(0,I.useEffect)(o,[o]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(w5,{title:D5(`inviteSomeone`),description:D5(`inviteDescription`),onInvite:async e=>{let i=await t.users.invite({email:e,roles:n});return r([]),o(),i},incomplete:n.length===0,children:(0,R.jsx)(E5,{roles:e,selected:n,grantable:new Set(e.map(e=>e.name)),onChange:r})}),(0,R.jsx)(cp,{title:D5(`notAcceptedYet`),description:i.length>0?D5(`sendingAgain`):D5(`nobodyWaiting`),children:i.length>0&&(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:i.map(n=>(0,R.jsx)(T5,{email:n.email,gives:Rxe(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))})})]})},Bxe=({roles:e,onCreated:t})=>{let{session:n}=B(),[r,i]=(0,I.useState)(``),[a,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)([]),{busy:d,error:f,run:p}=dg(),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,R.jsxs)(cp,{title:D5(`addAnAccount`),description:D5(`addDescription`),children:[(0,R.jsx)(lp,{message:f}),(0,R.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,R.jsx)(Rd,{"aria-label":D5(`email`),type:`email`,placeholder:`name@example.com`,value:r,onChange:e=>i(e.target.value),wrapperClassName:`flex-1`}),(0,R.jsx)(Rd,{"aria-label":D5(`name`),placeholder:D5(`name`),autoComplete:`off`,value:a,onChange:e=>o(e.target.value),wrapperClassName:`flex-1`})]}),(0,R.jsx)(Rd,{"aria-label":D5(`password`),type:`password`,autoComplete:`new-password`,placeholder:D5(`passwordOptional`,12),value:s,onChange:e=>c(e.target.value)}),(0,R.jsx)(E5,{roles:e,selected:l,grantable:new Set(e.map(e=>e.name)),onChange:u}),(0,R.jsx)(`div`,{children:(0,R.jsx)(V,{type:`submit`,variant:`primary`,loading:d,disabled:h,children:D5(`addAccount`)})})]})]})},Vxe=a({en:{showMore:`Show more`},nl:{showMore:`Meer tonen`}}),O5=({title:e,description:t,searchLabel:n,placeholder:r,query:i,onQuery:a,list:o,error:s,renderRow:c})=>(0,R.jsxs)(cp,{title:e,description:t,children:[(0,R.jsx)(lp,{message:s}),(0,R.jsx)(Rd,{"aria-label":n,placeholder:r,value:i,onChange:e=>a(e.target.value),leading:(0,R.jsx)(vo,{className:`size-3.5`}),wrapperClassName:`mb-2`}),(0,R.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[o.found.length,` of `,o.total]}),o.found.length>0&&(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:o.found.map(c)}),o.found.length<o.total&&(0,R.jsx)(V,{className:`mt-3`,loading:o.loading,onClick:()=>void o.more(),children:Vxe(`showMore`)})]}),k5=(e,t)=>{let[n,r]=(0,I.useState)([]),[i,a]=(0,I.useState)(0),[o,s]=(0,I.useState)(!1),c=(0,I.useRef)(t);return c.current=t,(0,I.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}},A5=({name:e,email:t,self:n,actions:r,children:i,error:a})=>(0,R.jsxs)(`li`,{className:`flex flex-col gap-2 px-3 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`span`,{className:`block truncate font-medium`,children:[e,n&&` (you)`]}),(0,R.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t})]}),r]}),i,(0,R.jsx)(lp,{message:a})]}),Hxe=({user:e,roles:t,self:n})=>{let{session:r}=B(),[i,a]=(0,I.useState)(e),{busy:o,error:s,run:c,setError:l}=dg(),u=e=>{if(e.length===0)return l(D5(`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,R.jsx)(A5,{name:i.name,email:i.email,self:n,error:s,actions:(0,R.jsxs)(R.Fragment,{children:[i.blocked&&(0,R.jsx)(dd,{tone:`red`,children:D5(`blocked`)}),!n&&(i.blocked?(0,R.jsx)(V,{size:`sm`,loading:o,onClick:()=>d(!1),children:D5(`unblock`)}):(0,R.jsx)(V,{size:`sm`,variant:`danger`,loading:o,onClick:()=>d(!0),children:D5(`block`)}))]}),children:(0,R.jsx)(E5,{roles:t,selected:i.roles,grantable:new Set(t.map(e=>e.name)),disabled:o,onChange:u})})},Uxe=({roles:e,version:t})=>{let{session:n,state:r}=B(),[i,a]=(0,I.useState)(``),o=k5((0,I.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,R.jsx)(O5,{title:D5(`people`),description:D5(`peopleDescription`),searchLabel:D5(`findSomeone`),placeholder:D5(`emailAddress`),query:i,onQuery:a,list:o,renderRow:n=>(0,R.jsx)(Hxe,{user:n,roles:e,self:n.id===s},`${t}/${n.id}`)})},Wxe=()=>{let{session:e}=B(),[t,n]=(0,I.useState)([]),[r,i]=(0,I.useState)();return(0,I.useEffect)(()=>{e.users.roles().then(n,e=>i(e instanceof Dc?ef(e):D5(`couldNotReadRoles`)))},[e]),{roles:t,error:r}},Gxe={Page:jhe,Grid:whe,Card:ET,Stat:hbe,RecordCard:Phe,Field:yhe,Table:Lxe,CardRow:OT,RecordRow:dbe,Chart:mhe,Progress:Mhe,ModalForm:Ahe,Action:CT,Show:fbe,Link:The,Users:()=>{let{roles:e,error:t}=Wxe(),[n,r]=(0,I.useState)(0);return(0,R.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,R.jsx)(lp,{message:t}),(0,R.jsx)(Uxe,{roles:e,version:n}),(0,R.jsx)(zxe,{roles:e}),(0,R.jsx)(Bxe,{roles:e,onCreated:()=>r(e=>e+1)})]})}},j5=e=>typeof e==`string`||!e.custom&&e.type===`Link`,M5=e=>{let t=[];for(let n of e){let e=t.at(-1);j5(n)&&e&&j5(e[0])?e.push(n):t.push([n])}return t.map((e,t)=>{let[n]=e;return j5(n)?(0,R.jsx)(`p`,{className:`leading-6`,children:e.map((e,t)=>typeof e==`string`?(0,R.jsx)(I.Fragment,{children:e},t):(0,R.jsx)(N5,{node:e},t))},t):(0,R.jsx)(N5,{node:n},t)})},Kxe=e=>mc(e)||Array.isArray(e)&&e.length>0&&e.every(mc),qxe=e=>Object.fromEntries(Object.entries(e.props).flatMap(([e,t])=>Kxe(t)?[[e,(0,R.jsx)(R.Fragment,{children:M5(Array.isArray(t)?t:[t])})]]:[])),N5=({node:e})=>{let{components:t}=tC();if(e.custom){let n=t?.[e.type];return n?(0,R.jsx)(vg,{name:e.type,children:(0,R.jsx)(n,{...Zn(e.props),children:e.children.length>0?M5(e.children):void 0})}):(0,R.jsx)(gg,{children:Xh(_g(`noComponent`),e.type)})}let n=Gxe[e.type];return n?(0,R.jsx)(n,{node:e,slots:qxe(e),children:M5(e.children)}):(0,R.jsx)(gg,{children:Xh(_g(`unknownBlock`),e.type)})},P5=({name:e})=>{let t=J().pages[e];return t?(0,R.jsx)(N5,{node:t.tree}):(0,R.jsx)(mS,{title:_g(`notFound`),children:Xh(_g(`noPage`),e)})},F5=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.`}}),Jxe=2e3,I5=(e,t)=>{let n=ub(),[r,i]=(0,I.useState)(`idle`),[a,o]=(0,I.useState)(),s=(0,I.useRef)(void 0);return(0,I.useEffect)(()=>()=>clearTimeout(s.current),[]),{phase:r,message:a,run:async r=>{let a=e===`toast`?n.show({state:`loading`,title:F5(`savingSubject`,t)}):void 0;o(void 0),e===`button`&&i(`saving`);try{return await r(),a!==void 0&&n.update(a,{state:`success`,title:F5(`subjectSaved`,t)}),e===`button`&&(i(`saved`),s.current=setTimeout(()=>i(`idle`),Jxe)),!0}catch(t){if(!Ys(t))throw t;let r=t.status===412?F5(`changedBySomeoneElse`):F5(`couldNotSave`),s=Noe(t);return a!==void 0&&n.update(a,{state:`error`,title:r,description:s}),e===`button`&&(i(`idle`),o(`${r}: ${s}`)),!1}}}},L5=({title:e,eyebrow:t,submit:n,saving:r,disabled:i,error:a,errorTitle:o=FS(`notSaved`),onSubmit:s,onCancel:c,children:l,ref:u})=>{let d=(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c&&(0,R.jsx)(V,{className:`max-sm:min-h-11`,onClick:c,children:FS(`cancel`)}),(0,R.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,R.jsx)(`div`,{className:`mt-4`,children:(0,R.jsx)(US,{title:o,error:a})}),p=(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:l}),m=e=>{e.preventDefault(),s()};return e===void 0?(0,R.jsxs)(`form`,{ref:u,className:`max-w-[760px]`,onSubmit:m,children:[f,p,(0,R.jsx)(`footer`,{className:`border-t pt-6 sm:flex sm:justify-end`,children:d})]}):(0,R.jsx)(`form`,{ref:u,className:`flex-1`,onSubmit:m,children:(0,R.jsxs)(`div`,{className:`mx-auto max-w-[760px] px-4 py-6 md:px-10 md:py-8`,children:[(0,R.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,R.jsxs)(`div`,{children:[t&&(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),(0,R.jsx)(`h1`,{className:`mt-1 text-2xl font-semibold tracking-tight`,children:e})]}),d]}),f,p]})})},Yxe=({noun:e,collection:t,sections:n,saving:r,message:i,onSubmit:a,onCancel:o,ref:s})=>(0,R.jsx)(L5,{ref:s,title:FS(`title`,e),eyebrow:t,submit:FS(`submit`,e),saving:r,error:i?Error(i):void 0,errorTitle:FS(`notCreated`),onSubmit:a,onCancel:o,children:n.map(e=>(0,R.jsx)(mb,{title:e.title,help:e.help,children:(0,R.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:e.fields.map(e=>(0,R.jsx)(pb,{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))}),Xxe=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),Zxe=({resource:e,values:t})=>{let n=J(),r=n.resources[e],i=hS(e);return r?eT(i,`create`)?(0,R.jsx)(Qxe,{resource:e,values:t}):(0,R.jsx)(mS,{title:FS(`notAllowed`),children:FS(`cannotCreate`,n.views[e]?.names?.plural.toLowerCase()??e)}):(0,R.jsx)(mS,{title:W(`notFound`),children:W(`noResource`,e)})},Qxe=({resource:e,values:t})=>{let n=J(),r=n.resources[e],i=n.views[e],a=U(),o=Om(),{go:s}=gS(),c=i?.names?.singular??K(e),l=I5(i?.saveFeedback??`toast`,FS(`subject`,c)),u=$ae(r,i),[d,f]=(0,I.useState)(()=>BS(r,u,t)),[p,m]=(0,I.useState)({}),[h,g]=(0,I.useState)(0),_=pC(h);(0,I.useEffect)(()=>{for(let[e,i]of Object.entries(t??{})){let t=n.resources[r.fields[e]?.relation?.resource??``];t&&H0(o,a,t,[i],n.views[t.name]).then(t=>{let n=t.get(i);n&&f(t=>IS(t[e])&&t[e].key===i?{...t,[e]:{key:i,label:n}}:t)})}},[t,n,r,a,o]);let v=(e,t)=>{m(t=>Xxe(t,e)),f(n=>({...n,[e]:t}))},y=()=>l.run(async()=>{let t;try{t=await a.create(e,RS(r,n.resources,d))}catch(e){let t=fC(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:px(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??K(e),c=p[e];return{name:e,label:s,help:i?.fields[e]?.help,required:zS(t),error:c&&dC(t,s,c),wide:!!(i?.fields[e]?.multiline||i?.fields[e]?.markdown),editor:(0,R.jsx)(cC,{field:t,hints:i?.fields[e],value:IS(a)?a.key:a??(t.type!==`boolean`&&``),stored:void 0,relationLabel:IS(a)?a.label:void 0,placeholder:VS(t)?FS(`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,R.jsx)(Yxe,{ref:_,noun:c,collection:i?.names?.plural??K(e),sections:b,saving:l.phase===`saving`,message:l.message,onSubmit:()=>void y(),onCancel:()=>s({kind:`list`,resource:e})})},$xe=({resource:e,values:t})=>{let n=J(),r=n.views[e];return r?.create?n.pages[r.create.page]?(0,R.jsx)(P5,{name:r.create.page}):(0,R.jsx)(mS,{title:FS(`notAllowed`),children:FS(`cannotCreate`,r.names?.plural.toLowerCase()??K(e))}):(0,R.jsx)(Zxe,{resource:e,values:t},new URLSearchParams(t).toString())},eSe=(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)}}))},tSe=(e,t)=>[...new Set(t.filter(t=>!e.includes(t)))],nSe=Un(),rSe=(e,t)=>{let n=U(),[r,i]=(0,I.useState)({}),a=e=>!!e?.search?.length&&e.primaryKey.length===1,o=Oh({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:qm,queryFn:async()=>{let e=i.primaryKey[0],r=cx(i,t[i.name]);return(await n.list(i.name,{filter:Fn(nSe.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??[]}})},iSe=24,aSe=({model:e,resources:t,views:n,view:r,state:i,extras:a})=>{let o=U(),s=Om(),c=e6(r,e),l=e=>r?.fields[e]?.label??K(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=Oh({queries:d.map(({group:t,field:r})=>{let s=K3(c,{...i,facets:{...i.facets,[t]:[]}},a),l=u(r),d=l?.primaryKey.length===1?cx(l,n[l.name]):void 0;return{queryKey:H.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=Oh({queries:c.facets.map(t=>{let r=u(t.id),a=tSe((p(t.id,t.id)??[]).flatMap(e=>e.value===null?[]:[String(e.value)]),i.facets[t.id]??[]);return{queryKey:H.labels(`facet:${e.name}.${t.id}`,a.join(`,`)),enabled:!!r&&a.length>0,queryFn:async()=>[...await H0(s,o,r,a,n[r.name])]}})}),h=rSe(c.facets.map(e=>({id:e.id,target:e.combobox?u(e.id):void 0})),n),g=c.ranges??[],_=Oh({queries:g.map(t=>{let n=K3(c,w3(i,t.id,void 0),a),s=t6(r,t.id)?iSe:1;return{queryKey:H.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`?_s(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?eSe(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:t6(r,e.id)?n.buckets.map(e=>e.count):[],format:n6(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)}))}},R5=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`}}),oSe=Un(),sSe=({blockingPlural:e,noun:t})=>R5(`stillPointAt`,e,t),cSe=({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??K(a),c=sSe({blockingPlural:s,noun:r});if(!o||i===void 0)return{text:c};let l={kind:`list`,resource:a,filter:Fn(oSe.eq(o,i))};return{text:c,link:{label:R5(`show`,s),to:l}}},lSe=({title:e,noun:t,busy:n,onConfirm:r,onCancel:i})=>(0,R.jsx)(sp,{title:R5(`confirmTitle`,e),description:R5(`confirmDescription`,t,e),onClose:i,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:i,children:R5(`cancel`)}),(0,R.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:r,children:R5(`delete`)})]})}),uSe=({title:e,changes:t,busy:n,onReview:r,onDeleteAnyway:i,onCancel:a})=>(0,R.jsx)(sp,{title:R5(`changedTitle`,e),description:R5(`changedDescription`),onClose:a,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:r,children:R5(`reviewChanges`)}),(0,R.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:i,children:R5(`deleteAnyway`)})]}),children:t.length===0?(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:R5(`noVisibleChanges`)}):(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:t.map(e=>(0,R.jsxs)(`li`,{className:`grid grid-cols-[96px_1fr] gap-3 px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,R.jsx)(`span`,{className:`font-medium`,children:e.after})]})]},e.field))})}),z5=e=>{if(e.stage===`confirm`)return(0,R.jsx)(sp,{title:R5(`bulkConfirmTitle`,e.count,e.plural),description:R5(`bulkConfirmDescription`),onClose:e.onCancel,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:e.onCancel,children:R5(`cancel`)}),(0,R.jsx)(V,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,onClick:e.onConfirm,children:R5(`deleteCount`,e.count)})]})});if(e.stage===`running`)return(0,R.jsx)(sp,{title:R5(`deleting`),description:R5(`progress`,e.done,e.total),onClose:()=>void 0,actions:(0,R.jsx)(V,{loading:!0,disabled:!0,children:R5(`working`)})});let t=e.total-e.failures.length;return(0,R.jsx)(sp,{title:e.failures.length===0?R5(`deleted`,t):R5(`deletedOf`,t,e.total),description:e.failures.length===0?void 0:R5(`kept`,e.failures.length),onClose:e.onClose,actions:(0,R.jsx)(V,{variant:`primary`,onClick:e.onClose,children:R5(`done`)}),children:e.failures.length>0&&(0,R.jsx)(`ul`,{className:`max-h-48 divide-y overflow-y-auto rounded-md border`,children:e.failures.map(e=>(0,R.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,R.jsx)(`span`,{className:`block text-xs text-danger-text`,children:e.message})]},e.title))})})},dSe=new Set([`updated_at`,`updatedAt`]),fSe=(e,t,n,r)=>Object.values(e.fields).flatMap(e=>{if(dSe.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??K(e.name),before:Ox(e,n[e.name],i),after:Ox(e,r[e.name],i)}]}),pSe=4,B5=({model:e,view:t,onDeleted:n,onReview:r,restore:i})=>{let a=U(),o=Om(),s=ub(),[c,l]=(0,I.useState)(),[u,d]=(0,I.useState)(!1),f=t?.names?.singular??K(e.name),p=t?.names?.plural??K(e.name),{resources:m,views:h}=J(),{href:g,open:_}=gS(),v=(t,n)=>t.blockedBy&&cSe({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 Js))throw e;return e}},x=t=>{y(),l(void 0),n?.(t),s.show({state:`success`,title:R5(`deletedToast`,t.title),...e.softDelete&&i&&{action:{label:R5(`undo`),onClick:()=>{i(t).then(()=>{y(),s.show({state:`success`,title:R5(`restored`,t.title)})},e=>{if(!Ys(e))throw e;y(),s.show({state:e.status===409?`success`:`error`,title:e.status===409?R5(`alreadyBack`,t.title):R5(`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:fSe(e,t,n.snapshot,i)})}catch(e){if(!Ys(e))throw e;l(void 0);let t=v(e,n);s.show({state:`error`,title:R5(`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:R5(`changedSinceLoaded`)}:void 0}catch(t){if(!Ys(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(pSe,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,R.jsxs)(R.Fragment,{children:[c.kind===`confirm`&&(0,R.jsx)(lSe,{title:c.target.title,noun:f,busy:u,onCancel:T,onConfirm:()=>void S(c.target,c.target.etag)}),c.kind===`conflict`&&(0,R.jsx)(uSe,{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,R.jsx)(z5,{stage:`confirm`,count:c.targets.length,plural:p,onCancel:T,onConfirm:()=>void w(c.targets)}),c.kind===`bulk-running`&&(0,R.jsx)(z5,{stage:`running`,done:c.done,total:c.total}),c.kind===`bulk-done`&&(0,R.jsx)(z5,{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})}},V5=e=>{let t=U();return e.softDelete?async n=>void await t.undelete(e.name,n.key):void 0},H5=(e,t,n)=>e?.create?Object.hasOwn(t,e.create.page):eT(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}`}}),U5=e=>typeof e==`object`&&!!e,W5=e=>e===null||typeof e==`string`&&e.trim()===``,G5=e=>e===null?``:U5(e)?e.date.replace(`T`,` `):typeof e==`boolean`?e?`TRUE`:`FALSE`:String(e),K5=e=>e<26?String.fromCharCode(65+e):K5(Math.floor(e/26)-1)+K5(e%26),q5=(e,t)=>e[t]?.trim()?e[t]:$(`column`,K5(t)),mSe=e=>/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,hSe=(e,t)=>{let n=[...t].sort((e,t)=>e.line-t.line).map(t=>[...e.map((e,n)=>G5(t.cells[n]??null)),String(t.line),t.problems.join(`; `)]);return`${[[...e,$(`line`),$(`problems`)],...n].map(e=>e.map(mSe).join(`,`)).join(`\r
|
|
68
68
|
`)}\r\n`},J5=({label:e,counts:t})=>(0,R.jsx)(`dl`,{"aria-label":e,className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:t.map(([e,t])=>(0,R.jsxs)(`div`,{className:`rounded-lg border px-3 py-2`,children:[(0,R.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsx)(`dd`,{className:`text-lg font-semibold tabular-nums`,children:t.toLocaleString(l())})]},e))}),Y5=(e,t)=>e?.fields[t]?.label??K(t),gSe=new Set([`text`,`integer`,`bigint`,`decimal`,`boolean`,`date`,`timestamp`,`uuid`,`enum`,`relation`,`currency`,`country`]),X5=(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||!gSe.has(n.type)?!1:n.type!==`relation`||X5(n,t)!==void 0),vSe=new Set([`text`,`integer`,`bigint`,`uuid`,`date`,`currency`,`country`,`enum`]),Z5=e=>{let t=e.primaryKey.length===1?[e.fields[e.primaryKey[0]]]:[],n=Object.values(e.fields).filter(t=>t.filterable&&!t.sensitive&&vSe.has(t.type)&&!e.primaryKey.includes(t.name));return[...t,...n]},Q5=(e,t)=>X5(e,t),$5=e=>!e.nullable&&!e.default,e7=e=>e.toLowerCase().replace(/[\s_-]+/g,``),t7=(e,t,n)=>{let r=new Set;return e.flatMap((e,i)=>{let a=e7(e);if(a===``)return[];let o=t.find(e=>!r.has(e.name)&&(e7(Y5(n,e.name))===a||e7(e.name)===a));return o?(r.add(o.name),[{column:i,field:o.name}]):[]})},n7=(e,t,n)=>{if(e===`update`)return[];let r=new Set(n.map(e=>e.field));return t.filter(e=>$5(e)&&!r.has(e.name))},r7=e=>({ok:!0,value:e}),i7=e=>({ok:!1,problem:e}),a7=e=>`“${G5(e)}”`,o7=(e,t)=>{if(typeof e==`number`)return String(e);if(typeof e==`string`)return wS(e,t.decimal)},ySe=(e,t,n)=>{let r=o7(t,n);if(r===void 0)return i7($(`notNumber`,a7(t)));let[i,a=``]=r.split(`.`);if(/[1-9]/.test(a)||/e/i.test(r))return i7($(`notWholeNumber`,a7(t)));if(e.type===`bigint`)return r7(String(BigInt(i)));let o=Number(i);return Number.isSafeInteger(o)?r7(o):i7($(`tooLarge`,a7(t)))},bSe=(e,t)=>{let n=o7(e,t);return n===void 0?i7($(`notNumber`,a7(e))):r7(n)},xSe=new Set([`true`,`yes`,`1`]),SSe=new Set([`false`,`no`,`0`]),CSe=e=>{if(typeof e==`boolean`)return r7(e);let t=typeof e==`string`||typeof e==`number`?String(e).trim().toLowerCase():``;return xSe.has(t)?r7(!0):SSe.has(t)?r7(!1):i7($(`notBoolean`,a7(e)))},s7=e=>String(e).padStart(2,`0`),wSe=(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}-${s7(t)}-${s7(n)}`},c7=`(\\d{1,2}):(\\d{2})(?::(\\d{2})(?:\\.\\d+)?)?`,TSe=(e,t)=>{let n=RegExp(`^(\\d{4})[-/](\\d{1,2})[-/](\\d{1,2})(?:[T ]${c7}(Z|[+-]\\d{2}:?\\d{2})?)?$`).exec(e.trim()),r=RegExp(`^(\\d{1,2})[./-](\\d{1,2})[./-](\\d{4})(?: ${c7})?$`).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=wSe(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:`${s7(Number(c))}:${l}:${s7(Number(u))}`,zone:n?.[7]}},l7=(e,t)=>{if(U5(e)){let[t,n]=e.date.split(`T`);return{date:t,time:n}}return typeof e==`string`?TSe(e,t.dateOrder):void 0},u7=(e,t)=>i7($(`notDate`,a7(e),t.dateOrder===`dmy`)),ESe=(e,t)=>{let n=l7(e,t);return n?n.time&&n.time!==`00:00:00`?i7($(`hasTime`,a7(e))):r7(n.date):u7(e,t)},DSe=(e,t)=>{let n=l7(e,t);if(!n)return u7(e,t);if(n.zone)return r7(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 r7(new Date(r,i-1,a,o,s,c).toISOString())},d7=e=>e.trim().toLowerCase().replace(/\s+/g,` `),OSe=(e,t,n)=>{let r=e.enumValues??[],i=d7(G5(n)),a=r.filter(e=>d7(e)===i||d7(_s(e,t?.valueLabels))===i);return a.length===1?r7(a[0]):a.length>1?i7($(`severalValues`,a7(n),a.map(e=>_s(e,t?.valueLabels)).join(`, `))):i7($(`notOneOf`,a7(n),r.map(e=>_s(e,t?.valueLabels)).join(`, `)))},kSe=e=>typeof e==`boolean`?i7($(`notText`,a7(e))):r7(G5(e)),f7=(e,t,n,r)=>{if(W5(n))return e.nullable?r7(null):i7($(`emptyRequired`));switch(e.type){case`integer`:case`bigint`:return ySe(e,n,r);case`decimal`:return bSe(n,r);case`boolean`:return CSe(n);case`date`:return ESe(n,r);case`timestamp`:return DSe(n,r);case`enum`:return OSe(e,t,n);case`text`:case`uuid`:case`currency`:case`country`:return kSe(n);default:throw Error(`Not implemented: importing ${e.type} fields, which importableFields leaves out`)}},ASe=(e,t)=>e[t]?.names?.singular??K(t),jSe=(e,t)=>e[t]?.names?.plural??K(t),MSe=(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=Y5(o,d),g=Q5(p,i);if(g&&!W5(m)){let e=f??g.primaryKey[0],n=f7(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]=G5(m);continue}let _=f7(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=f7({...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(`${Y5(o,n.name)}: ${i.problem}`)}return{values:s,data:c,problems:l,relations:u,match:d}},p7=(e,t)=>{let n=e.lookups.keysOf(t.model.name,t.field,t.value),r=`${Y5(e.views[t.model.name],t.field).toLowerCase()} “${String(t.value)}”`;return n.length===1?{key:n[0]}:n.length===0?{none:$(`noneHas`,ASe(e.views,t.model.name),r)}:{several:$(`severalHave`,n.length,jSe(e.views,t.model.name),r)}},NSe=e=>e.cells.every(W5),m7=async(e,t,n)=>{let{model:r,views:i}=n,a=e.filter(e=>!NSe(e)).map(e=>({row:e,...MSe(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=p7(n,t);`key`in a?u[e]=a.key:s.push(`${Y5(i[r.name],e)}: ${a.none??a.several}`)}let d=l&&p7(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}}})},PSe=5,FSe=5,ISe=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(G5),sample:a.slice(0,PSe)}};async function*h7(e,t){let n=!0;for await(let r of e.rows(t))yield n?r.slice(1):r,n=!1}var LSe=async(e,t,n,r,i,a)=>{let o={rows:0,creates:0,updates:0,problems:[],preview:[]};for await(let s of h7(e,t)){a?.throwIfAborted();for(let e of await m7(s,n,r))o.rows++,o.preview.length<FSe&&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},RSe=(e,t)=>{if(!Ys(e))return[e.message];let n=e.errors.filter(e=>e.field);return n.length===0?[e.message]:n.map(e=>`${Y5(t.views[t.model.name],e.field)}: ${e.message}`)},zSe=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=Ys(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:RSe(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 h7(e,t)){for(let e of await m7(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}},g7=50,_7=(e,t,n)=>pp(hSe(t,n),$(`notImportedFile`,(e??`import`).replace(/\.[^.]+$/,``)),`text/csv`),v7=({rows:e})=>(0,R.jsxs)(`ul`,{"aria-label":$(`rowsNotImported`),className:`flex flex-col gap-1 text-body`,children:[e.slice(0,g7).map(e=>(0,R.jsxs)(`li`,{children:[(0,R.jsx)(`span`,{className:`font-medium`,children:$(`rowProblems`,e.line)}),` `,e.problems.join(`; `)]},e.line)),e.length>g7&&(0,R.jsx)(`li`,{className:`text-muted-foreground`,children:$(`andMore`,(e.length-g7).toLocaleString(l()))})]}),BSe=({rows:e})=>(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,R.jsx)(Vd,{className:`size-3.5`}),$(`checkingRows`,e.toLocaleString(l()))]}),VSe=({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,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(J5,{label:$(`check`),counts:[[$(`rows`),e.rows],[$(`toCreate`),e.creates],[$(`toUpdate`),e.updates],[$(`withProblems`),e.problems.length]]}),e.preview.length>0&&(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,R.jsxs)(`table`,{"aria-label":$(`firstRows`),className:`w-full text-left text-body`,children:[(0,R.jsx)(`thead`,{className:`bg-muted text-muted-foreground`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`px-2 py-1.5 font-medium`,children:$(`row`)}),c.map(e=>(0,R.jsx)(`th`,{className:`whitespace-nowrap px-2 py-1.5 font-medium`,children:Y5(s,e.name)},e.name))]})}),(0,R.jsx)(`tbody`,{className:`divide-y`,children:e.preview.map(e=>(0,R.jsxs)(`tr`,{className:e.problems.length>0?`bg-danger-soft`:void 0,children:[(0,R.jsx)(`td`,{className:`px-2 py-1.5 tabular-nums text-muted-foreground`,children:e.line}),c.map(t=>(0,R.jsx)(`td`,{className:`max-w-48 truncate px-2 py-1.5`,children:Q5(t,n)?String(e.values[t.name]??`—`):t.name in e.values?Ox(t,e.values[t.name],s?.fields[t.name]):``},t.name))]},e.line))})]})}),e.problems.length>0&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`h3`,{className:`font-medium`,children:$(`problemRows`)}),(0,R.jsxs)(V,{size:`sm`,onClick:()=>_7(o,a,e.problems),children:[(0,R.jsx)(Gi,{className:`size-3.5`}),$(`download`)]})]}),(0,R.jsx)(v7,{rows:e.problems})]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:$(`batches`,100)})]})},y7=({label:e,name:t,value:n,options:r,onChange:i,help:a,className:o})=>{let s=(0,I.useId)();return(0,R.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1.5`,o),children:[(0,R.jsx)(`label`,{htmlFor:s,className:`font-medium`,children:e}),(0,R.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,R.jsx)(`option`,{value:e.value,children:e.label},e.value))}),a&&(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a})]})},HSe=({file:e,sheets:t,sheet:n,reading:r,onChoose:i,onSheet:a})=>{let o=(0,I.useId)();return(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`label`,{htmlFor:o,className:`font-medium`,children:$(`file`)}),(0,R.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,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:$(`fileHint`)})]}),r&&(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,R.jsx)(Vd,{className:`size-3.5`}),$(`reading`,e?.name??$(`theFile`))]}),!r&&t.length>1&&(0,R.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,R.jsx)(Zee,{className:`mb-2 size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(y7,{className:`flex-1`,label:$(`sheet`),value:n??``,options:t.map(e=>({value:e,label:e})),onChange:a})]})]})},USe=()=>[{value:`create`,label:$(`create`)},{value:`update`,label:$(`update`)},{value:`upsert`,label:$(`upsert`)}],WSe={create:`createHint`,update:`updateHint`,upsert:`upsertHint`},b7=``,GSe=({flow:e,model:t,resources:n,views:r,canUpdate:i})=>{let a=r[t.name],o=e.head?.headers??[],s=e.head?.sample??[],c=n7(e.mode,e.fields,e.columns),l=[{value:b7,label:$(`doNotImport`)},...e.fields.map(e=>({value:e.name,label:`${Y5(a,e.name)}${$5(e)?` *`:``}`}))],u=o.map((e,t)=>({value:String(t),label:q5(o,t)})),d=Z5(t);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[i&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:$(`rows`)}),(0,R.jsx)(`div`,{children:(0,R.jsx)(f,{label:$(`whatEachRowDoes`),size:`md`,value:e.mode,options:USe(),onChange:e.setMode})}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:$(WSe[e.mode])})]}),e.mode!==`create`&&(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,R.jsx)(y7,{label:$(`findBy`),value:e.match?.field??b7,options:[{value:b7,label:$(`chooseField`)},...d.map(e=>({value:e.name,label:Y5(a,e.name)}))],onChange:t=>e.setMatch(t?{field:t,column:e.match?.column??0}:void 0),help:$(`findByHint`)}),(0,R.jsx)(y7,{label:$(`foundInColumn`),value:e.match?String(e.match.column):b7,options:[{value:b7,label:$(`chooseColumn`)},...u],onChange:t=>e.setMatch(t&&e.match?{...e.match,column:Number(t)}:e.match)})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,R.jsx)(y7,{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,R.jsx)(y7,{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,R.jsx)(`p`,{className:`-mb-3 text-xs text-muted-foreground`,children:$(`requiredMarked`)}),(0,R.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?Q5(d,n):void 0,p=s.map(e=>G5(e.cells[c]??null)).filter(e=>e!==``).slice(0,3),m=q5(o,c);return(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 py-3 sm:grid-cols-2 sm:gap-4`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate font-medium`,children:m}),(0,R.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:p.length>0?p.join(`, `):$(`emptyInFirstRows`)})]}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,R.jsx)(y7,{label:$(`field`),name:$(`fieldFor`,m),value:u?.field??b7,options:l,onChange:t=>e.mapColumn(c,t||void 0)}),f&&(0,R.jsx)(y7,{label:$(`foundBy`),name:$(`pluralFoundBy`,r[f.name]?.names?.plural??Y5(a,d.name)),value:u.matchBy??f.primaryKey[0],options:Z5(f).map(e=>({value:e.name,label:Y5(r[f.name],e.name)})),onChange:t=>e.matchColumnBy(c,t)})]})]},c)})}),c.length>0&&(0,R.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,R.jsx)(Qo,{className:`mt-0.5 size-4 shrink-0`}),(0,R.jsx)(`span`,{children:$(`noColumnFills`,c.map(e=>Y5(a,e.name)).join(`, `))})]})]})},x7=e=>e.toLocaleString(l()),KSe=({progress:e,total:t,cancelling:n})=>{let r=e.created+e.updated+e.failed;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:$(n?`stopping`:`saving`)}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[x7(r),` / `,x7(t)]})]}),(0,R.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,R.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${t>0?Math.min(100,r/t*100):0}%`}})})]})},qSe=({result:e,stopped:t,headers:n,fileName:r})=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t!==void 0&&(0,R.jsx)(US,{title:$(`stopped`),error:t}),e.cancelled&&(0,R.jsx)(`p`,{role:`status`,children:$(`cancelled`)}),(0,R.jsx)(J5,{label:$(`summary`),counts:[[$(`created`),e.created],[$(`updated`),e.updated],[$(`skipped`),e.skipped],[$(`failed`),e.failed]]}),e.notWritten.length>0&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`h3`,{className:`font-medium`,children:$(`rowsNotImported`)}),(0,R.jsxs)(V,{size:`sm`,onClick:()=>_7(r,n,e.notWritten),children:[(0,R.jsx)(Gi,{className:`size-3.5`}),$(`download`)]})]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:$(`notWrittenHint`)}),(0,R.jsx)(v7,{rows:[...e.notWritten].sort((e,t)=>e.line-t.line)})]})]}),JSe=e=>{let t=SS(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`}},YSe=Un(),S7=100,C7=e=>String(e),XSe=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(C7(e))).map(e=>[C7(e),e])).values()],s=t.primaryKey[0];for(let n=0;n<o.length;n+=S7){let i=o.slice(n,n+S7);for(let e of i)a.set(C7(e),[]);let c=Fn(YSe.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(C7(e[r]))?.push(e[s]);l=n.nextPageToken||void 0}while(l)}},keysOf:(e,t,r)=>n(e,t).get(C7(r))??[]}},ZSe=500,w7=()=>{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()}},QSe=e=>({sheets:async()=>{let t=w7();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=w7();try{for(n.send({type:`read`,file:e,sheet:t,chunk:ZSe,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()}}}),T7={created:0,updated:0,skipped:0,failed:0,notWritten:[]},$Se=({model:e,resources:t,views:n,sourceFor:r=QSe})=>{let i=vre(),a=Om(),o=n[e.name],s=(0,I.useMemo)(()=>_Se(e,t),[e,t]),[c,l]=(0,I.useState)({kind:`file`,reading:!1}),[u,d]=(0,I.useState)(),[f,p]=(0,I.useState)(),[m,h]=(0,I.useState)(),[g,_]=(0,I.useState)(),[v,y]=(0,I.useState)(`create`),[b,x]=(0,I.useState)([]),[S,C]=(0,I.useState)(),[w,T]=(0,I.useState)(()=>JSe()),E=(0,I.useRef)(!1),D=(0,I.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 ISe(t,n);_(r),x(t7(r.headers,s,o));let i=Z5(e)[0],a=i?t7(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)),ee=()=>({mode:v,columns:b,match:v===`create`?void 0:S,options:w}),te=()=>({model:e,resources:t,views:n,lookups:XSe(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}),LSe(f.source,m,ee(),te(),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:T7,total:t,cancelling:!1});let n=T7;zSe(f.source,m,ee(),te(),{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()}},eCe=e=>e.step.kind===`file`?$(`couldNotReadFile`):$(`couldNotCheck`),tCe=e=>e.columns.length===0?!1:e.mode===`create`?n7(`create`,e.fields,e.columns).length===0:e.match!==void 0,nCe=({model:e,resources:t,views:n,canUpdate:r,onClose:i,sourceFor:a})=>{let o=$Se({model:e,resources:t,views:n,sourceFor:a}),s=n[e.name]?.names?.plural??K(e.name),{step:c}=o,u=o.head?.headers??[],d=()=>{c.kind!==`importing`&&(o.stop(),i())},f=(0,R.jsx)(V,{onClick:d,children:$(`cancel`)});return(0,R.jsx)(Mw,{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,R.jsxs)(R.Fragment,{children:[f,o.sheets.length>1&&(0,R.jsx)(V,{variant:`primary`,loading:c.reading,onClick:o.openSheet,children:$(`next`)})]});case`map`:return(0,R.jsxs)(R.Fragment,{children:[f,(0,R.jsx)(V,{variant:`primary`,disabled:!tCe(o),onClick:o.check,children:$(`checkRows`)})]});case`checking`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:o.back,children:$(`back`)}),(0,R.jsx)(V,{variant:`primary`,loading:!0,children:$(`checking`)})]});case`checked`:{let e=c.check.creates+c.check.updates;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:o.back,children:$(`back`)}),(0,R.jsx)(V,{variant:`primary`,disabled:e===0,onClick:()=>o.start(e),children:$(`importRows`,e.toLocaleString(l()),e)})]})}case`importing`:return(0,R.jsx)(V,{variant:`danger`,disabled:c.cancelling,onClick:o.cancel,children:$(`cancelImport`)});case`done`:return(0,R.jsx)(V,{variant:`primary`,onClick:i,children:$(`done`)})}})(),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.error!==void 0&&(0,R.jsx)(US,{title:eCe(o),error:o.error}),(()=>{switch(c.kind){case`file`:return(0,R.jsx)(HSe,{file:o.file,sheets:o.sheets,sheet:o.sheet,reading:c.reading,onChoose:o.choose,onSheet:o.setSheet});case`map`:return(0,R.jsx)(GSe,{flow:o,model:e,resources:t,views:n,canUpdate:r});case`checking`:return(0,R.jsx)(BSe,{rows:c.rows});case`checked`:return(0,R.jsx)(VSe,{check:c.check,model:e,resources:t,views:n,columns:o.columns,headers:u,fileName:o.file?.name});case`importing`:return(0,R.jsx)(KSe,{progress:c.progress,total:c.total,cancelling:c.cancelling});case`done`:return(0,R.jsx)(qSe,{result:c.result,stopped:c.stopped,headers:u,fileName:o.file?.name})}})()]})})},rCe=({model:e})=>{let{resources:t,views:n}=J(),r=hS(e.name),[i,a]=(0,I.useState)(!1);return n[e.name]?.import===!1||!eT(r,`create`)?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(V,{onClick:()=>a(!0),"aria-haspopup":`dialog`,children:[(0,R.jsx)(ns,{className:`size-3.5`}),$(`import`)]}),i&&(0,R.jsx)(nCe,{model:e,resources:t,views:n,canUpdate:eT(r,`update`),onClose:()=>a(!1)})]})},E7=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`}}),iCe=()=>new DOMException(E7(`cancelled`),`AbortError`),aCe=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 iCe();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 D7(s,c),{rows:f,truncated:g.length<h.items.length||m!==``||i+1<n.length}}while(m!==``)}return await D7(s,c),{rows:f,truncated:!1}}catch(e){throw await c.abort(),e}finally{s.close()}},D7=async(e,t)=>{await t.write(await e.send({kind:`finish`})),await t.close()},oCe=1048575,O7=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
69
69
|
`,k7=`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,A7=`http://schemas.openxmlformats.org/package/2006/relationships`;`${O7}`,`${O7}${A7}${k7}`,`${O7}${A7}${k7}${k7}`,new TextEncoder;var sCe=Un(),j7=e=>e?.export!==!1,M7=e=>Object.values(e.fields).flatMap(e=>e.sensitive?[]:[e.name]),cCe=(e,t)=>{let n=new Set(M7(e));return Tx(e,t).filter(e=>n.has(e))},N7=(e,t,n)=>Object.fromEntries(Ex(e,t,[],n).map(e=>[e.id,e.header])),lCe=(e,t,n)=>{let r=N7(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]??{}}]:[]})},P7=(e,t)=>{let n=e?.export?e.export.maxRows??1/0:1/0;return Math.min(n,t===`xlsx`?oCe:1/0)},F7=e=>e.primaryKey.length===1,uCe=(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(sCe.in(n,t.slice(e,e+500))));return r},dCe=()=>{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(E7(`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()}},fCe=()=>[{value:`xlsx`,label:E7(`excel`)},{value:`csv`,label:E7(`csv`)}],pCe=()=>[{value:`shown`,label:E7(`asShown`)},{value:`raw`,label:E7(`rawValues`)}],mCe={shown:`shownHint`,raw:`rawHint`},hCe=e=>e.kind===`counting`?E7(`counting`):e.kind===`exact`||e.rows>1e4?Tf(e.rows):E7(`moreThan`),I7=e=>{if(e.kind!==`counting`)return e.kind===`exact`?e.rows:Math.max(e.rows,10001)},L7=({label:e,help:t,children:n})=>(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-1.5`,children:[(0,R.jsx)(`span`,{className:`text-body font-medium`,children:e}),n,t&&(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]}),R7=(e,t,n)=>{let r=e.indexOf(t),i=[...e];return i.splice(r,1),i.splice(r+n,0,t),i},gCe=({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,R.jsx)(`ul`,{className:`divide-y self-stretch rounded-md border`,"aria-label":E7(`columns`),children:i.map(e=>{let i=t.includes(e),a=t.indexOf(e);return(0,R.jsxs)(`li`,{className:`flex min-h-10 items-center gap-2 px-3 py-1`,children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-1 cursor-pointer items-center gap-2.5`,children:[(0,R.jsx)(tg,{checked:i,label:r[e],onChange:r=>n(r?[...t,e]:t.filter(t=>t!==e))}),(0,R.jsx)(`span`,{className:i?`truncate`:`truncate text-muted-foreground`,children:r[e]})]}),i&&(0,R.jsxs)(`span`,{className:`flex shrink-0 gap-1`,children:[(0,R.jsx)(V,{size:`sm`,variant:`ghost`,className:`min-h-8 px-2`,"aria-label":E7(`moveUp`,r[e]),disabled:a===0,onClick:()=>n(R7(t,e,-1)),children:(0,R.jsx)(Xr,{className:`size-3.5`})}),(0,R.jsx)(V,{size:`sm`,variant:`ghost`,className:`min-h-8 px-2`,"aria-label":E7(`moveDown`,r[e]),disabled:a===t.length-1,onClick:()=>n(R7(t,e,1)),children:(0,R.jsx)(Br,{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,I.useState)(`xlsx`),[d,p]=(0,I.useState)(a?`selected`:`list`),[m,h]=(0,I.useState)(r),[g,_]=(0,I.useState)(`shown`),v=P7(t,l),y=d===`selected`?E7(`selectedRows`,Sf(a??0),a??0):hCe(i),b=(d===`selected`?a??0:I7(i)??0)>v,x=[{value:`list`,label:E7(`rowsInList`)},{value:`selected`,label:E7(`selected`,Sf(a??0))}];return(0,R.jsx)(Mw,{title:E7(`exportPlural`,e),open:o,onClose:c,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:c,children:E7(`cancel`)}),(0,R.jsx)(V,{variant:`primary`,disabled:m.length===0,onClick:()=>s({format:l,scope:d,columns:m,mode:g}),children:E7(`export`)})]}),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-4 text-body`,children:[(0,R.jsx)(L7,{label:E7(`format`),children:(0,R.jsx)(f,{size:`md`,label:E7(`format`),value:l,options:fCe(),onChange:u})}),a!==void 0&&a>0&&(0,R.jsx)(L7,{label:E7(`rows`),help:d===`list`?E7(`listHint`):void 0,children:(0,R.jsx)(f,{size:`md`,label:E7(`rows`),value:d,options:x,onChange:p})}),(0,R.jsx)(L7,{label:E7(`values`),help:E7(mCe[g]),children:(0,R.jsx)(f,{size:`md`,label:E7(`values`),value:g,options:pCe(),onChange:_})}),(0,R.jsx)(L7,{label:E7(`columns`),children:(0,R.jsx)(gCe,{fields:n,columns:m,onChange:h})}),(0,R.jsxs)(`p`,{role:`status`,className:`text-muted-foreground`,children:[E7(`exports`,y),b&&E7(`overLimit`,Sf(v))]})]})})},vCe=({plural:e,done:t,total:n,onCancel:r})=>{let i=n?Math.min(1,t/n):void 0;return(0,R.jsx)(Mw,{title:E7(`exporting`,e),open:!0,onClose:r,actions:(0,R.jsx)(V,{onClick:r,children:E7(`cancel`)}),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 text-body`,children:[(0,R.jsx)(`div`,{role:`progressbar`,"aria-label":E7(`rowsExported`),"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":t,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,R.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${(i??0)*100}%`}})}),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:n?E7(`doneOf`,Sf(t),Sf(n)):E7(`done`,Sf(t))})]})})},z7={xlsx:{mime:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,extension:`.xlsx`,description:`workbook`},csv:{mime:`text/csv`,extension:`.csv`,description:`csvFile`}},yCe=/[\\/:*?"<>|\u0000-\u001f]/g,bCe=(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(yCe,` `).trim()} ${r}${z7[t].extension}`},xCe=8e6,SCe=(e,t)=>{let n=new Blob([],{type:z7[t].mime}),r=[],i=0,a=()=>{n=new Blob([n,...r],{type:z7[t].mime}),r=[],i=0};return{write:async e=>{e.length!==0&&(r.push(e),i+=e.length,i>=xCe&&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([])}}},B7=()=>globalThis.showSaveFilePicker,CCe=()=>typeof B7()==`function`,wCe=async(e,t)=>{let n=B7();if(!n)throw Error(`This browser cannot save a file as it is built`);let r=z7[t],i;try{i=await n({suggestedName:e,types:[{description:E7(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()}},TCe=(e,t)=>CCe()?wCe(e,t):Promise.resolve(SCe(e,t)),ECe=(e,t)=>{let n=t[e.primaryKey[0]];return typeof n==`object`&&n&&`id`in n?n.id:n},DCe=({model:e,view:t,resources:n,views:r,plural:i,filter:a,orderBy:o,createPort:s=dCe,createSink:c=TCe})=>{let l=U(),u=ub(),[d,f]=(0,I.useState)({kind:`closed`}),p=(0,I.useRef)(void 0),m=Ah({queryKey:H.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:F7(e)?t.map(t=>ECe(e,t)):[]}),g=async(d,h)=>{let g=bCe(i,d.format),_=await c(g,d.format);if(!_)return;let v=P7(t,d.format),y=d.scope===`selected`?h.length:I7(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 aCe({client:l,resource:e.name,filters:d.scope===`selected`?uCe(e,h):[a],orderBy:o,plan:{format:d.format,mode:d.mode,name:i,columns:lCe(e,t,d.columns)},labels:d.mode===`shown`?W0(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:E7(`exported`,Sf(c.rows),i),description:c.truncated?E7(`truncated`,g,Sf(c.rows)):g})}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;if(!Ys(e))throw e;u.show({state:`error`,title:E7(`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=M7(e),y=N7(e,t,v);return{open:h,dialogs:d.kind===`settings`?(0,R.jsx)(_Ce,{plural:i,view:t,fields:v.map(e=>({name:e,label:y[e]})),initialColumns:cCe(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,R.jsx)(vCe,{plural:i,done:d.done,total:d.total,onCancel:_}):null}},V7=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`}}),OCe=({state:e,onClearSearch:t,onClearFilters:n,create:r})=>(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-8 text-center text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:e.message}),(e.clearSearch||e.clearFilters||e.create&&r)&&(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[e.clearSearch&&(0,R.jsx)(V,{onClick:t,children:V7(`clearSearch`)}),e.clearFilters&&(0,R.jsx)(V,{onClick:n,children:V7(`clearFilters`)}),e.create&&r]})]}),kCe=({plural:e,search:t,filtered:n,scoped:r,canCreate:i})=>t?{message:V7(`noMatchSearch`,e,t),clearSearch:!0,clearFilters:n,create:!1}:n?{message:V7(`noMatchFilters`,e),clearSearch:!1,clearFilters:!0,create:!1}:r?{message:V7(`noMatch`,e),clearSearch:!1,clearFilters:!1,create:!1}:{message:V7(`noneYet`,e),clearSearch:!1,clearFilters:!1,create:i},ACe=(e,t)=>{},jCe=({windowMs:e=1e3,comebacks:t=2,onHold:n=ACe}={})=>{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}},MCe=e=>Math.max(1,Math.floor((e+12)/252)),NCe=(e,t)=>Math.max(0,(e-(t-1)*12)/t),PCe=(e,t,n,r)=>({start:e*n,end:Math.max(0,Math.min(r,(t+1)*n)-1)}),FCe=(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},ICe=(e,t)=>{let n=e/t.rowHeight;return Math.floor(n)*t.columns+n%1},LCe=(e,t)=>Math.floor(Math.floor(e)/t)+e%1,RCe=8,zCe=(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<=RCe)break;i.delete(e)}return i},BCe=({source:e,label:t,initialIndex:n,onScrollIndex:r,minHeight:i,children:a})=>{let{total:o}=e,[s]=(0,I.useState)(n),[c,l]=(0,I.useState)(0),u=MCe(c),d=NCe(c,u),[f,p]=(0,I.useState)(()=>new Map),m=Math.ceil(Math.max(i(d),f.get(d)??0)),h=m+12,g={columns:u,rowHeight:h},_=(0,I.useRef)({layout:g,top:0}),v=_.current.top>0&&(_.current.layout.columns!==u||_.current.layout.rowHeight!==h),y=e=>v?FCe(_.current.top,_.current.layout,g):e,b=d>0&&f.has(d),x=r3({total:Math.ceil(o/u),rowHeight:h,initialIndex:LCe(s,u),settle:y,ready:b,onScroll:e=>r(ICe(e,g))});(0,I.useLayoutEffect)(()=>{v&&x.scrollTo(x.top),_.current={layout:g,top:x.top}});let S=PCe(x.first,x.last,u,o),C=Y4({total:o,rowAt:e.rowAt,loadRows:e.loadRows,revision:e.revision,latencyMs:0},S.start,S.end),[w]=(0,I.useState)(()=>jCe());(0,I.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,I.useRef)(d);T.current=d;let[E]=(0,I.useState)(()=>new ResizeObserver(e=>{let t=Math.max(...e.map(e=>e.borderBoxSize[0]?.blockSize??e.contentRect.height)),n=T.current;p(e=>zCe(e,n,t))}));(0,I.useLayoutEffect)(()=>()=>E.disconnect(),[E]);let D=(0,I.useCallback)(e=>{if(e)return E.observe(e),()=>E.unobserve(e)},[E]);return(0,R.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,R.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,R.jsx)(`li`,{"aria-hidden":!0,className:`absolute grid grid-cols-[minmax(0,1fr)]`,style:c,children:(0,R.jsx)(Uu,{className:`h-full rounded-lg`})},`skeleton-${i}`)}))})},VCe=`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,HCe=e=>e*.75,UCe=44,WCe=({model:e,view:t,display:n,list:r,empty:i})=>{let a=t?.names?.plural??K(e.name),o=n.card===void 0&&(n.image!==void 0||n.photos!==void 0);return r.isLoading?(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden ${VCe}`,children:Array.from({length:6},(e,t)=>(0,R.jsx)(Uu,{className:`h-24`},t))}):r.error?(0,R.jsx)(US,{title:q(`couldNotLoadRows`),error:r.error}):!r.source||r.source.total===0?i??(0,R.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:q(`noneMatch`,a.toLowerCase())}):(0,R.jsx)(BCe,{source:r.source,label:a,initialIndex:r.initialIndex,onScrollIndex:r.onScrollIndex,minHeight:e=>(o?HCe(e):0)+UCe,children:r=>(0,R.jsx)(k6,{model:e,view:t,display:n,row:rS(e,r)})})},H7=`protobase:list-places`,GCe=50,U7=(e,t)=>`${e} ${t}`,KCe=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},qCe=e=>u(()=>{let t=e.getItem(H7);if(t===null)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(KCe):[]},[]),JCe=e=>{let t=new Map(qCe(e).map(e=>[U7(e.entry,e.url),e]));return{placeOf:(e,n)=>{let r=t.get(U7(e,n));return r?r.place:[...t.values()].findLast(e=>e.url===n)?.place??0},save:(e,n,r)=>{let i=U7(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-GCe)))t.delete(e)},persist:()=>u(()=>e.setItem(H7,JSON.stringify([...t.values()])),void 0)}},YCe={getItem:()=>null,setItem:()=>{}},XCe,ZCe=()=>XCe??=JCe(u(()=>window.sessionStorage,void 0)??YCe),QCe=()=>{let{entry:e,path:t,params:n}=Bh(),r=`${t}?${n.toString()}`,i=ZCe();(0,I.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,I.useCallback)(t=>i.save(e,r,t),[i,e,r]);return{initialIndex:i.placeOf(e,r),remember:a}},W7=e=>e.reduce((e,t)=>e+t.count,0),$Ce=e=>{let t=Math.floor(e.length/2),n=W7(e.slice(0,t)),r=W7(e.slice(e.length-t));return n===0?0:(r-n)/n*100},ewe=({active:e,payload:t,noun:n})=>{let r=t?.[0]?.payload;return!e||!r?null:(0,R.jsxs)(`div`,{className:`rounded-md border bg-background px-2.5 py-1.5 text-xs shadow-pop`,children:[(0,R.jsx)(`div`,{className:`text-muted-foreground`,children:Uf(r.at)}),(0,R.jsxs)(`div`,{className:`font-semibold tabular-nums`,children:[Sf(r.count),` `,n]})]})},G7=a({en:{day:`Day`,week:`Week`},nl:{day:`Dag`,week:`Week`}}),K7={fontSize:11,fill:`var(--muted-foreground)`},twe=({title:e=`Orders created`,noun:t=`orders`,defaultGranularity:n=`day`,data:r,granularity:i,onGranularityChange:a,periodLabel:o,className:s})=>{let[c,l]=(0,I.useState)(n),u=i??c,d=a??l,p=r??Wy(u),m=Tu(`(min-width: 640px)`),h=$Ce(p);return(0,R.jsxs)(`section`,{className:g(`rounded-lg border bg-background px-4 pb-2 pt-3`,s),children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`h2`,{className:`font-semibold`,children:e}),(0,R.jsx)(`span`,{className:`font-semibold tabular-nums`,children:Sf(W7(p))}),(0,R.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,R.jsx)(`span`,{className:`hidden text-xs text-muted-foreground sm:inline`,children:o??`last ${u===`day`?`30 days`:`12 weeks`}`})]}),(0,R.jsx)(f,{value:u,onChange:d,options:[{value:`day`,label:G7(`day`)},{value:`week`,label:G7(`week`)}]})]}),(0,R.jsx)(`div`,{className:`mt-2 h-24`,children:(0,R.jsx)(FM,{width:`100%`,height:`100%`,children:(0,R.jsxs)(E0,{data:p,margin:{top:4,right:0,bottom:0,left:0},barCategoryGap:u===`day`?`22%`:`30%`,children:[(0,R.jsx)(F$,{vertical:!1,stroke:`var(--border)`}),(0,R.jsx)(C1,{dataKey:`at`,padding:{left:4,right:m?4:18},tickFormatter:Wf,tick:K7,axisLine:!1,tickLine:!1,interval:u===`day`?m?4:9:m?1:3,height:18}),(0,R.jsx)(O1,{width:m?36:28,tick:K7,axisLine:!1,tickLine:!1,tickCount:3}),(0,R.jsx)(Dq,{cursor:{fill:`var(--muted)`},content:(0,R.jsx)(ewe,{noun:t}),isAnimationActive:!1}),(0,R.jsx)(h1,{dataKey:`count`,fill:`var(--primary)`,radius:[2,2,0,0],isAnimationActive:!1})]})})})]})},nwe={"7d":`last 7 days`,"30d":`last 30 days`,"90d":`last 90 days`,"1y":`last year`,all:`all time`},rwe=({resource:e,chart:t,title:n,noun:r,filter:i})=>{let[a,o]=(0,I.useState)(t.granularity===`week`?`week`:`day`),s=a===`week`?`90d`:t.range,c=AT(e,{field:t.field,range:s,granularity:a,filter:i,timeZone:Ef()}).data?.points.map(e=>({at:Date.parse(`${e.bucket}Z`),count:e.count}))??[];return(0,R.jsx)(twe,{title:n,noun:r,data:c,granularity:a,onGranularityChange:o,periodLabel:a===`week`?`last 12 weeks`:nwe[s]})},q7=(e,t,n)=>{let r=e.sum??e.average;if(r===void 0)return n;let i=t?.fields[r]?.label??K(r);return e.sum===void 0?W(`average`,i):`${i}`},iwe=({model:e,view:t,chart:n,plural:r,filter:i})=>{let a=t?.fields[n.groupBy]?.label??K(n.groupBy);return(0,R.jsxs)(`section`,{className:`rounded-lg border bg-background px-4 pb-3 pt-3`,"aria-label":`${q7(n,t,r)} by ${a.toLowerCase()}`,children:[(0,R.jsxs)(`h2`,{className:`mb-2 font-semibold`,children:[q7(n,t,r),` by `,a.toLowerCase()]}),(0,R.jsx)(V0,{model:e,view:t,groupBy:n.groupBy,type:n.type,sum:n.sum,average:n.average,limit:n.limit,filter:i})]})},awe=({value:e,onCommit:t,placeholder:n,className:r})=>{let[i,a]=(0,I.useState)(e);return(0,I.useEffect)(()=>a(e),[e]),(0,I.useEffect)(()=>{if(i===e)return;let n=setTimeout(()=>t(i),350);return()=>clearTimeout(n)},[i,e,t]),(0,R.jsx)(Rd,{wrapperClassName:g(`min-w-0 flex-1 sm:w-72 sm:flex-initial`,r),leading:(0,R.jsx)(vo,{className:`size-4`}),placeholder:n,"aria-label":V7(`search`),value:i,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&t(i)})},J7=e=>new Set((e.userMenu?.items??[]).flatMap(e=>e.kind===`resource`?[e.resource]:e.kind===`page`?[e.page]:[])),owe=(e,t,n)=>(e.userMenu?.items??[]).map((r,i)=>{if(r.kind===`link`)return{id:`link-${i}`,label:r.label,icon:Dw(r.icon,Zi),href:r.href,external:!0};if(r.kind===`page`){let i=e.pages[r.page];return{id:r.page,label:r.label??i?.title??K(r.page),icon:Dw(r.icon??i?.icon,ga),href:ws({kind:`page`,page:r.page},t),active:r.page===n}}return{id:r.resource,label:r.label??e.views[r.resource]?.names?.plural??K(r.resource),icon:Dw(r.icon,Tw(r.resource)),href:ws({kind:`list`,resource:r.resource},t),active:r.resource===n}}),Y7=(e,t)=>t===void 0?e:`${e}/${t}`,X7={sales:`sales`,crm:`crm`,catalog:`catalog`,inventory:`inventory`,core:`admin`,hr:`hr`},Z7=(e,t=``,n={})=>{let r=new Map,i=new Map,a=J7(e);for(let n of Object.values(e.pages)){if(n.nav?.hidden||a.has(n.name))continue;let e=n.nav?.group??W(`pages`),o=r.get(e)??{label:e,items:[]};o.items.push({id:n.name,label:n.title,icon:Dw(n.icon,ga),href:ws({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??(X7[c]?W(X7[c]):K(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:Y7(o.name),label:s.names?.plural??K(o.name),icon:Tw(o.name),href:ws({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:Y7(o.name,e.name),label:e.names.plural,icon:Tw(o.name),href:ws({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??W(`account`),o=r.get(e)??{label:e,items:[]};o.items.push({id:n.resource,label:n.names?.plural??K(n.resource),icon:Tw(n.resource),href:ws({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:K(r),icon:Tw(r),href:ws({kind:`list`,resource:r},t),problem:W(`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))}))},swe=(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 Tx(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??K(n.name);return[{id:n.name,header:c,kind:`text`,width:160,minWidth:zb(c,!1),sortable:!1,render:e=>(0,R.jsx)(C6,{column:n,records:e[n.name]??[],target:s,view:i[s.name],Card:k6})}]})},cwe=({model:e,view:t,target:n,children:r})=>{let i=h6(e.name,t.listOf,!0),a=t.names?.plural??K(e.name),o=e=>(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[(0,R.jsx)(Jd,{title:a,subtitle:t.help}),e]});if(i.error)return o((0,R.jsx)(US,{title:g6(`couldNotLoadYour`,a.toLowerCase()),error:i.error}));if(!i.data)return o((0,R.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-3`,children:Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-24`},t))}));let s=p6(n,i.data);return s?r(s):o((0,R.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:g6(`noneYet`,a.toLowerCase())}))},Q7=({title:e,chips:t,label:n,required:r,initial:i=``,busy:a,onSave:o,onClose:s})=>{let c=(0,I.useId)(),[l,u]=(0,I.useState)(i),d=`${c}-form`;return(0,R.jsx)(Mw,{open:!0,title:e,onClose:s,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:s,children:Q(`cancel`)}),(0,R.jsx)(V,{type:`submit`,form:d,variant:`primary`,loading:a,children:Q(`save`)})]}),children:(0,R.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,R.jsx)(h3,{chips:t}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:c,className:`font-medium`,children:n}),!r&&(0,R.jsx)(`span`,{id:`${c}-hint`,className:`text-xs text-muted-foreground`,children:Q(`optional`)})]}),(0,R.jsx)(Rd,{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)})]})]})})},$7=Un(),lwe={start:0,end:0},e9=(e,t)=>$7.and(t,{kind:`present`,field:e.field,span:lwe}),t9=e=>{switch(e.kind){case`and`:case`or`:return{...e,args:e.args.map(t9)};case`not`:return n9(e.arg);case`search`:case`present`:case`isNull`:return e;default:return e9(e,e)}},n9=e=>{switch(e.kind){case`and`:return $7.or(...e.args.map(n9));case`or`:return $7.and(...e.args.map(n9));case`not`:return t9(e.arg);case`search`:case`present`:case`isNull`:return $7.not(e);default:return e9(e,$7.not(e))}},r9=e=>{let t=Yt(e);if(!t.ok)throw Error(`The filter cannot be read: ${t.errors.map(e=>e.message).join(`; `)}`);return t.ast},i9=(e,t)=>{let n=r9(e);if(!n)return null;let r=r9(t),i=$7.not(t9(n));return Fn(r?$7.and(r,i):i)},uwe=(e,t)=>i9(t,e),a9=e=>e.key.startsWith(`extra:`)?`extra:${e.label}`:e.key,dwe=(e,t)=>{let n=new Map(e.map(e=>[a9(e),e])),r=new Map(t.map(e=>[a9(e),e])),i=e.filter(e=>!r.has(a9(e))).map(e=>({kind:`removed`,label:e.label})),a=t.flatMap(e=>{let t=n.get(a9(e));return t&&t.label!==e.label?[{kind:`changed`,label:e.label,before:t.label}]:[]}),o=t.filter(e=>!n.has(a9(e))).map(e=>({kind:`added`,label:e.label}));return[...i,...a,...o]},fwe=(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)},o9=12,s9={added:{word:`added`,className:`text-success-text`},removed:{word:`removed`,className:`text-danger-text`},changed:{word:`changed`,className:`text-primary-text`}},pwe=({changes:e})=>(0,R.jsx)(`ul`,{"aria-label":Q(`filterChanges`),className:`divide-y rounded-md border`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`grid grid-cols-[72px_1fr] gap-3 px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`font-medium ${s9[e.kind].className}`,children:Q(s9[e.kind].word)}),e.kind===`changed`?(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,R.jsx)(`span`,{className:`font-medium`,children:e.label})]}):(0,R.jsx)(`span`,{className:e.kind===`removed`?`text-muted-foreground line-through`:`font-medium`,children:e.label})]},`${e.kind}:${e.label}`))}),c9=(e,t)=>{let n=Ah({...pT(U(),e,t??``),enabled:t!==null});return t===null?0:n.data},mwe=(e,t,n)=>`${e} ${e===1?t:n}`,l9=({model:e,view:t,title:n,filter:r,total:i,plural:a})=>{let o=t?.list?.displays?.find(e=>e.kind===`cards`);return(0,R.jsxs)(`section`,{"aria-label":n,className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h3`,{className:`font-semibold`,children:[n,` `,(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,i??`…`,`)`]})]}),i!==void 0&&i>o9&&(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Q(`firstOf`,o9,i)}),r===null||i===0?(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Q(`noPlural`,a)}):(0,R.jsx)(b5,{model:e,view:t,filter:r,sort:iS(e,t),limit:o9,display:o?.name??`table`,row:!0,link:!1,empty:`No ${a}.`})]})},hwe=({model:e,view:t,title:n,before:r,after:i,saveNewLabel:a,updating:o,creating:s,onUpdate:c,onSaveNew:l,onCancel:u})=>{let d=dwe(a6(e,r),a6(e,i)),f=(0,I.useMemo)(()=>i9(r,i),[r,i]),p=(0,I.useMemo)(()=>uwe(r,i),[r,i]),m=c9(e,f),h=c9(e,p),g=(t?.names?.singular??K(e.name)).toLowerCase(),_=(t?.names?.plural??K(e.name)).toLowerCase(),v=m!==void 0&&h!==void 0;return(0,R.jsx)(Mw,{open:!0,wide:!0,title:n,onClose:u,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:u,children:Q(`cancel`)}),(0,R.jsx)(V,{loading:s,disabled:o,onClick:l,children:a}),(0,R.jsx)(V,{variant:`primary`,loading:o,disabled:s,onClick:c,children:Q(`update`)})]}),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d.length>0&&(0,R.jsx)(pwe,{changes:d}),v?(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`font-semibold`,children:fwe(m,h,g,_)}),(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`: `,Q(`addedRemoved`,mwe(m,g,_),h)]})]}):(0,R.jsx)(Uu,{className:`h-4 w-48`}),(0,R.jsx)(l9,{model:e,view:t,title:Q(`added`),filter:f,total:m,plural:_}),(0,R.jsx)(l9,{model:e,view:t,title:Q(`removed`),filter:p,total:h,plural:_})]})})},gwe=()=>{let{address:e,set:t}=gS();return{key:e?.kind===`list`?e.savedSearch:void 0,open:e=>t({savedSearch:e})}},u9=e=>e instanceof Error?e.message:Q(`somethingWrong`),_we=(e,t)=>{let n=J(),r=U(),i=ub(),a=_T(),{href:o,open:s}=gS(),c=gwe(),{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&&eT(f,`create`)&&eT(f,`delete`),m=n.signIn?.[l]?.signIn,h=R6(l,p),g=e=>ur(px(u,e)),_=d&&h.data?.find(e=>e[d.filter]===t),v=_||c.key===void 0||!f||!eT(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=jh({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:u9(e)}),onSettled:()=>a(l)}),C=jh({mutationFn:e=>r.remove(l,g(e)),onError:e=>i.show({state:`error`,title:Q(`couldNotTakeOff`),description:u9(e)}),onSettled:()=>a(l)}),w=jh({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:u9(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??K(l)).toLowerCase(),naming:x&&{label:n.views[l]?.fields[x.name]?.label??K(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)}},vwe=({model:e,view:t,search:n,filter:r,chips:i,className:a})=>{let o=_we(n,r),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)();if(!o.mode)return null;let p=n.label??Q(`saveSearch`);if(o.mode===`sign-in`)return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(V,{className:a,"aria-haspopup":`dialog`,onClick:()=>c(!0),children:[(0,R.jsx)(fi,{className:`size-3.5`,"aria-hidden":!0}),p]}),(0,R.jsx)(d6,{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,R.jsx)(Q7,{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,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(V,{className:a,"aria-haspopup":`dialog`,"aria-disabled":!o.ready,onClick:()=>o.ready&&u(!0),children:[(0,R.jsx)(fo,{className:`size-3.5`,"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`max-w-60 truncate`,children:Q(`updateName`,g.name??o.noun)})]}),(0,R.jsxs)(V,{className:a,"aria-haspopup":o.naming?`dialog`:void 0,"aria-disabled":!o.ready,onClick:()=>o.ready&&m(n),children:[(0,R.jsx)(ui,{className:`size-3.5`,"aria-hidden":!0}),n]}),l&&(0,R.jsx)(hwe,{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?ci:fi;return(0,R.jsxs)(R.Fragment,{children:[(0,R.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,R.jsx)(_,{className:o.saved?`size-3.5 text-primary`:`size-3.5`,"aria-hidden":!0}),p]}),h]})},ywe=e=>e instanceof Error?e.message:Q(`somethingWrong`),bwe=({model:e,view:t,name:n,value:r,onChange:i})=>{let a=(0,I.useId)(),o=e.fields[n],s=t.fields[n],c=s?.label??K(n);if(o?.type===`boolean`)return(0,R.jsx)(WS,{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,R.jsxs)(`label`,{htmlFor:a,className:`flex items-center gap-2 text-muted-foreground`,children:[c,(0,R.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,R.jsx)(`option`,{value:e,children:_s(e,s?.valueLabels)},e))})]})},xwe=(e,t,n)=>Object.entries(n).map(([n,r])=>`${t.fields[n]?.label??K(n)}: ${e.fields[n]?.type===`boolean`?Q(r===!0?`on`:`off`):_s(String(r),t.fields[n]?.valueLabels)}`).join(`, `),Swe=({model:e,view:t,recordKey:n,title:r,row:i,fields:a})=>{let o=U(),s=ub(),c=_T(),l=jh({mutationFn:t=>o.update(e.name,n,t,i.etag??`*`),onSuccess:(n,i)=>s.show({state:`success`,title:Q(`saved`,r),description:xwe(e,t,i)}),onError:e=>s.show({state:`error`,title:Q(`couldNotChange`),description:ywe(e)}),onSettled:()=>c(e.name)});return(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:a.map(n=>(0,R.jsx)(bwe,{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))})},Cwe=e=>e instanceof Error?e.message:Q(`somethingWrong`),wwe=({model:e,view:t,of:n,target:r,targetView:i,row:a,recordKey:o,canRename:s,onDelete:c})=>{let l=U(),u=ub(),d=_T(),[f,p]=(0,I.useState)(!1),{name:m,chips:h,title:g,body:_}=z6({model:e,of:n,target:r,targetView:i,row:a,recordKey:o}),v=jh({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:Cwe(e)}),onSettled:()=>d(e.name)}),y=n.name===void 0?void 0:e.fields[n.name];return(0,R.jsxs)(`section`,{"aria-label":g,className:`flex flex-col gap-3 rounded-lg border bg-surface p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:(0,R.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:(0,R.jsx)(_S,{to:{kind:`record`,resource:e.name,key:o},className:`hover:underline`,children:m??(0,R.jsx)(g3,{chips:h})})})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n.controls&&(0,R.jsx)(Swe,{model:e,view:t,recordKey:o,title:g,row:a,fields:n.controls}),s&&y&&(0,R.jsx)(V,{variant:`ghost`,"aria-label":Q(`renameTitle`,g),"aria-haspopup":`dialog`,onClick:()=>p(!0),children:(0,R.jsx)(Qa,{className:`size-3.5`,"aria-hidden":!0})}),c&&(0,R.jsx)(V,{variant:`ghost`,"aria-label":Q(`deleteTitle`,g),onClick:()=>c(g),children:(0,R.jsx)(Xo,{className:`size-3.5`,"aria-hidden":!0})})]})]}),f&&y&&(0,R.jsx)(Q7,{title:Q(`renameTitle`,g),chips:h,label:t.fields[y.name]?.label??K(y.name),required:!y.nullable,initial:m,busy:v.isPending,onSave:e=>v.mutate(e),onClose:()=>p(!1)}),(0,R.jsx)(L6,{..._})]})},Twe=({model:e,view:t})=>{let{resources:n,views:r}=J(),i=t.searchesOf,a=n[i.resource],o=r[i.resource],s=R6(e.name,!0),c=hS(e.name),l=B5({model:e,view:t}),u=t.names?.plural??K(e.name),d=e=>(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[l.dialogs,(0,R.jsx)(Jd,{title:u,subtitle:t.help}),e]});if(!a)return d((0,R.jsx)(mS,{title:Q(`notFound`),children:Xh(Q(`noResource`),i.resource)}));if(s.error)return d((0,R.jsx)(US,{title:Q(`couldNotLoadYour`,u.toLowerCase()),error:s.error}));if(!s.data)return d((0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:2},(e,t)=>(0,R.jsx)(Uu,{className:`h-56`},t))}));if(s.data.length===0){let e=(o?.names?.plural??K(a.name)).toLowerCase();return d((0,R.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:Xh(Q(`noSavedYet`,u.toLowerCase()),(0,R.jsx)(_S,{to:{kind:`list`,resource:a.name},className:`font-medium text-primary-text hover:underline`,children:e}))}))}return d((0,R.jsx)(`div`,{className:`flex flex-col gap-4`,children:s.data.map(n=>{let r=ur(px(e,n)),s=eT(c,`delete`)?e=>void l.start({key:r,title:e,etag:n.etag,snapshot:n}):void 0;return(0,R.jsx)(wwe,{model:e,view:t,of:i,target:a,targetView:o,row:n,recordKey:r,canRename:eT(c,`update`),onDelete:s},r)})}))},Ewe=({field:e,hints:t,resource:n,stored:r,onSave:i,close:a})=>{let[o,s]=(0,I.useState)(()=>AS(e,r)),c=(0,I.useRef)(null),l=(0,I.useRef)(!1),u=!t?.widget&&(e.type===`boolean`||e.type===`enum`);(0,I.useEffect)(()=>{c.current?.querySelector(`input, select, textarea, button, [tabindex]`)?.focus()},[]);let d=(t,n,s=o)=>{l.current||(l.current=!0,t&&jS(e,s,r)&&i(OS(e,s)),a(n))};return(0,R.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,R.jsx)(cC,{field:e,hints:t,value:o,stored:r,resource:n,onChange:e=>{s(e),u&&d(!0,void 0,e)}})})},Dwe=a({en:{changedBySomeoneElse:`Changed by someone else`,couldNotSave:`Could not save`},nl:{changedBySomeoneElse:`Gewijzigd door iemand anders`,couldNotSave:`Kon niet bewaren`}}),Owe=e=>{let t=U(),n=Om(),r=ub(),[i,a]=(0,I.useState)(new Map),o=(0,I.useRef)(i),s=(0,I.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=px(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(H.record(e.name,ur(l)),r),n.invalidateQueries({queryKey:[`page`,e.name]}),n.invalidateQueries({queryKey:[`list`,e.name]}),n.invalidateQueries({queryKey:[`map`,e.name]})}catch(n){if(!Ys(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:Dwe(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}}},kwe=(e,t,n)=>{let r=Owe(e),i=t?.list?.editable??[];return{editor:i.length>0&&eT(n,`update`)?{editable:(t,n)=>i.includes(n)&&e.fields[n]!==void 0&&ES(e.fields[n])&&tT(t,`update`),render:(n,i,a)=>(0,R.jsx)(Ewe,{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}},d9=(e,t)=>({model:e,record:Object.fromEntries(Object.entries(rS(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}}),Awe=e=>{let{views:t}=J(),n=yT(e.name,void 0),{go:r,href:i}=gS(),[a,o]=(0,I.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=>uT(t,d9(e,n).record),o={label:e=>a(e)?.label??t.label,destructive:Jw(t)},s=t.run;if(s?.kind===`link`){let n=n=>a(n)!==void 0&&rT(t,d9(e,n).record);if(`to`in s){let t=t=>Jn(s.to,d9(e,t).record);return{...o,available:n,link:e=>({href:i(t(e)),onFollow:()=>r(t(e))})}}let c=t=>oT(s.href,d9(e,t).record)??``;return{...o,available:n,link:e=>({href:c(e),onFollow:()=>sT(c(e))})}}return{...o,available:e=>a(e)!==void 0,blocked:r=>n.blockedOn(t,d9(e,r)),onSelect:n=>l({action:t,row:d9(e,n)})}}),bulkActions:s.filter(e=>e.bulk&&e.run?.kind!==`link`).map(t=>({label:e=>V7(`actionCount`,t.label,e),destructive:Jw(t),available:r=>n.appliesOn(t,d9(e,r)),onRun:(n,r)=>l({action:t,selection:n.map(t=>d9(e,t)),skipped:r})})),prompt:a&&(0,R.jsx)(qw,{action:a.action,label:a.action.label,danger:Jw(a.action),onCancel:()=>o(void 0),onConfirm:()=>{o(void 0),c(a)}})}},jwe=(e,t,n)=>({order:r,index:i})=>{let a=t=>r.findIndex(n=>ur(px(e,n))===t),o=t.after.find(e=>a(e.key)>i);if(o)return s8(`dependsOn`,n,o.title);let s=t.before.find(e=>a(e.key)!==-1&&a(e.key)<i);return s?s8(`dependsOn`,s.title,n):void 0},Mwe=(e,t,n,r)=>{let i=e[t],a;for(let o=n;o<e.length;o++){let n=r({record:i,order:yy(e,t,o),index:o});if(n===void 0)return{to:o,...a!==void 0&&{reason:a}};a??=n}return{to:t,reason:a}},Nwe=({model:e,view:t,field:n,filter:r,fields:i,rule:a})=>{let o=U(),s=ub(),c=_T(),{resources:l,views:u}=J(),d=`${n} asc`,f=Ah({queryKey:[...H.list(e.name,r,d,500,`hand-order`),i.join(`,`)],queryFn:async()=>{let t=W0(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(...G0(l,e,i,s.items,s.labels).map((t,n)=>({...t,id:fx(e,s.items[n])}))),a=s.nextPageToken}while(a);return n}}),[p,m]=(0,I.useState)(),h=(0,I.useRef)(void 0),g=(0,I.useRef)(void 0),_=(0,I.useRef)(Promise.resolve()),v=(0,I.useRef)(0),y=(0,I.useRef)(void 0),b=async()=>{let t=h.current,r=g.current;if(g.current=void 0,!t||!r)return;let i=i8(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`?[[ur(px(e,t)),t.etag]]:[])),l=(await o.batchWrite([{op:`reorder`,resource:e.name,field:n,keys:a.map(t=>px(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=$6(e,l.records.map(t=>({...t,before:u.get(fx(e,t.record))??{}})),[n]);if(y.current!==void 0&&s.dismiss(y.current),y.current=s.show({state:`success`,title:Q6(`orderChanged`),action:{label:Q6(`undo`),onClick:()=>E(d)}}),!h.current)return;let f=new Map(l.records.map(t=>[fx(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:Rx(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=rS(e,i[n]).record,c=i[n].id;n8(o,e,t,s).then(n=>{let i=h.current??f.data,o=jwe(e,n,ux(e,t,s,c));w(i,i.findIndex(e=>e.id===c),r,e=>o(e)??a?.(e))},x(Q6(`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=yy(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(Q6(`couldNotChange`))).then(S)},T=(t,n,r,i)=>{let a=Mwe(t.map(t=>rS(e,t).record),n,r,i);return a.reason!==void 0&&s.show({state:`warning`,title:a.to===n?Q6(`notMoved`):Q6(`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(Q6(`couldNotUndo`))).then(S)};return{rows:p??f.data,loading:f.isPending,error:f.error,move:C}},f9=({model:e,view:t,field:n,filter:r,columns:i,sort:a})=>{let{resources:o,views:s}=J(),{fields:c,dropRules:l}=tC(),{go:u,href:d}=gS(),f=a!==void 0,p=(0,I.useMemo)(()=>p5(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,I.useMemo)(()=>nS(e,t,p.map(e=>e.id)),[e,t,p]),h=t?.list?.drag?.rule,g=h===void 0?void 0:l?.[h],_=Nwe({model:e,view:t,field:n,filter:r,fields:m,...g&&{rule:g}}),v=_.rows,y=(0,I.useMemo)(()=>v&&{total:v.length,rowAt:e=>v[e]},[v]);if(h!==void 0&&!g)return(0,R.jsx)(gg,{children:Xh(Q6(`noRule`),h)});if(_.loading)return(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-4 w-full`},t))});if(_.error)return(0,R.jsx)(US,{title:Q6(`couldNotLoad`),error:_.error});if(!y||y.total===0)return(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:Q6(`nothingYet`)});let b=t=>u({kind:`record`,resource:e.name,key:px(e,t)});return(0,R.jsx)(o3,{fit:!0,scroll:`parent`,columns:p,source:y,latencyMs:0,onOpenRow:b,rowLink:t=>({href:d({kind:`record`,resource:e.name,key:px(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}})},p9=({sorting:e,onChange:t,size:n,iconOnly:r=!1})=>{let i=Q6(e?`done`:`reorder`);return(0,R.jsxs)(V,{size:n,variant:e?`primary`:`secondary`,onClick:()=>t(!e),...r&&{"aria-label":i,title:i},children:[e?(0,R.jsx)(Ci,{className:`size-3.5`}):(0,R.jsx)(Kr,{className:`size-3.5`}),!r&&i]})},Pwe=Un(),Fwe=e=>e.find(e=>e.kind===`search`),Iwe=({address:e})=>{let{resources:t,views:n,signIn:r}=J(),i=t[e.resource],a=r?.[e.resource];if(!i)return a?(0,R.jsx)(d6,{as:`page`,prompt:a.signIn}):(0,R.jsx)(mS,{title:W(`notFound`),children:W(`noResource`,e.resource)});let o=nr(n[e.resource],e.list);if(e.list!==void 0&&!o)return(0,R.jsx)(mS,{title:W(`notFound`),children:V7(`noList`,e.list)});if(o?.searchesOf)return(0,R.jsx)(Twe,{model:i,view:o});let s=sS(t,n,e.resource,e.list);if(o&&s.listOf){let t=s.model;return(0,R.jsx)(cwe,{model:i,view:o,target:t,children:n=>(0,R.jsx)(m9,{model:t,address:e,scope:n,heading:{title:o.names?.plural??K(i.name),subtitle:o.help}})})}return(0,R.jsx)(m9,{model:i,address:e})},m9=({model:e,address:t,scope:n,heading:r})=>{let i=J(),{set:a,listTo:o,go:s,href:c}=gS(),l=e.name,u=nr(i.views[l],t.list),d=(0,I.useMemo)(()=>e6(u,e),[u,e]),{fields:f}=tC(),p=(0,I.useMemo)(()=>swe(d5(Ex(e,u),e,u,f),e,u,i.resources,i.views),[e,u,f,i.resources,i.views]),m=t.filter,h=(0,I.useMemo)(()=>Z3(d,m),[d,m]),g=h.ok?h.state:x3,_=h.ok?h.extras:[],{orderBy:v,filterLayout:y}=t,b=Eu(),x=Du(),[S,C]=(0,I.useState)(!1),w=n?[..._,n]:_,T=aSe({model:e,resources:i.resources,views:i.views,view:u,state:g,extras:w}),E=n?K3(d,g,w):h.ok?m:``,D=(0,I.useMemo)(()=>nS(e,u,p.map(e=>e.id)),[e,u,p]),O=(0,I.useMemo)(()=>zye(u,i.resources,i.views,D),[u,i.resources,i.views,D]),k=d3({resources:i.resources,views:i.views,model:e,columns:D,filter:E,orderBy:v,related:O}),A=Gx(e,u,t.display),j=hS(l),M=n?void 0:U6(e,j),[N,ee]=(0,I.useState)(!1),te=N&&M!==void 0,ne=!A&&!te&&_be(u,M,v,E),re=te||A?.kind!==`map`;zu(re);let ie=J6(e,k.page,k.key,A?.kind===`custom`),ae=QCe(),oe=lx(e,u),se=e=>({key:e.id,title:String(typeof e[oe]==`object`?e[oe].name:e[oe]??e.id),etag:typeof e.etag==`string`?e.etag:void 0,snapshot:e}),ce=u?.names?.singular??K(l),le=kwe(e,u,j),{state:ue}=B(),de=B5({model:e,view:u,restore:V5(e),onReview:e=>s({kind:`record`,resource:l,key:e.key})}),P=Awe(e),fe=u?.actions.some(e=>e.run?.kind===`delete`)??!1,pe=(e,t=_)=>a({filter:K3(d,e,t)}),me=Fwe(_),he=e=>{let t=_.filter(e=>e.kind!==`search`);pe(g,e?[...t,Pwe.search(e)]:t)},F=u?.names?.plural??K(l),ge=A?.kind===`calendar`||A?.kind===`timeline`||A?.kind===`board`&&Fx(e)?void 0:A,_e=ge&&(0,R.jsx)(u5,{model:e,view:u,display:ge,orderBy:v,onChange:e=>a({orderBy:e})}),ve=e.search?.length?(0,R.jsx)(awe,{value:me?.kind===`search`?me.text:``,onCommit:he,placeholder:V7(`searchPlural`,F),className:b?void 0:`min-h-11`}):null,ye=(0,R.jsx)(R3,{layout:y,config:T,value:g,onChange:pe,leading:y===`bar`?_e:void 0,trailing:ve}),be=y===`bar`?ye:(0,R.jsx)(L3,{groups:[_e?[_e]:[]],trailing:ve}),xe=E3(T,g),Se=(0,R.jsx)(v3,{scroll:!0,chips:xe,onRemove:e=>pe(D3(g,e)),onClear:()=>pe(x3)}),Ce=ge&&(0,R.jsx)(A3,{title:V7(`sort`),children:(0,R.jsx)(u5,{model:e,view:u,display:ge,orderBy:v,onChange:e=>a({orderBy:e}),className:`min-h-11 w-full`})}),we=(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(V,{className:`min-h-11`,onClick:()=>C(!0),"aria-haspopup":`dialog`,children:[(0,R.jsx)(Mo,{className:`size-3.5`}),xe.length>0?V7(`filtersCount`,xe.length):V7(`filters`)]}),ve??(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:Se})]}),ve&&Se,(0,R.jsx)(jw,{title:V7(`filters`),open:S,onClose:()=>C(!1),children:(0,R.jsx)(R3,{layout:`panel`,fullWidth:!0,config:T,value:g,onChange:pe,leading:Ce})})]}),Te=!n&&H5(u,i.pages,j)&&(0,R.jsxs)(_S,{to:{kind:`create`,resource:l},className:op({variant:`primary`}),children:[(0,R.jsx)(ro,{className:`size-3.5`}),V7(`newRecord`,ce)]}),Ee=u?.saveSearch&&!n&&h.ok&&m&&(0,R.jsx)(vwe,{model:e,view:u,search:u.saveSearch,filter:m,chips:i6(e,u,m,Eye(T))}),De=!n&&(0,R.jsx)(rCe,{model:e}),Oe=DCe({model:e,view:u,resources:i.resources,views:i.views,plural:F,filter:E,orderBy:v}),ke=j7(u)&&(0,R.jsxs)(V,{onClick:()=>Oe.open(),...!b&&{"aria-label":V7(`export`),title:V7(`export`)},children:[(0,R.jsx)(Gi,{className:`size-3.5`}),b&&V7(`export`)]}),Ae=M&&!ne&&(0,R.jsx)(p9,{sorting:te,onChange:ee,iconOnly:!b}),je=t=>!te&&(0,R.jsx)(l5,{view:u,choices:Yx(e,u,x),value:A?.name??`table`,onChange:e=>a({display:e}),menu:t}),Me=o6(e),Ne=t=>{Me(rS(e,t).record),s({kind:`record`,resource:l,key:px(e,t)})},Pe=k.source?(0,R.jsx)(o3,{columns:p,source:k.source,sort:aS(v),onSortChange:e=>a({orderBy:oS(e)}),onOpenRow:Ne,rowLink:t=>({href:c({kind:`record`,resource:l,key:px(e,t)}),onFollow:()=>Ne(t)}),cellEditor:le.editor,rowPatches:le.patches,initialScrollIndex:ae.initialIndex,onScrollIndex:ae.remember,rowActions:[{label:V7(`openRecord`,ce),onSelect:Ne},...P.rowActions,...eT(j,`delete`)&&!fe?[{label:V7(`delete`),destructive:!0,available:e=>tT(e,`delete`),onSelect:e=>void de.start(se(e))}]:[]],bulkActions:[...j7(u)&&F7(e)?[{label:e=>V7(`exportCount`,e),onRun:e=>Oe.open(e)}]:[],...P.bulkActions,...eT(j,`delete`)?[{label:e=>V7(`deleteCount`,e),destructive:!0,onRun:e=>de.startBulk(e.map(se))}]:[]],rowNumbers:!1,pinKey:ue.kind===`signed-in`?mve(ue.user.id,Y7(l,t.list)):void 0,scroll:`parent`,className:`flex-1`}):(0,R.jsx)(`div`,{className:`flex-1 rounded-lg border bg-surface`}),Fe={...k,initialIndex:ae.initialIndex,onScrollIndex:ae.remember},Ie=kCe({plural:F,search:me?.kind===`search`?me.text:``,filtered:xe.length>0,scoped:!!n||_.some(e=>e.kind!==`search`),canCreate:!!Te}),Le=(0,R.jsx)(OCe,{state:Ie,onClearSearch:()=>he(``),onClearFilters:()=>pe(x3),create:Te}),Re=te?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:V7(`dragToSort`)}),(0,R.jsx)(f9,{model:e,view:u,field:M,filter:``,columns:Tx(e,u)})]}):ne?(0,R.jsx)(f9,{model:e,view:u,field:M,filter:``,columns:Tx(e,u),sort:{value:aS(v),onChange:e=>a({orderBy:oS(e)})}}):A?A.kind===`cards`?(0,R.jsx)(WCe,{model:e,view:u,display:A,list:Fe,empty:Le},k.key.join(` `)):A.kind===`map`?(0,R.jsx)(s5,{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,R.jsx)(u8,{model:e,view:u,display:A,fields:D,filter:E,orderBy:v}):A.kind===`calendar`?(0,R.jsx)(P8,{model:e,view:u,display:A,fields:D,filter:E,at:t.calendar,linkTo:e=>o({calendar:e})}):A.kind===`timeline`?(0,R.jsx)(U8,{model:e,view:u,display:A,fields:D,filter:E,at:t.timeline,linkTo:e=>o({timeline:e})}):(0,R.jsx)(K8,{display:A,list:ie}):k.source?.total===0&&!k.error?Le:Pe;return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-5 py-4`,children:[de.dialogs,Oe.dialogs,P.prompt,(0,R.jsx)(Jd,{title:r?.title??F,subtitle:r?r.subtitle:u?.help,actions:(0,R.jsxs)(R.Fragment,{children:[je(!b),Ae,Ee,De,ke,Te]})}),!h.ok&&(0,R.jsx)(US,{title:V7(`unreadableFilter`),error:Error(h.errors.map(e=>e.message).join(`; `))}),k.error&&!A&&!te&&(0,R.jsx)(US,{title:V7(`couldNotLoadRows`),error:k.error}),u?.chart&&!te&&(lr(u.chart)?(0,R.jsx)(iwe,{model:e,view:u,chart:u.chart,plural:F,filter:E}):(0,R.jsx)(rwe,{resource:l,chart:u.chart,title:V7(`created`,F),noun:F.toLowerCase(),filter:E})),!te&&(b?be:we),b&&y===`panel`&&!te?(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,R.jsx)(`div`,{className:re?`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:ye}),Re]}):Re]})},h9=e=>e?.role===`owner`?[`owner`,`admin`,`member`]:[`admin`,`member`],Lwe=({member:e,current:t,onChanged:n})=>{let{session:r,organizations:i}=B(),a=t.organization.id,{busy:o,error:s,run:c}=dg(),l=i?.roles??[],u=e.id===t.memberId,d=h9(t),f=e.role===`owner`&&t.role!==`owner`,p=l.filter(e=>e.membership);return(0,R.jsx)(A5,{name:e.name,email:e.email,self:u,error:s,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`select`,{"aria-label":G(`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,R.jsx)(`option`,{value:e,children:sg(e)},e))}),!u&&(0,R.jsx)(V,{size:`sm`,variant:`danger`,loading:o,disabled:f,onClick:()=>void c(async()=>{await r.organizations.removeMember(a,e.id),n()}),children:G(`remove`)})]}),children:(0,R.jsx)(E5,{roles:p,selected:e.appRoles,grantable:ug(l,t),disabled:o,onChange:t=>void c(async()=>{await r.organizations.setAppRoles(e.id,t),n()})})})},Rwe=({current:e})=>{let{session:t}=B(),[n,r]=(0,I.useState)(),[i,a]=(0,I.useState)(),o=e?.organization?.id,s=(0,I.useCallback)(()=>{o&&t.organizations.members(o).then(r,e=>a(e instanceof Dc?ef(e):G(`couldNotReadMembers`)))},[t,o]);return(0,I.useEffect)(s,[s]),e?.organization?(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,R.jsx)(Jd,{title:G(`members`),subtitle:G(`whoWorks`,e.organization.name)}),(0,R.jsxs)(cp,{title:G(`members`),description:G(`membersDescription`),children:[(0,R.jsx)(lp,{message:i}),n?(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:n.map(t=>(0,R.jsx)(Lwe,{member:t,current:e,onChanged:s},`${t.id}/${t.role}/${t.appRoles.join()}`))}):!i&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,G(`loading`)]})]})]}):null},zwe=({current:e,onSent:t})=>{let{session:n,organizations:r}=B(),i=r?.roles??[],[a,o]=(0,I.useState)(`member`),[s,c]=(0,I.useState)([]);return(0,R.jsx)(w5,{title:G(`inviteSomeone`),description:G(`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,R.jsx)(`select`,{"aria-label":G(`organizationRole`),value:a,onChange:e=>o(e.target.value),className:`h-8 rounded-md border border-border-strong bg-background px-2`,children:h9(e).map(e=>(0,R.jsx)(`option`,{value:e,children:sg(e)},e))}),children:(0,R.jsx)(E5,{roles:i.filter(e=>e.membership),selected:s,grantable:ug(i,e),onChange:c})})},Bwe=({invitation:e,organizationId:t,onChanged:n})=>{let{session:r,organizations:i}=B(),a=e.appRoles.map(e=>cg(i?.roles??[],e));return(0,R.jsx)(T5,{email:e.email,gives:`${sg(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()}})},Vwe=({current:e})=>{let{session:t}=B(),[n,r]=(0,I.useState)([]),i=e?.organization?.id,a=(0,I.useCallback)(()=>{i&&t.organizations.invitations(i).then(e=>r(e.filter(e=>e.status===`pending`)),()=>r([]))},[t,i]);return(0,I.useEffect)(a,[a]),!e?.organization||!i?null:(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,R.jsx)(Jd,{title:G(`invitations`),subtitle:G(`peopleInvited`,e.organization.name)}),(0,R.jsx)(zwe,{current:e,onSent:a}),(0,R.jsx)(cp,{title:G(`notAcceptedYet`),description:n.length>0?G(`sendingAgain`):G(`nobodyWaiting`),children:n.length>0&&(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:n.map(e=>(0,R.jsx)(Bwe,{invitation:e,organizationId:i,onChanged:a},e.id))})})]})},Hwe=e=>{let{session:t}=B(),[n,r]=(0,I.useState)(),[i,a]=(0,I.useState)([]),[o,s]=(0,I.useState)(),[c,l]=(0,I.useState)(0),u=(0,I.useCallback)(()=>l(e=>e+1),[]);return(0,I.useEffect)(()=>{e&&Promise.all([t.organizations.current(),t.organizations.list()]).then(([e,t])=>{r(e),a(t)},e=>s(e instanceof Dc?ef(e):G(`couldNotReadOrganizations`)))},[e,t,c]),{current:n,organizations:i,...o&&{error:o},reload:u}},g9=e=>window.location.assign(`${e}/`),Uwe=({organization:e,editable:t,onSaved:n})=>{let{session:r}=B(),[i,a]=(0,I.useState)(e.name),[o,s]=(0,I.useState)(e.slug),{busy:c,error:l,run:u}=dg(),d=i.trim()!==e.name||o!==e.slug;return(0,R.jsxs)(cp,{title:G(`details`),description:G(t?`detailsEditable`:`detailsReadOnly`),children:[(0,R.jsx)(lp,{message:l}),(0,R.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,R.jsx)(Rd,{"aria-label":G(`name`),value:i,disabled:!t,onChange:e=>a(e.target.value),wrapperClassName:`flex-1`}),(0,R.jsx)(Rd,{"aria-label":G(`slug`),value:o,disabled:!t,onChange:e=>s(e.target.value),wrapperClassName:`sm:w-48`}),t&&(0,R.jsx)(V,{type:`submit`,variant:`primary`,loading:c,disabled:!d||!i.trim(),children:G(`save`)})]})]})},Wwe=({organization:e,memberId:t})=>{let{session:n}=B(),[r,i]=(0,I.useState)([]),[a,o]=(0,I.useState)(``),{busy:s,error:c,run:l}=dg();return(0,I.useEffect)(()=>{n.organizations.members(e.id).then(e=>i(e.filter(e=>e.id!==t)),()=>i([]))},[n,e.id,t]),(0,R.jsxs)(cp,{title:G(`handOver`),description:G(`handOverDescription`),children:[(0,R.jsx)(lp,{message:c}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,R.jsxs)(`select`,{"aria-label":G(`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,R.jsx)(`option`,{value:``,children:G(`chooseMember`)}),r.map(e=>(0,R.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.email,`)`]},e.id))]}),(0,R.jsx)(V,{loading:s,disabled:!a,onClick:()=>void l(async()=>{await n.organizations.transferOwnership(a),window.location.reload()}),children:G(`handOver`)})]})]})},Gwe=({organization:e,basePath:t})=>{let{session:n}=B(),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(``),{busy:s,error:c,run:l}=dg(),u=()=>l(async()=>{await n.organizations.remove(e.id),g9(t)});return(0,R.jsxs)(cp,{title:G(`deleteOrganization`),description:G(`deleteDescription`),children:[(0,R.jsx)(lp,{message:r?void 0:c}),(0,R.jsx)(V,{variant:`danger`,onClick:()=>i(!0),children:G(`deleteOrganization`)}),r&&(0,R.jsxs)(sp,{title:G(`deleteTitle`,e.name),description:G(`deleteConfirm`),onClose:()=>i(!1),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:()=>i(!1),children:G(`cancel`)}),(0,R.jsx)(V,{variant:`danger`,loading:s,disabled:a!==e.name,onClick:()=>void u(),children:G(`delete`)})]}),children:[(0,R.jsx)(lp,{message:c}),(0,R.jsx)(Rd,{"aria-label":G(`organizationName`),value:a,onChange:e=>o(e.target.value)})]})]})},Kwe=({organization:e,basePath:t,owner:n})=>{let{session:r}=B(),{busy:i,error:a,run:o}=dg();return(0,R.jsxs)(cp,{title:G(`leave`),description:G(n?`leaveOwner`:`leaveMember`),children:[(0,R.jsx)(lp,{message:a}),(0,R.jsx)(V,{loading:i,onClick:()=>void o(async()=>{await r.organizations.leave(e.id),g9(t)}),children:G(`leaveName`,e.name)})]})},qwe=({current:e,basePath:t,onChanged:n})=>{let r=e?.organization;if(!r)return(0,R.jsx)(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-6 md:px-6`,children:(0,R.jsx)(Jd,{title:G(`organization`),subtitle:G(`noOrganization`)})});let i=e.role===`owner`;return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,R.jsx)(Jd,{title:r.name,subtitle:e.role?G(`youAre`,sg(e.role).toLowerCase()):G(`throughGlobalRoles`)}),(0,R.jsx)(Uwe,{organization:r,editable:lg(e),onSaved:n},`${r.name}/${r.slug}`),i&&e.memberId&&(0,R.jsx)(Wwe,{organization:r,memberId:e.memberId}),e.role&&(0,R.jsx)(Kwe,{organization:r,basePath:t,owner:i}),i&&(0,R.jsx)(Gwe,{organization:r,basePath:t})]})},_9=({organization:e,current:t,busy:n,onOpen:r})=>(0,R.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,R.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.slug})]}),t?(0,R.jsx)(dd,{tone:`green`,children:G(`current`)}):(0,R.jsx)(V,{size:`sm`,loading:n,onClick:r,children:G(`open`)})]}),Jwe=({basePath:e,currentId:t})=>{let{session:n}=B(),[r,i]=(0,I.useState)(``),a=k5((0,I.useCallback)((e,t)=>n.organizations.search(e,t).then(e=>({items:e.organizations,total:e.total})),[n]),r),{busy:o,error:s,run:c}=dg();return(0,R.jsx)(O5,{title:G(`allOrganizations`),description:G(`allOrganizationsDescription`),searchLabel:G(`findOrganization`),placeholder:G(`nameOrSlug`),query:r,onQuery:i,list:a,error:s,renderRow:r=>(0,R.jsx)(_9,{organization:r,current:r.id===t,busy:o,onOpen:()=>void c(async()=>{await n.organizations.switchTo(r.id),g9(e)})},r.id)})},v9=e=>e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,63),Ywe=({basePath:e})=>{let{session:t}=B(),[n,r]=(0,I.useState)(``),[i,a]=(0,I.useState)(),{busy:o,error:s,run:c}=dg(),l=()=>c(async()=>{await t.organizations.create({name:n.trim(),slug:i??v9(n)}),g9(e)});return(0,R.jsxs)(cp,{title:G(`newOrganization`),description:G(`newOrganizationDescription`),children:[(0,R.jsx)(lp,{message:s}),(0,R.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,R.jsx)(Rd,{"aria-label":G(`name`),placeholder:G(`name`),value:n,onChange:e=>r(e.target.value),wrapperClassName:`flex-1`}),(0,R.jsx)(Rd,{"aria-label":G(`slug`),placeholder:`slug`,value:i??v9(n),onChange:e=>a(e.target.value),wrapperClassName:`sm:w-48`}),(0,R.jsx)(V,{type:`submit`,variant:`primary`,loading:o,disabled:!n.trim(),children:G(`create`)})]})]})},Xwe=()=>{let{session:e,organizations:t}=B(),[n,r]=(0,I.useState)([]);if((0,I.useEffect)(()=>{e.organizations.myInvitations().then(r,()=>r([]))},[e]),n.length===0)return null;let i=t?.roles??[];return(0,R.jsx)(cp,{title:G(`invitationsForYou`),description:G(`invitationsForYouDescription`),children:(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:n.map(e=>(0,R.jsxs)(`li`,{className:`px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.organizationName??G(`anOrganization`)}),`: `,e.appRoles.map(e=>cg(i,e)).join(`, `)||G(`noAppRoles`),(0,R.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:G(`until`,new Date(e.expiresAt).toLocaleDateString(l()))})]},e.id))})})},Zwe=({state:e,basePath:t})=>{let{session:n,organizations:r,state:i}=B(),{busy:a,error:o,run:s}=dg(),c=i.kind===`signed-in`?i.user:void 0,l=r?.create===`everyone`||c!==void 0&&Vg(c),u=e.current?.organization?.id;return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,R.jsx)(Jd,{title:G(`organizations`),subtitle:G(`organizationsSubtitle`)}),(0,R.jsxs)(cp,{title:G(`yourOrganizations`),description:e.organizations.length>0?G(`memberOf`):G(`notMember`),children:[(0,R.jsx)(lp,{message:o??e.error}),e.organizations.length>0&&(0,R.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.organizations.map(e=>(0,R.jsx)(_9,{organization:e,current:e.id===u,busy:a,onOpen:()=>void s(async()=>{await n.organizations.switchTo(e.id),g9(t)})},e.id))})]}),(0,R.jsx)(Xwe,{}),l&&(0,R.jsx)(Ywe,{basePath:t}),(e.current?.globalRoles.length??0)>0&&(0,R.jsx)(Jwe,{basePath:t,currentId:u})]})},Qwe=(e,t)=>t?.active?{...e,role:t.active}:e,y9=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`}}),b9=(e,t)=>e instanceof Dc?ef(e):t,$we=(e,t=!0)=>{let{session:n}=B(),r=ub(),[i,a]=(0,I.useState)();(0,I.useEffect)(()=>{t&&n.roles.current().then(a,e=>r.show({state:`error`,title:b9(e,y9(`couldNotReadRoles`))}))},[n,r,t]);let o=(0,I.useCallback)(t=>void n.roles.switchTo(t).then(e,e=>r.show({state:`error`,title:b9(e,y9(`couldNotSwitch`))})),[n,r,e]);return{...i&&{current:i},switchTo:o}},eTe=e=>{let t=tC().shell?.logo;return t?(0,R.jsx)(vg,{name:`shell.logo`,fallback:(0,R.jsx)($u,{...e}),children:(0,R.jsx)(t,{...e})}):(0,R.jsx)($u,{...e})},x9=(0,I.createContext)([]),tTe=()=>(0,I.useContext)(x9),nTe=({ui:e,children:t})=>{let{plugins:n=[]}=J(),{loads:r,settled:i}=Ig(n,Pg()),a=(0,I.useMemo)(()=>Tg(e,r),[e,r]);return i?(0,R.jsx)(eC.Provider,{value:a.ui,children:(0,R.jsx)(x9.Provider,{value:a.off,children:t})}):(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,Eg(`loading`)]})},rTe=({off:e})=>{let[t,n]=(0,I.useState)(!1);return t||e.length===0?null:(0,R.jsxs)(`div`,{role:`region`,"aria-label":Eg(`pluginsOff`),className:`flex items-start gap-3 border-b border-warning/40 bg-warning-soft px-4 py-2 text-warning-text`,children:[(0,R.jsx)(so,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,R.jsx)(`ul`,{className:`min-w-0 flex-1 space-y-0.5 break-words`,children:e.map(e=>(0,R.jsx)(`li`,{children:Xh(Eg(`pluginOff`),(0,R.jsx)(`span`,{className:`font-semibold`,children:e.name??e.url}),e.reason)},e.url))}),(0,R.jsx)(`button`,{type:`button`,"aria-label":Eg(`dismiss`),className:`rounded p-0.5 hover:bg-warning/10`,onClick:()=>n(!0),children:(0,R.jsx)(ds,{"aria-hidden":!0,className:`size-4`})})]})},S9=(e,t)=>[`${t}_at`,`${t}At`].find(t=>e.fields[t]),C9=({item:e,scope:t})=>{let{components:n}=tC(),r=n?.[e.component],i=r?(0,R.jsx)(Qw,{value:t,children:(0,R.jsx)(vg,{name:e.component,children:(0,R.jsx)(r,{...Zn(e.props??{})})})}):(0,R.jsx)(gg,{children:Xh(W(`noComponent`),e.component)});return e.sidebar?e.title?(0,R.jsx)(vb,{title:e.title,children:i}):i:e.title?(0,R.jsx)(mb,{title:e.title,children:i}):(0,R.jsx)(`section`,{className:`py-8`,children:i})},iTe=(0,I.lazy)(()=>m(()=>import(`./record-map-DFy7sJEU.js`).then(e=>({default:e.RecordMap})),__vite__mapDeps([10,1,6,2,7,8,3,4,9]))),aTe=15,w9=({item:e,record:t})=>{let n=J().maps,r=n?.style,i=Q8(t,e);if(!r||!i)return null;let a=(0,R.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted ${e.sidebar?`h-48`:`h-64 md:h-80`}`,children:(0,R.jsx)(I.Suspense,{fallback:null,children:(0,R.jsx)(iTe,{style:r,layers:n?.layers,position:i,zoom:e.zoom??aTe},`${i.latitude},${i.longitude}`)})});return e.sidebar?(0,R.jsx)(vb,{title:e.title,children:a}):(0,R.jsx)(mb,{title:e.title,children:a})},oTe={"1h":`minute`,"24h":`5_minutes`,"7d":`hour`},sTe=(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}))},T9=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.`}}),cTe=Un(),lTe=[`1h`,`24h`,`7d`],uTe={"1h":`hour`,"24h":`day`,"7d":`week`},dTe=({item:e,recordKey:t})=>{let{resources:n,views:r}=J(),[i,a]=(0,I.useState)(e.range??`1h`),[o,s]=(0,I.useState)(`average`),c=n[e.resource],l=r[e.resource],u=oTe[i],d=Fn(cTe.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:Ef()})),m=NT(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??K(e),color:`var(--chart-${t+1})`,measure:h[t]})),_=m.every(e=>e.data)?sTe(m.map(e=>e.data.groups),g.map(e=>e.key),o):[],v=(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(f,{label:T9(`measure`),value:o,onChange:s,options:[{value:`average`,label:T9(`average`)},{value:`maximum`,label:T9(`maximum`)}]}),(0,R.jsx)(f,{label:T9(`range`),value:i,onChange:a,options:lTe.map(e=>({value:e,label:T9(uTe[e])}))})]});return(0,R.jsx)(mb,{title:e.title,help:e.help,actions:v,children:m.some(e=>e.error)?(0,R.jsx)(`p`,{className:`text-danger-text`,children:T9(`couldNotLoad`)}):m.some(e=>e.isPending)?(0,R.jsx)(Uu,{className:`h-40 w-full`}):_.every(e=>e.count===0)?(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:T9(`noSamples`)}):(0,R.jsx)(z0,{points:_,measure:h[0],bucket:u,type:`line`,series:g,...g.length>1&&{resource:e.resource,view:l}})})},fTe=e=>c6(e)??pte,pTe=({model:e,stored:t,recordKey:n,edit:r,onDelete:i})=>{let{go:a}=gS(),o=Pd(),s={model:e,record:t.record,key:n,etag:t.etag,permissions:t.permissions},c=yT(e.name,s,t=>t.run?.kind===`delete`&&a({kind:`list`,resource:e.name},{replace:!0})),[l,u]=(0,I.useState)(),d=c.actions.map(e=>({name:e.label,icon:fTe(e.icon),blocked:c.blocked(e),running:c.running===e.name,...Jw(e)&&{tone:`danger`},onRun:()=>Yw(e)?u(e):void c.run(e)})),f=c.actions.some(e=>e.run?.kind===`delete`),p=[...r?[{name:F5(`edit`),icon:Qa,render:({className:e,children:t,role:n})=>(0,R.jsx)(_S,{to:r,role:n,className:e,children:t})}]:[],...d,...i&&!f?[{name:F5(`delete`),icon:Xo,tone:`danger`,onRun:i}]:[]];return p.length===0?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:o?`max-md:hidden`:void 0,children:(0,R.jsx)(gb,{actions:p})}),o&&(0,ps.createPortal)((0,R.jsx)(qae,{actions:p,label:F5(`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,R.jsx)(Xw,{action:l,label:l.label,danger:Jw(l),onCancel:()=>u(void 0),onConfirm:()=>{u(void 0),c.run(l)},onSubmit:async e=>{await c.submit(l,e),u(void 0)}})]})},mTe=(e=[],t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],hTe=(e,t=[],n)=>!e.collapsed||t.includes(e.title)||e.items.some(e=>e.kind===`section`&&e.fields.some(n)),gTe=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],E9=e=>tr(e.items).flatMap(e=>e.kind===`section`?e.fields:[]),vTe=(e,t,n)=>{if(t&&!E9(t).some(n))return e.find(e=>E9(e).some(n))},yTe=(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)),bTe=e=>({id:String(e.id),productId:String(e.productId??``),description:String(e.description??``),quantity:Number(e.quantity),unitPriceCents:Math.round(Number(e.unitPrice)*100)}),xTe=({lines:e,draft:t,vatRate:n,saving:r,locked:i=!1})=>{let a=eT(hS(e.name),`update`);return(0,R.jsx)(mb,{title:F5(`lines`),help:F5(`linesHelp`),children:(0,R.jsx)(`div`,{className:`-mx-4 overflow-x-auto px-4 [-webkit-overflow-scrolling:touch] md:mx-0 md:px-0`,children:(0,R.jsx)(`div`,{className:`min-w-[560px]`,children:(0,R.jsx)(tb,{lines:t.shown.map(bTe),onChange:()=>void 0,onReorder:e=>t.setOrder(e.map(e=>e.id)),vatRate:n,readOnly:!0,reorderable:a&&!r&&!i})})})})},STe=(e,t,n)=>`protobase:draft:${e}:${t}:${n}`,CTe=(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),wTe=(e,t,n)=>u(()=>n?e.setItem(t,JSON.stringify(n)):e.removeItem(t),void 0),TTe=(e,t)=>Number(e.position)-Number(t.position),ETe=(e,t,n)=>{let r=e&&Object.values(e.fields).find(e=>e.type===`relation`&&e.relation?.resource===t.name),i=qS(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(TTe),loading:i.isPending&&!!e}},DTe=(e,t)=>{let[n,r]=(0,I.useState)(),i=t.map(e=>String(e.id)),a=(0,I.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,I.useCallback)(()=>!e||!s?[]:[{op:`reorder`,resource:e.name,field:`position`,keys:a.map(t=>px(e,t)),etags:Object.fromEntries(a.flatMap(t=>typeof t.etag==`string`?[[ur(px(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}},OTe=e=>{let t=e>=5?5:e===4?3:e;return{shown:t,more:e-t}},kTe=(e,t)=>Math.abs(e)<40||Math.abs(e)<=Math.abs(t)?0:e<0?1:-1,ATe=e=>e===`ArrowRight`?1:e===`ArrowLeft`?-1:0,jTe=(e,t,n)=>Math.min(Math.max(e+t,0),Math.max(n-1,0)),MTe=e=>e.key===`i`&&!e.ctrlKey&&!e.metaKey&&!e.altKey,D9=`protobase:lightbox-details`,NTe=e=>u(()=>e.getItem(D9)===`true`,!1),PTe=(e,t)=>u(()=>t?e.setItem(D9,`true`):e.removeItem(D9),void 0),O9=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`}}),k9=`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`,FTe=({title:e,photos:t,index:n,onIndex:r,onClose:i,details:a,detailsTitle:o=O9(`details`)})=>{let s=(0,I.useRef)(null),c=(0,I.useRef)(void 0),l=(0,I.useId)(),u=Eu(),[d,f]=(0,I.useState)(()=>NTe(localStorage)),[p,m]=(0,I.useState)(!1);Iu(s,!0,i),(0,I.useEffect)(()=>m(!0),[]);let h=t.length,_=e=>{let t=jTe(n,e,h);t!==n&&r(t)},v=Mb(t[n],{width:1600,height:1200}),y=a?.(n),b=y!==void 0,x=e=>{f(e),PTe(localStorage,e)};return(0,R.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e,onKeyDown:e=>{if(b&&MTe(e))return e.preventDefault(),x(!d);let t=ATe(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,R.jsxs)(`div`,{className:`flex h-dvh shrink-0 flex-col md:sticky md:top-0 md:min-w-0 md:flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 p-3`,children:[(0,R.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,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,R.jsx)(`button`,{type:`button`,className:g(k9,`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,R.jsx)(tte,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(`button`,{type:`button`,className:k9,"aria-label":O9(`close`),onClick:i,children:(0,R.jsx)(ds,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,R.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&&=(_(kTe(e.clientX-c.current.x,e.clientY-c.current.y)),void 0)},onPointerCancel:()=>c.current=void 0,children:[v&&(0,R.jsx)(QS,{image:v,className:`max-h-full max-w-full select-none object-contain`},v.url),h>1&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:g(k9,`absolute left-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":O9(`previousPhoto`),"aria-disabled":n===0,onClick:()=>_(-1),children:(0,R.jsx)(Di,{className:`size-5`,"aria-hidden":!0})}),(0,R.jsx)(`button`,{type:`button`,className:g(k9,`absolute right-3 top-1/2 -translate-y-1/2 aria-disabled:cursor-default aria-disabled:opacity-40`),"aria-label":O9(`nextPhoto`),"aria-disabled":n===h-1,onClick:()=>_(1),children:(0,R.jsx)(ki,{className:`size-5`,"aria-hidden":!0})})]})]})]}),b&&d&&u&&(0,R.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,R.jsx)(`h2`,{className:`mb-3 text-[16px] font-semibold`,children:o}),y]}),(0,R.jsx)(jw,{title:o,open:b&&d&&!u&&p,onClose:()=>x(!1),children:(0,R.jsx)(`div`,{className:`pt-3`,children:y})})]})},ITe=(e,t,n)=>{let r=tr(t?.layout??[]).flatMap(e=>e.kind===`section`&&PS(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)&&PS(t?.fields[r]?.when,!1))},LTe=({model:e,view:t,photoKey:n,fields:r})=>{let i=Gg(e.name,n),a=(t?.names?.singular??K(e.name)).toLowerCase();if(i.isPending)return(0,R.jsx)(Uu,{className:`h-4 w-48`});if(i.error)return(0,R.jsx)(US,{title:O9(`couldNotLoadOne`,a),error:i.error});let o=r.filter(e=>nT(i.data.permissions,e)!==`hidden`);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(yS,{rows:o.map(n=>({label:t?.fields[n]?.label??K(n),value:(0,R.jsx)(J0,{model:e,field:e.fields[n],value:i.data.record[n]})}))}),(0,R.jsx)(_S,{to:{kind:`record`,resource:e.name,key:n},className:`mt-3 inline-block font-medium text-primary-text hover:underline`,children:O9(`open`,a)})]})},A9=e=>Mb(e,{width:0,height:0})!==void 0,RTe=(e,t)=>{let n=e.primaryKey.map(e=>t[e]);if(!n.some(e=>e==null))return ur(n)},zTe=(e,t,n,r)=>{let i=n===void 0?[]:t.flatMap(e=>{let t=e[n];if(!Sb(t)||!A9(t))return[];let i=r&&RTe(r,e);return[{file:t,...i!==void 0&&{key:i}}]});if(!Sb(e)||!A9(e))return i;let a=t=>Sb(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))]},BTe=Un(),VTe=(e,t,n)=>{let r=U(),{resources:i}=J(),a=e.photos?i[e.photos.resource]:void 0,o=e.photos?Fn(BTe.eq(e.photos.field,n)):``,s=e.photos?.sort??``,c=Ah({queryKey:H.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:zTe(e.image===void 0?void 0:t[e.image],c.data??[],e.photos?.image,a),isPending:a!==void 0&&c.isPending,error:c.error}},HTe={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`,``,``,``,``]},UTe=({photo:e,large:t})=>{let n=Mb(e,t?{width:960,height:720}:{width:480,height:360});return n?(0,R.jsx)(QS,{image:n,loading:`lazy`,className:`size-full object-cover transition-transform duration-300 group-hover/tile:scale-[1.02]`}):null},WTe=({item:e,record:t,recordKey:n})=>{let{views:r}=J(),i=VTe(e,t,n),a=hS(i.holder?.name??``),[o,s]=(0,I.useState)();if(i.isPending)return(0,R.jsx)(mb,{title:e.title,children:(0,R.jsx)(Uu,{className:`aspect-[4/3] w-full rounded-lg md:aspect-[2/1]`})});if(i.error)return(0,R.jsx)(mb,{title:e.title,children:(0,R.jsx)(US,{title:O9(`couldNotLoad`),error:i.error})});let c=i.items.length;if(c===0)return null;let{shown:l,more:u}=OTe(c),d=i.holder,f=d&&r[d.name],p=d?ITe(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,R.jsxs)(mb,{title:e.title,children:[(0,R.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,R.jsxs)(`button`,{type:`button`,"aria-label":n?O9(`showAll`,c):O9(`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`,HTe[l][t]),children:[(0,R.jsx)(UTe,{photo:e.file,large:t===0}),n&&(0,R.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,R.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,R.jsx)(ete,{className:`size-3.5`}),c]})]},t)})}),o!==void 0&&(0,R.jsx)(FTe,{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,R.jsx)(LTe,{model:d,view:f,photoKey:t,fields:p},t):void 0},detailsTitle:d&&O9(`holderDetails`,f?.names?.singular??K(d.name))})]})},j9=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`}}),GTe=e=>e.actor?e.actor.name??e.actor.id:e.databaseRole?j9(`databaseRole`,e.databaseRole):j9(`database`),KTe=(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??K(r);return i.sensitive||!e.before||!e.after?[{name:r,label:o}]:[{name:r,label:o,before:Ox(i,e.before[r],a),after:Ox(i,e.after[r],a)}]}),i=e.operation===`update`&&r.length===0?j9(`changedThis`):j9(e.operation);return{who:GTe(e),verb:i,fields:r}},qTe=1500,JTe=(e,t,n,r)=>{let i=U(),a=Mh({queryKey:H.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,I.useEffect)(()=>{let e=setTimeout(()=>void o(),qTe);return()=>clearTimeout(e)},[r,o]),{...a,items:a.data?.pages.flatMap(e=>e.items)??[]}},YTe=()=>(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-4 w-full`},t))}),XTe=({change:e,model:t,view:n})=>{let{who:r,verb:i,fields:a}=KTe(e,t,n),o=Date.parse(e.at);return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-3 first:pt-0 last:pb-0`,children:[(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),` `,(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:i}),` `,(0,R.jsxs)(`time`,{dateTime:e.at,title:Kf(o),className:`text-muted-foreground`,children:[`· `,rp(Math.max(0,Math.round((Date.now()-o)/1e3)))]})]}),a.length>0&&(0,R.jsx)(`dl`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1`,children:a.map(e=>(0,R.jsxs)(`div`,{className:`contents`,children:[(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,R.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.before===void 0?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`changed`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`del`,{className:`text-muted-foreground`,children:e.before}),` → `,(0,R.jsx)(`ins`,{className:`no-underline`,children:e.after})]})})]},e.name))})]})},ZTe=({item:e,model:t,view:n,recordKey:r,etag:i})=>{let a=JTe(t.name,r,e.limit??10,i);return(0,R.jsx)(mb,{title:e.title,children:a.isPending?(0,R.jsx)(YTe,{}):a.error?(0,R.jsx)(US,{title:`Could not load the history`,error:a.error}):a.items.length===0?(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`No changes kept yet.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ol`,{className:`divide-y divide-border`,children:a.items.map(e=>(0,R.jsx)(XTe,{change:e,model:t,view:n},e.id))}),a.hasNextPage&&(0,R.jsx)(V,{size:`sm`,className:`mt-4`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Show more`})]})})},QTe=(e,t)=>{let n=/(?:^|\s)@([^\s@]*)$/.exec(e.slice(0,t));return n?{start:t-n[1].length-1,query:n[1]}:void 0},$Te=(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(` `)}},eEe=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),M9=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(eEe).join(`|`)})(?![\\p{L}\\p{N}_])`,`gu`)},tEe=(e,t)=>{let n=M9(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))]},nEe=(e,t)=>{let n=M9(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},rEe=({comment:e})=>(0,R.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:nEe(e.body,e.mentions).map((e,t)=>`mention`in e?(0,R.jsxs)(`span`,{className:`font-medium text-primary`,children:[`@`,e.mention]},t):e.text)}),iEe=(e,t,n)=>{let r=U(),i=M3(n,150);return Ah({queryKey:H.mentionable(e,t,i??``),queryFn:()=>r.mentionable(e,t,i??``),enabled:i!==void 0,placeholderData:qm})},aEe=(e,t)=>{let n=U(),r=Om();return jh({mutationFn:r=>n.comment(e,t,r),onSuccess:()=>r.invalidateQueries({queryKey:H.comments(e,t)})})},N9=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.`}}),oEe=8,sEe=({resource:e,recordKey:t})=>{let[n,r]=(0,I.useState)(``),[i,a]=(0,I.useState)(0),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)([]),[u,d]=(0,I.useState)(0),[f,p]=(0,I.useState)(),m=(0,I.useRef)(null),h=(0,I.useRef)(void 0),_=(0,I.useId)(),v=ub(),y=aEe(e,t),b=QTe(n,i),x=o&&b!==void 0&&b.start!==f,S=iEe(e,t,x?b.query:void 0),C=x?(S.data??[]).slice(0,oEe):[],w=x&&S.data!==void 0,T=e=>`${_}-${e}`;(0,I.useEffect)(()=>d(0),[b?.query]);let E=b?.start;(0,I.useEffect)(()=>{E===void 0&&p(void 0)},[E]),(0,I.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=$Te(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:tEe(n,c)},{onSuccess:()=>{r(``),l([])},onError:e=>v.show({state:`error`,title:N9(`couldNotPost`),description:Rx(e)})})};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(KS,{ref:m,role:`combobox`,"aria-label":N9(`comment`),"aria-multiline":!0,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":_,"aria-activedescendant":w&&C[u]?T(u):void 0,placeholder:N9(`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=j3(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,R.jsxs)(`ul`,{id:_,role:`listbox`,"aria-label":N9(`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,R.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,R.jsx)(`li`,{className:`px-3 py-1.5 text-muted-foreground`,children:N9(`noOneFound`)})]})]}),(0,R.jsx)(`div`,{children:(0,R.jsx)(V,{variant:`primary`,size:`sm`,disabled:n.trim()===``,loading:y.isPending,onClick:O,children:N9(`comment`)})})]})},cEe=20,lEe=(e,t)=>{let n=U(),r=Mh({queryKey:H.comments(e,t),initialPageParam:``,queryFn:({pageParam:r})=>n.comments(e,t,{pageSize:cEe,pageToken:r}),getNextPageParam:e=>e.nextPageToken||void 0});return{...r,items:r.data?.pages.flatMap(e=>e.items).reverse()??[]}},uEe=()=>(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-4 w-full`},t))}),dEe=({comment:e})=>{let t=e.author.name??e.author.id,n=Date.parse(e.createdAt);return(0,R.jsxs)(`li`,{className:`flex gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,R.jsx)(nd,{initials:zg(t)||`?`,hue:Rg(e.author.id),size:`md`,className:`ring-0`}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),` `,(0,R.jsxs)(`time`,{dateTime:e.createdAt,title:Kf(n),className:`text-muted-foreground`,children:[`· `,rp(Math.max(0,Math.round((Date.now()-n)/1e3)))]})]}),(0,R.jsx)(rEe,{comment:e})]})]})},fEe=({item:e,resource:t,recordKey:n,canWrite:r})=>{let i=lEe(t,n);return(0,R.jsxs)(mb,{title:e.title,children:[i.isPending?(0,R.jsx)(uEe,{}):i.error?(0,R.jsx)(US,{title:N9(`couldNotLoad`),error:i.error}):(0,R.jsxs)(R.Fragment,{children:[i.hasNextPage&&(0,R.jsx)(V,{size:`sm`,className:`mb-4`,disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:N9(`showEarlier`)}),i.items.length===0?(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:N9(`noComments`)}):(0,R.jsx)(`ol`,{className:`divide-y divide-border`,children:i.items.map(e=>(0,R.jsx)(dEe,{comment:e},e.id))})]}),r&&(0,R.jsx)(`div`,{className:`mt-4`,children:(0,R.jsx)(sEe,{resource:t,recordKey:n})})]})},pEe=e=>e.kind===`group`||e.kind===`tab`?e.items:[],P9=e=>e.kind===`tab`?void 0:e.when,F9=e=>e.flatMap(e=>[e,...F9(pEe(e))]).filter(e=>gs(P9(e))),mEe=(e,t,n,r)=>{let i=0,a=e=>{let a=P9(e);return gs(a)?!r&&t[i++]===!0:PS(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)},hEe=(e,t,n,r)=>mEe(e,B6(r?[]:F9(e).map(e=>P9(e)),t),n,r),I9=(e,t)=>{let n=U(),r=Om(),i=ur(t);return jh({mutationFn:({patch:r,etag:i})=>n.update(e,t,r,i),onSuccess:t=>{r.setQueryData(H.record(e,i),t),r.invalidateQueries({queryKey:[`page`,e]}),r.invalidateQueries({queryKey:[`list`,e]}),r.invalidateQueries({queryKey:[`map`,e]})}})},L9=e=>e instanceof Js,gEe=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?W(`operationFailed`,n+1,gEe(r),e.message):W(`nothingSaved`,e.message)},vEe=(e,t)=>new e.constructor({...e.problem,detail:_Ee(e,t)}),R9=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),yEe=({model:e,stored:t,recordKey:n,mode:r,subject:i,draftKey:a,lines:o})=>{let s=U(),c=Om(),l=I9(e.name,n),u=I5(r,i),[d]=(0,I.useState)(()=>a?CTe(localStorage,a,t.etag):void 0),[f,p]=(0,I.useState)(d?.fields??{}),[m,h]=(0,I.useState)(!!d),[g,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)({}),[b,x]=(0,I.useState)({}),[S,C]=(0,I.useState)(0),w=Object.entries(f).filter(([n,r])=>jS(e.fields[n],r,t.record[n])),T=w.length>0,E=T||!!o?.dirty;(0,I.useEffect)(()=>{d?.order&&o?.setOrder(d.order)},[]),(0,I.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;wTe(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]:TS(t.record[n]),O=(n,r)=>{x(e=>R9(e,n));let i=typeof r==`string`?r!==TS(t.record[n]):jS(e.fields[n],r,t.record[n]);p(e=>i?{...e,[n]:r}:R9(e,n))},k=async()=>{let r=await s.get(e.name,n);c.setQueryData(H.record(e.name,n),r);let i={},a={};for(let[n,o]of Object.entries(f)){let s=e.fields[n];jS(s,o,r.record[n])&&(a[n]=o,TS(r.record[n])!==TS(t.record[n])&&(i[n]=s.type===`file`?Ox(s,r.record[n]):TS(r.record[n])))}p(a),y(i)},A=()=>Object.fromEntries(w.map(([t,n])=>[t,OS(e.fields[t],n)])),j=e=>{let t=fC(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 L9(e)?await k():Ys(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 L9(e)?(await k(),await c.invalidateQueries({queryKey:[`list`]}),_(!0)):Ys(e)&&j(e),Ys(e)?vEe(e,i):e}await Promise.all([c.invalidateQueries({queryKey:H.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=>R9(t,e)),useTheirs:e=>{y(t=>R9(t,e)),p(t=>R9(t,e))}}},z9=(e,t,n,r)=>{let i=U(),a=Om(),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=Oh({queries:o.map(e=>{let o=t[e.relation.resource],s=String(r[e.name]);return{queryKey:H.relatedLabel(o.name,s),queryFn:async()=>(await H0(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]))}},bEe=Un(),xEe=(e,t,n,r,i)=>{if(e.primaryKey.length!==1)return[];let a=new Set(tr(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??K(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??K(t)})`:i}})},SEe=(e,t)=>({kind:`list`,resource:e.resource,filter:Fn(bEe.eq(e.field,t))}),CEe=Un(),wEe=(e,t,n)=>{let r=U(),i=Oh({queries:e.map(e=>{let i=Fn(CEe.eq(e.field,n));return{queryKey:H.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}]})},TEe=({model:e,recordKey:t,layout:n,lines:r})=>{let{resources:i,views:a}=J(),o=wEe(xEe(e,i,a,n,r),i,t);return o.length===0?null:(0,R.jsx)(vb,{title:F5(`relatedRecords`),children:(0,R.jsx)(`ul`,{className:`-mx-2`,children:o.map(({relation:e,count:n})=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(_S,{to:SEe(e,t),className:`group flex items-center justify-between gap-3 rounded-md px-2 py-2 hover:bg-muted`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate font-medium text-primary-text`,children:e.label}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 tabular-nums text-muted-foreground`,children:[n===void 0?(0,R.jsx)(Uu,{className:`h-4 w-6`}):`${Sf(n.count)}${n.exact?``:`+`}`,(0,R.jsx)(ki,{className:`size-4 text-faint-foreground group-hover:text-foreground`})]})]})},`${e.resource}.${e.field}`))})})},B9=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.`}}),EEe=({children:e})=>{let t=(0,I.useRef)(null),[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1);return(0,I.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,R.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,R.jsx)(`div`,{className:g(`w-full min-w-0`,!n&&`max-h-40 overflow-hidden`),children:(0,R.jsx)(`div`,{ref:t,children:e})}),(i||n)&&(0,R.jsx)(V,{size:`sm`,variant:`ghost`,className:`-ml-2`,"aria-expanded":n,onClick:()=>r(!n),children:B9(n?`showLess`:`showMore`)})]})},DEe=e=>e==null||e===``,OEe=({scope:e,path:t})=>{let{views:n}=J(),r=Q0(e,t);if(r.state===`missing`||r.state===`ready`&&DEe(r.value))return null;let i=$0(t,r.state===`ready`?n[r.model.name]?.fields[r.field.name]?.label:void 0);return(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`dt`,{className:`text-body text-muted-foreground`,children:i}),(0,R.jsx)(`dd`,{className:`mt-0.5`,children:r.state===`loading`?(0,R.jsx)(Uu,{className:`h-4 w-24`}):(0,R.jsx)(EEe,{children:(0,R.jsx)(J0,{model:r.model,field:r.field,value:r.value})})})]})},kEe=({scope:e,view:t,fields:n,actions:r})=>(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-surface p-4`,children:[(0,R.jsx)(_S,{to:{kind:`record`,resource:e.model.name,key:px(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,R.jsx)(`dl`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,R.jsx)(OEe,{scope:e,path:t},t))}),r.length>0&&(0,R.jsx)(Qw,{value:e,children:(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:r.map(e=>(0,R.jsx)(ST,{name:e},e))})})]}),AEe=({model:e,view:t,filter:n,sort:r,fields:i,actions:a,limit:o,display:s,empty:c})=>{let l=Du(),u=r||iS(e,t),d=gT(e,{filter:n,sort:u,pageSize:o}),f=mT(e,n);if(d.isPending)return(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:2},(e,t)=>(0,R.jsx)(Uu,{className:`h-24 w-full`},t))});if(d.error)return(0,R.jsx)(US,{title:B9(`couldNotLoad`),error:d.error});let p=d.data.items;if(p.length===0)return(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:c??B9(`nothingYet`)});let m=f.data===void 0?void 0:h5(p.length,f.data,!1);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(`ul`,{className:`flex flex-col gap-3`,children:p.map(n=>{let r=fT(e,n);return(0,R.jsx)(kEe,{scope:r,view:t,fields:i,actions:a},r.key)})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m}),(0,R.jsxs)(_S,{to:p3(e,t,l,{filter:n,orderBy:u,display:f3(t,l,{preferred:s})}),className:`flex items-center gap-1 font-medium text-primary-text hover:underline`,children:[m5(`viewAll`),` `,(0,R.jsx)(`span`,{className:`sr-only`,children:(t?.names?.plural??K(e.name)).toLowerCase()}),(0,R.jsx)(Wr,{className:`size-3.5`,"aria-hidden":!0})]})]})]})},V9=Un(),H9=(...e)=>{let t=e.filter(e=>!!e);return t.length===1?t[0]:t.map(e=>`(${e})`).join(` AND `)},jEe=(e,t)=>{let n=U(),{resources:r}=J(),i=e.through,a=i?r[i.resource]:void 0,o=i?.key??a?.primaryKey[0],s=i?H9(Fn(V9.eq(i.field,t)),i.filter):``,c=Ah({queryKey:H.list(a?.name??``,s,``,0,`related:${o}`),enabled:!!(a&&o),queryFn:async()=>{let e=await s3(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:H9(Fn(V9.in(e.field,c.data)),e.filter),isPending:!1,error:null}:{filter:void 0,isPending:c.isPending,error:c.error}:{filter:H9(Fn(V9.eq(e.field,t)),e.filter),isPending:!1,error:null}},MEe=()=>(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,R.jsx)(Uu,{className:`h-4 w-full`},t))}),NEe=({empty:e})=>(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:e??F5(`nothingYet`)}),PEe=({item:e,value:t,owner:n})=>{let{resources:r,views:i}=J(),a=r[e.resource],o=a&&i[a.name],s=jEe(e,t),[c,l]=x5(o,`related:${n}:${e.title}`,e.display),u=hS(e.resource),[d,f]=(0,I.useState)(!1),p=U(),m=!!(e.hideEmpty&&a&&s.filter),h=Ah({queryKey:H.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=Mxe(e,a,r),_=e.columns??Tx(a,o).filter(t=>t!==e.field),v=t=>s.isPending?(0,R.jsx)(MEe,{}):s.error?(0,R.jsx)(US,{title:F5(`couldNotLoadRelated`),error:s.error}):s.filter===null||s.filter===void 0?(0,R.jsx)(NEe,{empty:e.empty}):t(s.filter);if(e.presentation===`cards`)return(0,R.jsx)(mb,{title:e.title,help:e.help,children:v(t=>(0,R.jsx)(AEe,{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=gbe(e,a,u),b=(0,R.jsx)(y5,{view:o,value:c,onChange:l}),x=y?(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!d&&b,(0,R.jsx)(p9,{size:`sm`,sorting:d,onChange:f})]}):b;return d&&y?(0,R.jsx)(mb,{title:e.title,help:e.help,actions:x,children:(0,R.jsx)(f9,{model:a,view:o,field:y,filter:Fn(V9.eq(e.field,t)),columns:_})}):(0,R.jsx)(mb,{title:e.title,help:e.help,actions:x,children:v(t=>(0,R.jsx)(b5,{model:a,view:o,filter:t,sort:e.sort??``,columns:_,limit:e.limit??10,display:c,empty:e.empty,opens:g},t))})},FEe=(e,t,n)=>{if(e.from===void 0)return n;let r=t[e.from];return typeof r==`boolean`?r:_5(t,e.from)??null},IEe=(e,t)=>t===e.tenant||e.primaryKey.includes(t),LEe=(e,t,n)=>{if(t&&t.layout.length>0)return t.layout;let r=Object.values(e.fields).filter(t=>!IEe(e,t.name)),i=r.filter(e=>!e.readOnly),a=(i.length>0&&!n?i:r).map(e=>e.name);return[{kind:`section`,title:F5(`details`),fields:a},...e.history?[{kind:`history`,title:F5(`history`)}]:[],...e.comments?[{kind:`comments`,title:F5(`comments`)}]:[]]},REe=({resource:e,recordKey:t})=>{let{resources:n}=J(),r=n[e],i=Kg(e,t);return r?i.isPending?(0,R.jsx)(mS,{title:F5(`loading`),children:F5(`fetching`)}):i.error?(0,R.jsx)(`div`,{className:`p-8`,children:Ys(i.error)&&i.error.status===404?(0,R.jsx)(mS,{title:W(`notFound`),children:F5(`noRecord`)}):(0,R.jsx)(US,{title:F5(`couldNotLoad`),error:i.error})}):(0,R.jsx)(zEe,{model:r,recordKey:t,stored:i.data,preview:i.isPlaceholderData},i.isPlaceholderData?`preview`:`loaded`):(0,R.jsx)(mS,{title:W(`notFound`),children:W(`noResource`,e)})},zEe=({model:e,recordKey:t,stored:n,preview:r})=>{let i=J(),{address:a,go:o}=gS(),s=i.views[e.name],c=ux(e,s,n.record,t),{state:l}=B(),u=(0,I.useMemo)(()=>yTe(i.resources,e),[i.resources,e]),d=DTe(u,ETe(u,e,t).items),f=yEe({model:e,stored:n,recordKey:t,mode:s?.saveFeedback??`toast`,subject:c,draftKey:!r&&l.kind===`signed-in`?STe(l.user.id,e.name,t):void 0,lines:d}),p=Om(),m=U(),h=pC(f.rejections),_=hS(e.name),v=V5(e),y=eT(_,`update`)&&n.permissions?.update!==!1,{shown:b,offersEdit:x,editing:S}=Zae(s?.recordMode,y,a?.kind===`record`&&a.edit===!0);Cre(f.dirty&&b===`form`),gre(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=eT(_,`delete`)&&n.permissions?.delete!==!1,j=B5({model:e,view:s,restore:v,onDeleted:()=>o({kind:`list`,resource:e.name},{replace:!0}),onReview:()=>void p.invalidateQueries({queryKey:H.record(e.name,t)})}),M=z9(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},ee=Object.values(e.fields).filter(e=>N(e.name)),te={...n.record,...Object.fromEntries(ee.map(e=>[e.name,kS(e,f.value(e.name))]))},ne=z9(e,i.resources,i.views,te),re=(e,t)=>{let n=N(e);if(!n||!IS(t))return f.change(e,t);p.setQueryData(H.relatedLabel(n.name,t.key),t.label),f.change(e,LS(n,t.key))},{fields:ie}=tC(),ae={model:e,record:n.record,key:t,etag:n.etag,permissions:n.permissions},oe=hEe(LEe(e,s,b===`read`),ae,S,r),{before:se,tabs:ce,after:le}=gTe(oe),ue=_Te(ce,T),de=e=>S&&(f.errors[e]!==void 0||f.conflicts[e]!==void 0);(0,I.useEffect)(()=>{if(f.rejections===0)return;let e=vTe(ce,ue,de);e&&o(E(C,w,e===ce[0]?void 0:e.title),{replace:!0})},[f.rejections]);let P=oe.flatMap(e=>e.kind===`sidebar`?e.fields:[]),fe=e.fields.status?.type===`enum`,pe=n.record.status,me=fe&&!P.includes(`status`)&&pe!=null&&pe!==``?String(pe):void 0,he=S9(e,`updated`),F=e=>s?.fields[e],ge=e=>nT(n.permissions,e)!==`hidden`&&PS(F(e)?.when,S),_e=e=>!r||Object.hasOwn(n.record,e),ve=r=>{let a=e.fields[r],o=nT(n.permissions,r);if(!a||o===`hidden`)return null;let c=f.conflicts[r],l=N(r),u=F(r)?.label??K(r),d=f.errors[r];return(0,R.jsx)(pb,{name:r,label:u,required:b===`form`&&o!==`read`&&Yae(a),help:NS(F(r),s,S),error:d&&dC(a,u,d),wide:!!(F(r)?.multiline||F(r)?.markdown),conflict:c===void 0?void 0:{user:{name:F5(`someoneElse`),initials:`?`,hue:40},ago:F5(`justNow`),theirValue:c||`—`,onKeepMine:()=>f.keepMine(r),onUseTheirs:()=>f.useTheirs(r)},children:_e(r)?(0,R.jsx)(cC,{field:a,hints:F(r),value:f.value(r),stored:n.record[r],relationLabel:ne.labels[r],relationTo:ne.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=>re(r,e)}):(0,R.jsx)(Uu,{className:`h-9`})},a.sensitive?`${r}:${n.etag}`:r)},ye=r=>{let i=e.fields[r],a=_e(r)?i.sensitive?(0,R.jsx)(cC,{field:i,hints:F(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,R.jsx)(J0,{model:e,field:i,value:n.record[r],relationLabel:M.labels[r]}):(0,R.jsx)(Uu,{className:`h-4 w-32`});return{label:F(r)?.label??K(r),help:NS(F(r),s,S),wide:!!(F(r)?.multiline||F(r)?.markdown),value:a}},be=oe.findIndex(e=>e.kind===`sidebar`),xe=(0,R.jsx)(yb,{title:F5(`summary`),rows:P.flatMap(t=>{let r=e.fields[t];if(!r||!ge(t))return[];if(!_e(t))return[{label:F(t)?.label??K(t),value:(0,R.jsx)(Uu,{className:`h-4 w-24`})}];let i=n.record[t],a=ox(r,F(t))&&typeof i==`string`&&i!==``?ax(i):Ox(r,i,F(t)),o=r.type===`text`&&typeof i==`string`&&i!==``?hx(F(t)):void 0,s=r.type===`enum`?(0,R.jsx)(q0,{value:i,hints:F(t),children:a}):o?(0,R.jsx)(sC,{format:o,value:a}):(0,R.jsx)(`strong`,{title:kx(r,i,void 0,F(t)),children:a}),c=nC(ie,r,F(t));return[{label:F(t)?.label??K(t),title:a,value:c?(0,R.jsx)(iC,{shown:c,part:`display`,field:r,value:n.record[t],fallback:s}):s}]})}),Se=async()=>{await f.save()&&k&&o(D,{replace:!0})},Ce=A?()=>void j.start({key:t,title:c,etag:n.etag,snapshot:n.record}):void 0,we=b===`form`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.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 Se(),children:[f.phase===`saved`&&(0,R.jsx)(Ci,{className:`size-4`}),f.phase===`saved`?F5(`saved`):F5(`save`)]}),k&&(0,R.jsx)(_S,{to:D,className:g(op(),`max-md:min-h-11 md:w-full`),onClick:e=>Wu(e)&&f.discard(),children:F5(`cancel`)}),f.dirty&&(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground max-md:order-first`,children:F5(`unsavedChanges`)})]}),Te=(i,a)=>{if(i.kind===`group`){let e=i.items.flatMap(Te);if(e.length===0)return[];let t=hTe(i,C,de),n=i.collapsed?E(mTe(C,i.title),w,T):void 0;return[(0,R.jsx)(Hae,{title:i.title,open:t,toggle:n,children:e},`group:${i.title}`)]}if(i.kind===`related`)return i.from!==void 0&&!_e(i.from)?[]:[(0,R.jsx)(PEe,{item:i,value:FEe(i,n.record,t),owner:e.name},`related:${i.title}`)];if(i.kind===`chart`)return[(0,R.jsx)(dTe,{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,R.jsx)(C9,{item:i,scope:ae},`custom:${a}`)];if(i.kind===`map`)return i.sidebar?[]:[(0,R.jsx)(w9,{item:i,record:n.record},`map:${a}`)];if(i.kind===`gallery`)return[(0,R.jsx)(WTe,{item:i,record:n.record,recordKey:t},`gallery:${a}`)];if(i.kind===`history`)return[(0,R.jsx)(ZTe,{item:i,model:e,view:s,recordKey:t,etag:n.etag},`history:${a}`)];if(i.kind===`comments`)return[(0,R.jsx)(fEe,{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]&&ge(t)),c=b===`read`&&i.presentation===`facts`,u=c?Nx(n.record,o):o;return u.length===0?[]:[(0,R.jsx)(mb,{title:i.title,help:MS(i.helpWhen,s,S)?i.help:void 0,children:c?(0,R.jsx)(Wae,{facts:u.map(e=>({label:ye(e).label,value:ye(e).value,icon:c6(F(e)?.icon)}))}):b===`read`?(0,R.jsx)(yS,{rows:u.map(ye)}):(0,R.jsx)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-5 sm:grid-cols-2`,children:u.map(ve)})},i.title)]};return(0,R.jsxs)(`div`,{ref:h,className:`flex flex-1 flex-col`,inert:r,children:[j.dialogs,(0,R.jsx)(`div`,{className:`flex-1`,children:(0,R.jsxs)(`div`,{className:`mx-auto max-w-[1100px] px-4 pb-8 pt-6 md:px-10 md:py-8`,children:[(0,R.jsx)(bb,{title:c,status:me?{label:_s(me,F(`status`)?.valueLabels),tone:yx(me)}:void 0}),f.message&&(0,R.jsx)(`div`,{className:`mt-4`,children:(0,R.jsx)(US,{title:F5(`notSaved`),error:Error(f.message)})}),f.linesConflict&&(0,R.jsx)(`div`,{className:`mt-4`,children:(0,R.jsx)(US,{title:F5(`linesChanged`),error:Error(F5(`linesReloaded`))})}),b!==`form`&&x&&f.dirty&&(0,R.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,R.jsx)(`span`,{children:F5(`unsavedKept`)}),(0,R.jsxs)(`span`,{className:`flex gap-2`,children:[(0,R.jsx)(_S,{to:O,className:op({size:`sm`}),children:F5(`continueEditing`)}),(0,R.jsx)(V,{size:`sm`,onClick:f.discard,children:F5(`discard`)})]})]}),b===`form`&&f.restored&&(0,R.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,R.jsx)(`span`,{children:F5(`unsavedRestored`)}),(0,R.jsxs)(`span`,{className:`flex gap-2`,children:[(0,R.jsx)(V,{size:`sm`,onClick:f.dismissRestored,children:F5(`keep`)}),(0,R.jsx)(V,{size:`sm`,onClick:f.discard,children:F5(`discard`)})]})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-[minmax(0,1fr)_300px] md:gap-12`,children:[(0,R.jsxs)(`main`,{className:`divide-y divide-border`,children:[se.flatMap(Te),ue&&(0,R.jsx)(Uae,{tabs:ce.map((e,t)=>({title:e.title,to:E(C,w,t===0?void 0:e.title),current:e===ue}))}),ue&&(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:ue.items.flatMap(Te)},`tab:${ue.title}`),le.flatMap(Te),u&&!r&&(0,R.jsx)(xTe,{lines:u,draft:d,vatRate:Number(n.record.vatRate??21)/100,saving:f.saving,locked:b!==`form`})]}),(0,R.jsxs)(`aside`,{className:`space-y-4 md:pt-8`,children:[we&&(0,R.jsx)(`div`,{className:`hidden flex-col items-center gap-2 md:flex`,children:we}),!r&&(0,R.jsx)(pTe,{model:e,stored:n,recordKey:t,edit:x?O:void 0,onDelete:Ce}),be===-1&&xe,oe.map((e,t)=>e.kind===`custom`&&e.sidebar&&!r?(0,R.jsx)(C9,{item:e,scope:ae},`custom:${t}`):e.kind===`map`&&e.sidebar&&!r?(0,R.jsx)(w9,{item:e,record:n.record},`map:${t}`):t===be?(0,R.jsx)(I.Fragment,{children:xe},`summary`):null),(0,R.jsx)(yb,{title:F5(`details`),rows:[S9(e,`created`),he].flatMap(t=>{let r=t?e.fields[t]:void 0;return!t||!r||!ge(t)?[]:[{label:F(t)?.label??K(t),value:_e(t)?(0,R.jsx)(`span`,{title:kx(r,n.record[t],void 0,F(t)),children:Ox(r,n.record[t],F(t))}):(0,R.jsx)(Uu,{className:`h-4 w-24`})}]})}),!r&&(0,R.jsx)(TEe,{model:e,recordKey:t,layout:oe,lines:u})]})]})]})}),we&&(0,R.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:we})]})},BEe=e=>Ys(e)?e.status===401||e.status===403?W(`signInRefused`,e.message):e.message:W(`noAnswer`),VEe=({status:e})=>{let t=Om();return e.state===`error`?(0,R.jsx)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center p-8`,children:(0,R.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,R.jsx)(`h1`,{className:`text-[16px] font-semibold`,children:W(`cannotReach`,e.source.label)}),(0,R.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[BEe(e.error),` `,W(`restWorks`)]}),(0,R.jsx)(V,{className:`mt-3`,onClick:()=>void t.refetchQueries({queryKey:H.sourceMetas(e.source.url)}),children:W(`tryAgain`)})]})}):(0,R.jsxs)(`div`,{className:`flex h-full min-h-48 flex-1 items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(Vd,{}),` `,W(`loadingFrom`,e.source.label)]})},U9=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`}}),W9=(e,t)=>e.toLowerCase().includes(t.trim().toLowerCase()),HEe=(e,t,n=``)=>{let r=Z7(e,n).flatMap(e=>e.items.filter(e=>e.href!==void 0&&!e.problem)).filter(e=>W9(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||!H5(a,e.pages,e.permissions[r.name]??dS))return[];let o=a.names?.singular??K(r.name),s=FS(`title`,o);return!W9(s,t)&&!W9(o,i)&&!W9(a.names?.plural??K(r.name),i)?[]:[{id:`new:${r.name}`,title:s,href:ws({kind:`create`,resource:r.name},n)}]});return[...r.length>0?[{id:`go-to`,label:U9(`goTo`),hits:r.map(e=>({id:`go-to:${e.id}`,title:e.label,href:e.href}))}]:[],...a.length>0?[{id:`create`,label:U9(`create`),hits:a.slice(0,5)}]:[]]},G9=Un(),UEe=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??K(t.name)}]}),WEe=e=>{let t=e.map(e=>e.label.toLowerCase());return t.length===0?U9(`search`):t.length===1?U9(`searchOne`,t[0]):t.length===2?U9(`searchTwo`,t[0],t[1]):U9(`searchMore`,t[0],t[1])},GEe=e=>Fn(G9.search(e.trim())),K9=e=>{let t=e.view?.searchResult?.title;return t?.length?t:[lx(e.model,e.view)]},q9=e=>{let t=K9(e);return e.view?.searchResult?.subtitle??e.model.search?.find(e=>!t.includes(e))},KEe=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`?_s(String(r),e.view?.fields[n]?.valueLabels):String(r)},qEe=(e,t,n,r=``)=>{let i=ur(px(e.model,t)),a=K9(e),o=q9(e),s=jn(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:ws({kind:`record`,resource:e.model.name,key:i},r)}},JEe=()=>{let e=J(),t=U(),{basePath:n}=Bh(),r=(0,I.useMemo)(()=>UEe(e),[e]),[i,a]=(0,I.useState)(``),o=i.trim(),s=M3(o,200),c=o.length>=2,l=c&&s.length>=2,u=Oh({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:GEe(s),pageSize:5,fields:KEe(e)})}))}),d=(0,I.useMemo)(()=>l?HEe(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=>qEe(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:WEe(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`}}),YEe=e=>!!(e?.updateAvailable&&e.indicator),XEe=e=>e?5e3:18e5,ZEe=(e,t)=>{if(!e.updateStage)return Y9(`updatingNow`);let n=Y9(e.updateStage);return e.updateStartedAt?Y9(`started`,n,ep(Math.max(0,Math.floor((t-Date.parse(e.updateStartedAt))/1e3)))):n},X9=(e,t=Date.now(),n=Ef())=>e.updating?ZEe(e,t):e.nextUpdateAt?Y9(`nextOn`,Y9(e.policy),Kf(Date.parse(e.nextUpdateAt),n)):Y9(e.policy),QEe=(e,t=Ef())=>{let n=Kf(Date.parse(e.finishedAt),t),r=Y9(e.outcome,e.toVersion,n);return e.message?`${r}: ${e.message}`:`${r}.`},$Ee=e=>Ys(e)&&e.status<500&&e.problem.detail?e.problem.detail:Ys(e)&&e.status===409?Y9(`alreadyLatest`):Ys(e)&&e.status===403?Y9(`onlyAdmin`):Y9(`couldNotStart`),Z9=({label:e,value:t})=>(0,R.jsxs)(`div`,{className:`flex justify-between gap-4 py-1`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`font-medium tabular-nums`,children:t})]}),eDe=({status:e,requesting:t,error:n,checkError:r,onUpdate:i,onClose:a})=>{let o=e.updating?void 0:e.lastUpdate;return(0,R.jsxs)(sp,{title:Y9(`runtimeUpdate`),description:e.updating?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(Vd,{className:`size-3.5`}),X9(e)]}):X9(e),onClose:a,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(V,{onClick:a,children:Y9(`close`)}),(0,R.jsx)(V,{variant:`primary`,loading:t,disabled:e.updating||!e.updateAvailable,onClick:i,children:e.updating?Y9(`updating`):Y9(`updateNow`)})]}),children:[(0,R.jsx)(Z9,{label:Y9(`currentVersion`),value:e.version}),(0,R.jsx)(Z9,{label:Y9(`latestVersion`),value:e.latest}),o&&(0,R.jsx)(`p`,{className:o.outcome===`failed`?`mt-3 text-danger-text`:`mt-3 text-muted-foreground`,children:QEe(o)}),n!==void 0&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-danger-text`,children:$Ee(n)}),r!==void 0&&(0,R.jsx)(`p`,{className:`mt-3 text-muted-foreground`,children:Y9(`checkFailed`)})]})},tDe=e=>{let t=Hg(),n=(0,I.useRef)(t);n.current=t;let r=t!==void 0;return(0,I.useMemo)(()=>r?wu({url:e,token:()=>n.current}):void 0,[e,r])},nDe=e=>{let[t,n]=(0,I.useState)(),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(),[s,c]=(0,I.useState)(),l=t?.updating??!1;return(0,I.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(),XEe(l));return()=>{t=!1,clearInterval(i)}},[e,l]),{status:t,update:(0,I.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}=nDe(e),[o,s]=(0,I.useState)(!1);return!t||!o&&!YEe(t)?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.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,R.jsx)(Ree,{className:`size-3.5 text-primary`}),(0,R.jsx)(`span`,{className:`max-md:sr-only`,children:Y9(`update`)})]}),o&&(0,R.jsx)(eDe,{status:t,requesting:r,error:i,checkError:a,onUpdate:()=>void n(),onClose:()=>s(!1)})]})},rDe=({url:e})=>(0,R.jsx)(Q9,{client:tDe(e)}),iDe=({url:e,client:t})=>t?(0,R.jsx)(Q9,{client:t}):(0,R.jsx)(rDe,{url:e}),aDe=({signIn:e,onStop:t})=>{let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(),o=async()=>{r(!0),a(void 0);try{await t()}catch(e){if(!(e instanceof Dc))throw e;a(ef(e)),r(!1)}};return(0,R.jsxs)(`div`,{role:`region`,"aria-label":W(`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,R.jsx)(ute,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,R.jsx)(`p`,{className:`min-w-64 flex-1 break-words`,children:Xh(W(`staffSignedIn`),(0,R.jsx)(`span`,{className:`font-semibold`,children:e.staffName??e.staff}),(0,R.jsx)(`span`,{className:`font-semibold`,children:e.user}),Kf(Date.parse(e.expiresAt)),e.reason)}),i&&(0,R.jsx)(`p`,{role:`alert`,className:`text-body font-medium text-danger-text`,children:i}),(0,R.jsx)(V,{size:`sm`,loading:n,onClick:()=>void o(),children:W(`stopStaffSession`)})]})},oDe=(e,t,n)=>({filter:n.filter??``,orderBy:n.orderBy??iS(e,t),pageSize:n.limit??3,fields:[...new Set([...e.primaryKey,lx(e,t),n.status])]}),sDe=(e,t,n,r,i,a)=>r.map(r=>{let o=ur(px(e,r)),s=String(r[n.status]??``);return{id:o,label:ux(e,t,r,o),href:ws({kind:`record`,resource:e.name,key:o},i),status:e.fields[n.status]?.type===`enum`&&s?_s(s,t.fields[n.status]?.valueLabels):s,tone:n.tones[s]??`neutral`,pulse:n.pulse?.includes(s)??!1,active:o===a}}),cDe=(e,t,n,r,i)=>{let a=n.find(t=>ur(px(e,t))===r);return a!==void 0&&t.some(e=>!Object.is(a[e],i[e]))},$9=({model:e,request:t})=>H.navRecent(e.name,t.filter,t.orderBy,t.pageSize),lDe=e=>{let t=Om();(0,I.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&&cDe(n.model,n.request.fields,e.items,a,o)&&t.invalidateQueries({queryKey:$9(n),exact:!0})}}),[t,e])},uDe=(e,t,n)=>{let r=U(),i=(0,I.useMemo)(()=>{let t=J7(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:oDe(r,n,i)}]:[]})},[e]);lDe(i);let a=Oh({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:sDe(e,r,i,s.data.items,t,c)}]}))},dDe=e=>e?.kind===`page`?e.page:e?.kind===`list`?Y7(e.resource,e.list):e?.resource,fDe=e=>e?.kind===`record`?e:void 0,pDe=({workspace:e,sidebarMode:t,assistant:n,runtime:r})=>{let i=J(),{state:a,session:o,signOut:s,stopStaffSession:c,organizations:l}=B(),u=ng();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}=Bh(),{address:g,go:_,open:v}=gS(),y=dDe(g),b=fDe(g),x=JEe(),S=RC(),C=uDe(i,h,{resource:b?.resource,key:b?.key});Iie(i);let w=Z7(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,I.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?Wg(i,O):void 0,A=O?nr(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=Kg(b?.resource??``,b?.key??``,!!(M&&b)),ee=M&&b&&N.data?ux(M,A,N.data.record,b.key):void 0,te=!!b&&(N.isLoading||k?.state===`loading`),{shell:ne}=tC(),re=ne?.actions,ie=ne?.rightPanel,[ae,oe]=(0,I.useState)(!1),se=i.assistant?.url,ce=se&&(0,R.jsx)(bw,{open:ae,onToggle:()=>oe(!ae)}),le=se&&ae&&(0,R.jsx)(Cw,{url:se,client:n,page:m.size>0?`${p}?${m}`:p,onClose:()=>oe(!1)}),ue=i.errorReporting;(0,I.useEffect)(()=>{ue&&lie(ue)},[ue]);let de=i.runtime?.url,P=de&&(0,R.jsx)(iDe,{url:de,client:r}),fe=$we((0,I.useCallback)(()=>g9(h),[h]),!!d),pe=d&&Qwe(d,fe.current),me=pe?Vg(pe):!1,he=tTe(),F=Hwe(!!(l&&d)),ge=F.current,_e=!!l&&ge!==void 0&&!ge.organization,ve=l&&d?oie(p):void 0,ye=d?p===`/-/account`?W(`signInSecurity`):p===`/-/sign-in-policy`?W(`signInPolicy`):ve:void 0,be=A?.names?.plural??(O&&K(O)),xe=ye?[ye]:kw({basePath:h,address:g,group:j?.label,page:D,resourceLabel:be,recordTitle:ee,recordLoading:te});HS(noe(toe({address:g,page:D,accountPage:ye,resourceLabel:be,singular:A?.names?.singular??(O&&K(O)),recordTitle:ee,recordLoading:te}),i.appName));let Se=d&&p===`/-/account`?(0,R.jsx)(mm,{email:d.email}):d&&p===`/-/sign-in-policy`?me?(0,R.jsx)(Em,{}):(0,R.jsx)(mS,{title:W(`adminsOnly`),children:W(`onlyAdminPolicy`)}):ve&&p===`/-/organization`?(0,R.jsx)(qwe,{current:ge,basePath:h,onChanged:F.reload}):ve&&(p===`/-/organization/members`||p===`/-/organization/invitations`)?lg(ge)?p===`/-/organization/members`?(0,R.jsx)(Rwe,{current:ge}):(0,R.jsx)(Vwe,{current:ge}):(0,R.jsx)(mS,{title:W(`ownersOnly`),children:W(`onlyOwners`)}):ve&&p===`/-/organizations`||_e?(0,R.jsx)(Zwe,{state:F,basePath:h}):g?g.kind===`page`?D?(0,R.jsx)(P5,{name:D.name},D.name):(0,R.jsx)(mS,{title:W(`notFound`),children:Xh(W(`noPage`),g.page)}):k&&k.state!==`ready`?(0,R.jsx)(VEe,{status:k}):g.kind===`create`?(0,R.jsx)($xe,{resource:g.resource,values:g.values},g.resource):g.kind===`record`?(0,R.jsx)(REe,{resource:g.resource,recordKey:g.key},`${g.resource}/${g.key}`):(0,R.jsx)(Iwe,{address:g},Y7(g.resource,g.list)):p===`/`?(0,R.jsx)(mS,{title:W(`chooseResource`),children:W(`pickFromSidebar`)}):(0,R.jsx)(mS,{title:W(`notFound`),children:W(`nothingHere`)}),Ce=(0,R.jsx)(qd,{pageScroll:!0,sidebarMode:t??`text-small`,activeItem:y??``,breadcrumb:xe,user:pe&&Aie(pe),onSignOut:d&&(()=>void s()),signIn:d?void 0:u.link(),workspace:ge?.organization?.name??e,appName:i.appName,appIcon:i.appIcon,logo:eTe,navGroups:w,bottomBar:Ow(i,h,y),userMenu:[...owe(i,h,y),...l&&d?sie(h,p,ge):[],...d?mte(h,p,me):[]],organizations:l&&{...ge?.organization&&{current:{id:ge.organization.id,name:ge.organization.name}},others:F.organizations.filter(e=>e.id!==ge?.organization?.id),onSwitch:e=>void o.organizations.switchTo(e).then(()=>g9(h))},theme:{preference:S.preference,onChange:S.choose},roles:fe.current?.active?{active:fe.current.active,roles:fe.current.roles,onSwitch:fe.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:(re||P||ce)&&(0,R.jsxs)(R.Fragment,{children:[re&&(0,R.jsx)(vg,{name:`shell.actions`,fallback:null,children:(0,R.jsx)(re,{})}),P,ce]}),rightPanel:(ie||le)&&(0,R.jsxs)(R.Fragment,{children:[ie&&(0,R.jsx)(vg,{name:`shell.rightPanel`,fallback:null,children:(0,R.jsx)(ie,{})}),le]}),children:Se}),we=me&&he.length>0;return!f&&!we?Ce:(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[f&&(0,R.jsx)(aDe,{signIn:f,onStop:c}),we&&(0,R.jsx)(rTe,{off:he}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:Ce})]})},mDe=({baseUrl:e,client:t,sources:n,workspace:r,sidebarMode:i,ui:a,assistant:o,runtime:s})=>{let{state:c,session:l,markSignedOut:u}=B();return(0,R.jsx)(Rh,{baseUrl:e,client:t,sources:n,token:c.kind===`visitor`?void 0:l.token,onUnauthenticated:u,children:(0,R.jsx)(Vae,{children:(0,R.jsx)(db,{children:(0,R.jsx)(nTe,{ui:a,children:(0,R.jsx)(pDe,{workspace:r,sidebarMode:i,assistant:o,runtime:s})})})})})},hDe=({baseUrl:e,client:t,ui:n,children:r})=>{let i=OC();return i?(0,R.jsx)(Rh,{baseUrl:e,client:t,children:(0,R.jsx)(eC.Provider,{value:n??{},children:(0,R.jsx)(EC,{name:i.name},i.name)})}):r},gDe=({auth:e,workspace:t,basePath:n,initialUrl:r,pluginLoader:i,locale:a,...s})=>(o(a??`en`),(0,R.jsx)(LC,{children:(0,R.jsx)(hf,{session:e,...s.baseUrl&&{origin:new URL(s.baseUrl,window.location.href).origin},children:(0,R.jsx)(xre,{basePath:n,initialUrl:r,children:(0,R.jsx)(wie,{...i&&{loader:i},children:(0,R.jsx)(Nie,{children:(0,R.jsx)(hDe,{baseUrl:s.baseUrl,client:s.client,ui:s.ui,children:(0,R.jsx)(Oie,{workspace:t,children:(0,R.jsx)(mDe,{workspace:t,...s})})})})})})})}));export{Jh as $,GC as A,gS as B,ow as C,QC as D,$C as E,voe as F,Gg as G,fS as H,XS as I,Mg as J,Hg as K,qS as L,BC as M,zC as N,YC as O,yoe as P,Yh as Q,KS as R,dw as S,ew as T,mb as U,J as V,pb as W,wg as X,gie as Y,yg as Z,Mw as _,c5 as a,Ah as at,gw as b,lxe as c,yp as ct,H0 as d,op as dt,qh as et,kT as f,_f as ft,Uw as g,Xu as gt,$w as h,Ld as ht,L5 as i,H as it,HC as j,JC as k,d6 as l,sp as lt,AT as m,Rd as mt,L9 as n,U as nt,Sxe as o,qm as ot,jT as p,Vd as pt,jg as q,I9 as r,Lh as rt,cxe as s,Om as st,gDe as t,Rh as tt,b3 as u,V as ut,yw as v,rw as w,hw as x,vw as y,_S as z};
|