fastapi-rtk 0.0.99 → 0.0.101

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.
@@ -184,16 +184,17 @@ async function nd(e, t, { email: r }) {
184
184
  }
185
185
  async function od(e, t, r, n) {
186
186
  const o = Se(e, "auth/login", t);
187
- if (r) {
188
- const s = window.screenLeft + window.outerWidth / 2 - 250, l = window.screenTop + window.outerHeight / 2 - 500 / 2, c = window.open(
189
- o + "?popup=true",
190
- "auth",
191
- `toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=500, height=500, top=${l}, left=${s}`
192
- ), f = window.setInterval(function() {
193
- c.closed !== !1 && (window.clearInterval(f), n == null || n());
194
- }, 200);
187
+ if (!r) {
195
188
  window.location.href = Se(e, "auth/login", t);
189
+ return;
196
190
  }
191
+ const i = 500, a = 500, s = window.screenLeft + window.outerWidth / 2 - i / 2, l = window.screenTop + window.outerHeight / 2 - a / 2, c = window.open(
192
+ o + "?popup=true",
193
+ "auth",
194
+ `toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${i}, height=${a}, top=${l}, left=${s}`
195
+ ), f = window.setInterval(function() {
196
+ c.closed !== !1 && (window.clearInterval(f), n == null || n());
197
+ }, 200);
197
198
  }
198
199
  async function id(e, t) {
199
200
  const { fetchPath: r, options: n } = Be({
@@ -1,4 +1,4 @@
1
- (function(I,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("react/jsx-runtime"),require("react-router-dom"),require("zustand"),require("@tanstack/react-query"),require("@mantine/hooks"),require("@mantine/core"),require("@mantine/form"),require("@mantine/dates"),require("@jsonforms/core"),require("@jsonforms/react"),require("clsx"),require("@emotion/react"),require("mantine-react-table")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-router-dom","zustand","@tanstack/react-query","@mantine/hooks","@mantine/core","@mantine/form","@mantine/dates","@jsonforms/core","@jsonforms/react","clsx","@emotion/react","mantine-react-table"],v):(I=typeof globalThis<"u"?globalThis:I||self,v(I["fastapi-rtk"]={},I.React,I.jsxRuntime,I.reactRouterDom,I.zustand,I.reactQuery,I.hooks,I.core,I.form,I.dates,I.core$1,I.react,I.clsx,I.react$1,I.mantineReactTable))})(this,function(I,v,l,ys,$u,rt,Te,g,sr,ut,H,ue,At,bs,yt){"use strict";var Ux=Object.defineProperty;var Vx=(I,v,l)=>v in I?Ux(I,v,{enumerable:!0,configurable:!0,writable:!0,value:l}):I[v]=l;var Ou=(I,v,l)=>Vx(I,typeof v!="symbol"?v+"":v,l);function Pu(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const $e=Pu(v),vs=v.createContext({path:"",data:null,info:null,queryParams:null,loading:!1,error:null,streaming:null,specialKey:null,setQueryParams:e=>null,refetch:()=>null,refetchInfo:()=>null,getEntry:async e=>({}),addEntry:async(e,t)=>({}),updateEntry:async(e,t,r)=>({}),deleteEntry:async(e,t)=>({}),download:async e=>null});function te(){const e=v.useContext(vs);if(e===void 0)throw new Error("useApi must be used within a ApiProvider");return e}function Pe({path:e,method:t,body:r=void 0,queryParams:n=void 0}){const o=Object.entries(n||{}).reduce((a,[c,u])=>((Array.isArray(u)||typeof u=="object")&&(u=JSON.stringify(u)),a[c]=u,a),{}),s=new ys.createSearchParams(o);e=e+"?"+s;const i={method:t,mode:"cors",credentials:"include",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:r?JSON.stringify(r):null};return{fetchPath:e,options:i}}function Iu(e){const t=[];if(e.length===0)return"";if(typeof e[0]!="string")throw new TypeError("Url must be a string. Received "+e[0]);e[0].match(/^[^/:]+:\/*$/)&&e.length>1&&(e[0]=e.shift()+e[0]),e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(let o=0;o<e.length;o++){let s=e[o];if(typeof s!="string")throw new TypeError("Url must be a string. Received "+s);s!==""&&(o>0&&(s=s.replace(/^[\/]+/,"")),o<e.length-1?s=s.replace(/[\/]+$/,""):s=s.replace(/[\/]+$/,"/"),t.push(s))}let r=t.join("/");r=r.replace(/\/(\?|&|#[^!])/g,"$1");const n=r.split("?");return r=n.shift()+(n.length>0?"?":"")+n.join("&"),r}function Se(...e){const t=Array.from(Array.isArray(e[0])?e[0]:e);return Iu(t)}const ku=e=>new Proxy(e,{get(t,r){return t(n=>n[r])}}),Mu=(e,t)=>Object.entries(t).reduce((r,[n,o])=>typeof o=="object"&&JSON.stringify(o)===JSON.stringify(e[n])||o===e[n]?r:{...r,[n]:o},{});function ir(e){const[t]=v.useState(()=>$u.create(()=>({...e}))),[r]=v.useState(()=>ku(t));return v.useEffect(()=>{t.setState(n=>Mu(n,e))},[e,t]),r}const Ts=v.createContext({user:null,loading:!1,error:null,signin:async(e,t)=>null,signout:async()=>null,update:async e=>null,resetPassword:async e=>null,oauth_signin:(e,t)=>null,refetch:async()=>null});function bt(){return v.useContext(Ts)}const Ss=v.createContext({baseUrl:"",info:null,loading:!1,error:null});function _s(){return v.useContext(Ss)}async function Du(e,{username:t,password:r}){const n=new FormData;n.append("username",t),n.append("password",r);const{fetchPath:o,options:s}=Pe({path:Se(e,"auth/login"),method:"POST"}),i=await fetch(o,{...s,headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(n)});if(!i.ok)throw i.status===400?new Error("Username or password wrong."):new Error("Failed to sign in.")}async function Fu(e){const{fetchPath:t,options:r}=Pe({path:Se(e,"auth/logout"),method:"POST"});if(!(await fetch(t,r)).ok)throw new Error("Failed to sign out.")}async function Nu(e,t,{email:r}){const{fetchPath:n,options:o}=Pe({path:Se(e,"auth/forgot-password"),method:"POST",body:{email:r}}),s=await fetch(n,o);if(!s.ok)throw new Error("Couldn't request token to reset password");const i=await s.json(),{token:a}=i,{fetchPath:c,options:u}=Pe({path:Se(e,"auth/reset-password"),method:"POST",body:{token:a,password:t}});if(!(await fetch(c,u)).ok)throw new Error("Couldn't reset password")}async function Lu(e,t,r,n){const o=Se(e,"auth/login",t);if(r){const a=window.screenLeft+window.outerWidth/2-250,c=window.screenTop+window.outerHeight/2-500/2,u=window.open(o+"?popup=true","auth",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=500, height=500, top=${c}, left=${a}`),d=window.setInterval(function(){u.closed!==!1&&(window.clearInterval(d),n==null||n())},200);window.location.href=Se(e,"auth/login",t)}}async function ju(e,t){const{fetchPath:r,options:n}=Pe({path:Se(e,"info/"),method:"GET"}),o=await fetch(r,{signal:t,...n}),s=await o.json();if(!o.ok){const i=typeof s.detail=="string"?s.detail:JSON.stringify(s.detail,null,2);throw new Error(i)}return s}async function zu(e,t){const{fetchPath:r,options:n}=Pe({path:Se(e,"auth/user"),method:"GET"}),o=await fetch(r,{signal:t,...n}),s=await o.json();if(!o.ok){const i=typeof s.detail=="string"?s.detail:JSON.stringify(s.detail,null,2);throw new Error(i)}return s}async function Bu(e,t){const{fetchPath:r,options:n}=Pe({path:Se(e,"auth/user"),method:"PUT",body:t}),o=await fetch(r,n),s=await o.json();if(!o.ok){const i=typeof s.detail=="string"?s.detail:JSON.stringify(s.detail,null,2);throw new Error(i)}return s}function Uu(e){const t=rt.useQueryClient(),r=rt.useQuery({queryKey:["user"],queryFn:({signal:d})=>zu(e,d),retry:0}),[n,o]=v.useState(null),s=v.useCallback(({username:d,password:f})=>{o(null),Du(e,{username:d,password:f}).then(()=>t.invalidateQueries({queryKey:["user"]})).catch(p=>o(p))},[e,t]),i=v.useCallback(()=>{o(null),Fu(e).then(()=>t.resetQueries({queryKey:["user"]})).then(()=>t.resetQueries({queryKey:["info"]})).catch(d=>o(d))},[e,t]),a=v.useCallback(d=>{o(null),Bu(e,d).then(()=>t.invalidateQueries({queryKey:["user"]})).catch(f=>o(f))},[e,t]),c=v.useCallback(d=>{o(null),Nu(e,d,r.data).catch(f=>o(f))},[e,r.data]),u=v.useCallback((d,f)=>Lu(e,d,f,()=>t.invalidateQueries({queryKey:["user"]})),[e,t]);return{user:r.isError?null:r.data,loading:r.isFetching,error:n?n.message:null,signin:s,signout:i,update:a,resetPassword:c,oauth_signin:u,refetch:r.refetch}}function Vu(e,t){const r=rt.useQuery({queryKey:["info"],queryFn:({signal:n})=>ju(e,n),enabled:!1});return v.useEffect(()=>{t.user&&!r.data&&r.refetch()},[t.user,r]),{baseUrl:e,info:r.data,loading:r.isFetching,error:r.error}}function Wu(e){const t={baseUrl:new URL(document.baseURI).pathname+"/api/v1",inheritMantineTheme:!1},{baseUrl:r,children:n}={...t,...e},o=Uu(r),s=ir(o),i=Vu(r,o),a=ir(i);return l.jsx(Ts.Provider,{value:s,children:l.jsx(Ss.Provider,{value:a,children:n})})}function Gu(e){const[t]=v.useState(()=>new rt.QueryClient);return l.jsx(rt.QueryClientProvider,{client:t,children:l.jsx(Wu,{...e})})}const ws=v.createContext({bulkActions:{selectedIds:[],setSelectedIds:()=>{}},dispatchBulkActions:async(e,t)=>{},error:null});function Hu(){const e=v.useContext(ws);if(e===void 0)throw new Error("useBulkActions must be used within a ApiProvider");return e}const Yu=async(e,t)=>{const{fetchPath:r,options:n}=Pe({path:Se(e,"/"),method:"POST",body:t}),o=await fetch(r,n);let s=null;const i=o.headers.get("content-type");if(i&&i.includes("application/json")?s=await o.json():s=await o.text(),!o.ok)throw typeof s=="object"?new Error(typeof s.detail=="string"?s.detail:JSON.stringify(s,null,2)):new Error(s);return s},qu=async(e,t)=>{const{fetchPath:r,options:n}=Pe({path:Se(e,t.toString()),method:"DELETE"}),o=await fetch(r,n);let s=null;const i=o.headers.get("content-type");if(i&&i.includes("application/json")?s=await o.json():s=await o.text(),!o.ok)throw typeof s=="object"?new Error(typeof s.detail=="string"?s.detail:JSON.stringify(s,null,2)):new Error(s);return s},Ku=async(e,t)=>{const{fetchPath:r,options:n}=Pe({path:e,method:"GET"}),o=await fetch(r,{signal:t,...n}),s=await o.json();if(!o.ok){const i=typeof s.detail=="string"?s.detail:JSON.stringify(s.detail,null,2);throw new Error(i)}return s},Ju=async(e,t)=>{const{fetchPath:r,options:n}=Pe({path:Se(e,t.toString()),method:"GET"}),o=await fetch(r,n);let s=null;const i=o.headers.get("content-type");if(i&&i.includes("application/json")?s=await o.json():s=await o.text(),!o.ok)throw typeof s=="object"?new Error(typeof s.detail=="string"?s.detail:JSON.stringify(s,null,2)):new Error(s);return s},Zu=async(e,t,r)=>{const{fetchPath:n,options:o}=Pe({path:e,method:"GET",queryParams:t}),s=await fetch(n,{signal:r,...o});let i=null;const a=s.headers.get("content-type");if(a&&a.includes("application/json")?i=await s.json():i=await s.text(),!s.ok)throw typeof i=="object"?new Error(typeof i.detail=="string"?i.detail:JSON.stringify(i,null,2)):new Error(i);return i},Xu=async(e,t,r)=>{const{fetchPath:n,options:o}=Pe({path:Se(e,t.toString()),method:"PUT",body:r}),s=await fetch(n,o);let i=null;const a=s.headers.get("content-type");if(a&&a.includes("application/json")?i=await s.json():i=await s.text(),!s.ok)throw typeof i=="object"?new Error(typeof i.detail=="string"?i.detail:JSON.stringify(i,null,2)):new Error(i);return i},je=e=>e&&typeof e=="object"?Array.isArray(e)?e.join(","):JSON.stringify(e):e,Qu={columns:[],filters:[],page:0,page_size:25};function Ar(e,t={}){return Object.entries(t).reduce((r,[n,o])=>o==null?(delete r[n],r):{...r,[n]:o},e||Qu)}const Cs=e=>{const t={};for(const r of e)switch(r.type){case"RelatedList":t[r.name]=[];break;case"Boolean":t[r.name]="false";break;case"Date":case"DateTime":case"Integer":case"Float":case"Geometry":case"Raw":case"Related":t[r.name]=void 0;break;default:t[r.name]=""}return t};var Or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ft(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function vt(e){this._maxSize=e,this.clear()}vt.prototype.clear=function(){this._size=0,this._values=Object.create(null)},vt.prototype.get=function(e){return this._values[e]},vt.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var Ru=/[^.^\]^[]+|(?=\[\]|\.\.)/g,Es=/^\d+$/,ef=/^\d/,tf=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,rf=/^\s*(['"]?)(.*?)(\1)\s*$/,Dn=512,xs=new vt(Dn),As=new vt(Dn),Os=new vt(Dn),Tt={Cache:vt,split:Nn,normalizePath:Fn,setter:function(e){var t=Fn(e);return As.get(e)||As.set(e,function(n,o){for(var s=0,i=t.length,a=n;s<i-1;){var c=t[s];if(c==="__proto__"||c==="constructor"||c==="prototype")return n;a=a[t[s++]]}a[t[s]]=o})},getter:function(e,t){var r=Fn(e);return Os.get(e)||Os.set(e,function(o){for(var s=0,i=r.length;s<i;)if(o!=null||!t)o=o[r[s++]];else return;return o})},join:function(e){return e.reduce(function(t,r){return t+(Ln(r)||Es.test(r)?"["+r+"]":(t?".":"")+r)},"")},forEach:function(e,t,r){nf(Array.isArray(e)?e:Nn(e),t,r)}};function Fn(e){return xs.get(e)||xs.set(e,Nn(e).map(function(t){return t.replace(rf,"$2")}))}function Nn(e){return e.match(Ru)||[""]}function nf(e,t,r){var n=e.length,o,s,i,a;for(s=0;s<n;s++)o=e[s],o&&(af(o)&&(o='"'+o+'"'),a=Ln(o),i=!a&&/^\d+$/.test(o),t.call(r,o,a,i,s,e))}function Ln(e){return typeof e=="string"&&e&&["'",'"'].indexOf(e.charAt(0))!==-1}function of(e){return e.match(ef)&&!e.match(Es)}function sf(e){return tf.test(e)}function af(e){return!Ln(e)&&(of(e)||sf(e))}const lf=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,$r=e=>e.match(lf)||[],Pr=e=>e[0].toUpperCase()+e.slice(1),jn=(e,t)=>$r(e).join(t).toLowerCase(),$s=e=>$r(e).reduce((t,r)=>`${t}${t?r[0].toUpperCase()+r.slice(1).toLowerCase():r.toLowerCase()}`,"");var zn={words:$r,upperFirst:Pr,camelCase:$s,pascalCase:e=>Pr($s(e)),snakeCase:e=>jn(e,"_"),kebabCase:e=>jn(e,"-"),sentenceCase:e=>Pr(jn(e," ")),titleCase:e=>$r(e).map(Pr).join(" ")},Bn={exports:{}};Bn.exports=function(e){return Ps(cf(e),e)},Bn.exports.array=Ps;function Ps(e,t){var r=e.length,n=new Array(r),o={},s=r,i=uf(t),a=ff(e);for(t.forEach(function(u){if(!a.has(u[0])||!a.has(u[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});s--;)o[s]||c(e[s],s,new Set);return n;function c(u,d,f){if(f.has(u)){var p;try{p=", node was:"+JSON.stringify(u)}catch{p=""}throw new Error("Cyclic dependency"+p)}if(!a.has(u))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(u));if(!o[d]){o[d]=!0;var y=i.get(u)||new Set;if(y=Array.from(y),d=y.length){f.add(u);do{var b=y[--d];c(b,a.get(b),f)}while(d);f.delete(u)}n[--r]=u}}}function cf(e){for(var t=new Set,r=0,n=e.length;r<n;r++){var o=e[r];t.add(o[0]),t.add(o[1])}return Array.from(t)}function uf(e){for(var t=new Map,r=0,n=e.length;r<n;r++){var o=e[r];t.has(o[0])||t.set(o[0],new Set),t.has(o[1])||t.set(o[1],new Set),t.get(o[0]).add(o[1])}return t}function ff(e){for(var t=new Map,r=0,n=e.length;r<n;r++)t.set(e[r],r);return t}var df=Bn.exports;const pf=ft(df),hf=Object.prototype.toString,gf=Error.prototype.toString,mf=RegExp.prototype.toString,yf=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",bf=/^Symbol\((.*)\)(.*)$/;function vf(e){return e!=+e?"NaN":e===0&&1/e<0?"-0":""+e}function Is(e,t=!1){if(e==null||e===!0||e===!1)return""+e;const r=typeof e;if(r==="number")return vf(e);if(r==="string")return t?`"${e}"`:e;if(r==="function")return"[Function "+(e.name||"anonymous")+"]";if(r==="symbol")return yf.call(e).replace(bf,"Symbol($1)");const n=hf.call(e).slice(8,-1);return n==="Date"?isNaN(e.getTime())?""+e:e.toISOString(e):n==="Error"||e instanceof Error?"["+gf.call(e)+"]":n==="RegExp"?mf.call(e):null}function Je(e,t){let r=Is(e,t);return r!==null?r:JSON.stringify(e,function(n,o){let s=Is(this[n],t);return s!==null?s:o},2)}function ks(e){return e==null?[]:[].concat(e)}let Ms,Ds,Fs,Tf=/\$\{\s*(\w+)\s*\}/g;Ms=Symbol.toStringTag;class Ns{constructor(t,r,n,o){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[Ms]="Error",this.name="ValidationError",this.value=r,this.path=n,this.type=o,this.errors=[],this.inner=[],ks(t).forEach(s=>{if(Ce.isError(s)){this.errors.push(...s.errors);const i=s.inner.length?s.inner:[s];this.inner.push(...i)}else this.errors.push(s)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}Ds=Symbol.hasInstance,Fs=Symbol.toStringTag;class Ce extends Error{static formatError(t,r){const n=r.label||r.path||"this";return r=Object.assign({},r,{path:n,originalPath:r.path}),typeof t=="string"?t.replace(Tf,(o,s)=>Je(r[s])):typeof t=="function"?t(r):t}static isError(t){return t&&t.name==="ValidationError"}constructor(t,r,n,o,s){const i=new Ns(t,r,n,o);if(s)return i;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[Fs]="Error",this.name=i.name,this.message=i.message,this.type=i.type,this.value=i.value,this.path=i.path,this.errors=i.errors,this.inner=i.inner,Error.captureStackTrace&&Error.captureStackTrace(this,Ce)}static[Ds](t){return Ns[Symbol.hasInstance](t)||super[Symbol.hasInstance](t)}}let Ze={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:r,originalValue:n})=>{const o=n!=null&&n!==r?` (cast from the value \`${Je(n,!0)}\`).`:".";return t!=="mixed"?`${e} must be a \`${t}\` type, but the final value was: \`${Je(r,!0)}\``+o:`${e} must match the configured type. The validated value was: \`${Je(r,!0)}\``+o}},Fe={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},dt={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},Un={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},Vn={isValue:"${path} field must be ${value}"},Ir={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"},kr={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},Ls={notType:e=>{const{path:t,value:r,spec:n}=e,o=n.types.length;if(Array.isArray(r)){if(r.length<o)return`${t} tuple value has too few items, expected a length of ${o} but got ${r.length} for value: \`${Je(r,!0)}\``;if(r.length>o)return`${t} tuple value has too many items, expected a length of ${o} but got ${r.length} for value: \`${Je(r,!0)}\``}return Ce.formatError(Ze.notType,e)}};var js=Object.assign(Object.create(null),{mixed:Ze,string:Fe,number:dt,date:Un,object:Ir,array:kr,boolean:Vn,tuple:Ls});const St=e=>e&&e.__isYupSchema__;class Mr{static fromOptions(t,r){if(!r.then&&!r.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:n,then:o,otherwise:s}=r,i=typeof n=="function"?n:(...a)=>a.every(c=>c===n);return new Mr(t,(a,c)=>{var u;let d=i(...a)?o:s;return(u=d==null?void 0:d(c))!=null?u:c})}constructor(t,r){this.fn=void 0,this.refs=t,this.refs=t,this.fn=r}resolve(t,r){let n=this.refs.map(s=>s.getValue(r==null?void 0:r.value,r==null?void 0:r.parent,r==null?void 0:r.context)),o=this.fn(n,t,r);if(o===void 0||o===t)return t;if(!St(o))throw new TypeError("conditions must return a schema object");return o.resolve(r)}}const Dr={context:"$",value:"."};function Sf(e,t){return new pt(e,t)}class pt{constructor(t,r={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof t!="string")throw new TypeError("ref must be a string, got: "+t);if(this.key=t.trim(),t==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===Dr.context,this.isValue=this.key[0]===Dr.value,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?Dr.context:this.isValue?Dr.value:"";this.path=this.key.slice(n.length),this.getter=this.path&&Tt.getter(this.path,!0),this.map=r.map}getValue(t,r,n){let o=this.isContext?n:this.isValue?t:r;return this.getter&&(o=this.getter(o||{})),this.map&&(o=this.map(o)),o}cast(t,r){return this.getValue(t,r==null?void 0:r.parent,r==null?void 0:r.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(t){return t&&t.__isYupRef}}pt.prototype.__isYupRef=!0;const He=e=>e==null;function Ot(e){function t({value:r,path:n="",options:o,originalValue:s,schema:i},a,c){const{name:u,test:d,params:f,message:p,skipAbsent:y}=e;let{parent:b,context:h,abortEarly:w=i.spec.abortEarly,disableStackTrace:E=i.spec.disableStackTrace}=o;function M(O){return pt.isRef(O)?O.getValue(r,b,h):O}function A(O={}){const B=Object.assign({value:r,originalValue:s,label:i.spec.label,path:O.path||n,spec:i.spec,disableStackTrace:O.disableStackTrace||E},f,O.params);for(const ee of Object.keys(B))B[ee]=M(B[ee]);const q=new Ce(Ce.formatError(O.message||p,B),r,B.path,O.type||u,B.disableStackTrace);return q.params=B,q}const _=w?a:c;let S={path:n,parent:b,type:u,from:o.from,createError:A,resolve:M,options:o,originalValue:s,schema:i};const P=O=>{Ce.isError(O)?_(O):O?c(null):_(A())},F=O=>{Ce.isError(O)?_(O):a(O)};if(y&&He(r))return P(!0);let z;try{var m;if(z=d.call(S,r,S),typeof((m=z)==null?void 0:m.then)=="function"){if(o.sync)throw new Error(`Validation test of type: "${S.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(z).then(P,F)}}catch(O){F(O);return}P(z)}return t.OPTIONS=e,t}function Wn(e,t,r,n=r){let o,s,i;return t?(Tt.forEach(t,(a,c,u)=>{let d=c?a.slice(1,a.length-1):a;e=e.resolve({context:n,parent:o,value:r});let f=e.type==="tuple",p=u?parseInt(d,10):0;if(e.innerType||f){if(f&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${i}" must contain an index to the tuple element, e.g. "${i}[0]"`);if(r&&p>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${t}. because there is no value at that index. `);o=r,r=r&&r[p],e=f?e.spec.types[p]:e.innerType}if(!u){if(!e.fields||!e.fields[d])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${i} which is a type: "${e.type}")`);o=r,r=r&&r[d],e=e.fields[d]}s=d,i=c?"["+a+"]":"."+a}),{schema:e,parent:o,parentPath:s}):{parent:o,parentPath:t,schema:e}}function _f(e,t,r,n){return Wn(e,t,r,n).schema}class Fr extends Set{describe(){const t=[];for(const r of this.values())t.push(pt.isRef(r)?r.describe():r);return t}resolveAll(t){let r=[];for(const n of this.values())r.push(t(n));return r}clone(){return new Fr(this.values())}merge(t,r){const n=this.clone();return t.forEach(o=>n.add(o)),r.forEach(o=>n.delete(o)),n}}function $t(e,t=new Map){if(St(e)||!e||typeof e!="object")return e;if(t.has(e))return t.get(e);let r;if(e instanceof Date)r=new Date(e.getTime()),t.set(e,r);else if(e instanceof RegExp)r=new RegExp(e),t.set(e,r);else if(Array.isArray(e)){r=new Array(e.length),t.set(e,r);for(let n=0;n<e.length;n++)r[n]=$t(e[n],t)}else if(e instanceof Map){r=new Map,t.set(e,r);for(const[n,o]of e.entries())r.set(n,$t(o,t))}else if(e instanceof Set){r=new Set,t.set(e,r);for(const n of e)r.add($t(n,t))}else if(e instanceof Object){r={},t.set(e,r);for(const[n,o]of Object.entries(e))r[n]=$t(o,t)}else throw Error(`Unable to clone ${e}`);return r}class Ae{constructor(t){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new Fr,this._blacklist=new Fr,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(Ze.notType)}),this.type=t.type,this._typeCheck=t.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},t==null?void 0:t.spec),this.withMutation(r=>{r.nonNullable()})}get _type(){return this.type}clone(t){if(this._mutate)return t&&Object.assign(this.spec,t),this;const r=Object.create(Object.getPrototypeOf(this));return r.type=this.type,r._typeCheck=this._typeCheck,r._whitelist=this._whitelist.clone(),r._blacklist=this._blacklist.clone(),r.internalTests=Object.assign({},this.internalTests),r.exclusiveTests=Object.assign({},this.exclusiveTests),r.deps=[...this.deps],r.conditions=[...this.conditions],r.tests=[...this.tests],r.transforms=[...this.transforms],r.spec=$t(Object.assign({},this.spec,t)),r}label(t){let r=this.clone();return r.spec.label=t,r}meta(...t){if(t.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},t[0]),r}withMutation(t){let r=this._mutate;this._mutate=!0;let n=t(this);return this._mutate=r,n}concat(t){if(!t||t===this)return this;if(t.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${t.type}`);let r=this,n=t.clone();const o=Object.assign({},r.spec,n.spec);return n.spec=o,n.internalTests=Object.assign({},r.internalTests,n.internalTests),n._whitelist=r._whitelist.merge(t._whitelist,t._blacklist),n._blacklist=r._blacklist.merge(t._blacklist,t._whitelist),n.tests=r.tests,n.exclusiveTests=r.exclusiveTests,n.withMutation(s=>{t.tests.forEach(i=>{s.test(i.OPTIONS)})}),n.transforms=[...r.transforms,...n.transforms],n}isType(t){return t==null?!!(this.spec.nullable&&t===null||this.spec.optional&&t===void 0):this._typeCheck(t)}resolve(t){let r=this;if(r.conditions.length){let n=r.conditions;r=r.clone(),r.conditions=[],r=n.reduce((o,s)=>s.resolve(o,t),r),r=r.resolve(t)}return r}resolveOptions(t){var r,n,o,s;return Object.assign({},t,{from:t.from||[],strict:(r=t.strict)!=null?r:this.spec.strict,abortEarly:(n=t.abortEarly)!=null?n:this.spec.abortEarly,recursive:(o=t.recursive)!=null?o:this.spec.recursive,disableStackTrace:(s=t.disableStackTrace)!=null?s:this.spec.disableStackTrace})}cast(t,r={}){let n=this.resolve(Object.assign({value:t},r)),o=r.assert==="ignore-optionality",s=n._cast(t,r);if(r.assert!==!1&&!n.isType(s)){if(o&&He(s))return s;let i=Je(t),a=Je(s);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${n.type}".
1
+ (function(I,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("react/jsx-runtime"),require("react-router-dom"),require("zustand"),require("@tanstack/react-query"),require("@mantine/hooks"),require("@mantine/core"),require("@mantine/form"),require("@mantine/dates"),require("@jsonforms/core"),require("@jsonforms/react"),require("clsx"),require("@emotion/react"),require("mantine-react-table")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-router-dom","zustand","@tanstack/react-query","@mantine/hooks","@mantine/core","@mantine/form","@mantine/dates","@jsonforms/core","@jsonforms/react","clsx","@emotion/react","mantine-react-table"],v):(I=typeof globalThis<"u"?globalThis:I||self,v(I["fastapi-rtk"]={},I.React,I.jsxRuntime,I.reactRouterDom,I.zustand,I.reactQuery,I.hooks,I.core,I.form,I.dates,I.core$1,I.react,I.clsx,I.react$1,I.mantineReactTable))})(this,function(I,v,l,ys,$u,rt,Te,g,sr,ut,H,ue,At,bs,yt){"use strict";var Ux=Object.defineProperty;var Vx=(I,v,l)=>v in I?Ux(I,v,{enumerable:!0,configurable:!0,writable:!0,value:l}):I[v]=l;var Ou=(I,v,l)=>Vx(I,typeof v!="symbol"?v+"":v,l);function Pu(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const $e=Pu(v),vs=v.createContext({path:"",data:null,info:null,queryParams:null,loading:!1,error:null,streaming:null,specialKey:null,setQueryParams:e=>null,refetch:()=>null,refetchInfo:()=>null,getEntry:async e=>({}),addEntry:async(e,t)=>({}),updateEntry:async(e,t,r)=>({}),deleteEntry:async(e,t)=>({}),download:async e=>null});function te(){const e=v.useContext(vs);if(e===void 0)throw new Error("useApi must be used within a ApiProvider");return e}function Pe({path:e,method:t,body:r=void 0,queryParams:n=void 0}){const o=Object.entries(n||{}).reduce((a,[c,u])=>((Array.isArray(u)||typeof u=="object")&&(u=JSON.stringify(u)),a[c]=u,a),{}),s=new ys.createSearchParams(o);e=e+"?"+s;const i={method:t,mode:"cors",credentials:"include",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:r?JSON.stringify(r):null};return{fetchPath:e,options:i}}function Iu(e){const t=[];if(e.length===0)return"";if(typeof e[0]!="string")throw new TypeError("Url must be a string. Received "+e[0]);e[0].match(/^[^/:]+:\/*$/)&&e.length>1&&(e[0]=e.shift()+e[0]),e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(let o=0;o<e.length;o++){let s=e[o];if(typeof s!="string")throw new TypeError("Url must be a string. Received "+s);s!==""&&(o>0&&(s=s.replace(/^[\/]+/,"")),o<e.length-1?s=s.replace(/[\/]+$/,""):s=s.replace(/[\/]+$/,"/"),t.push(s))}let r=t.join("/");r=r.replace(/\/(\?|&|#[^!])/g,"$1");const n=r.split("?");return r=n.shift()+(n.length>0?"?":"")+n.join("&"),r}function Se(...e){const t=Array.from(Array.isArray(e[0])?e[0]:e);return Iu(t)}const ku=e=>new Proxy(e,{get(t,r){return t(n=>n[r])}}),Mu=(e,t)=>Object.entries(t).reduce((r,[n,o])=>typeof o=="object"&&JSON.stringify(o)===JSON.stringify(e[n])||o===e[n]?r:{...r,[n]:o},{});function ir(e){const[t]=v.useState(()=>$u.create(()=>({...e}))),[r]=v.useState(()=>ku(t));return v.useEffect(()=>{t.setState(n=>Mu(n,e))},[e,t]),r}const Ts=v.createContext({user:null,loading:!1,error:null,signin:async(e,t)=>null,signout:async()=>null,update:async e=>null,resetPassword:async e=>null,oauth_signin:(e,t)=>null,refetch:async()=>null});function bt(){return v.useContext(Ts)}const Ss=v.createContext({baseUrl:"",info:null,loading:!1,error:null});function _s(){return v.useContext(Ss)}async function Du(e,{username:t,password:r}){const n=new FormData;n.append("username",t),n.append("password",r);const{fetchPath:o,options:s}=Pe({path:Se(e,"auth/login"),method:"POST"}),i=await fetch(o,{...s,headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(n)});if(!i.ok)throw i.status===400?new Error("Username or password wrong."):new Error("Failed to sign in.")}async function Fu(e){const{fetchPath:t,options:r}=Pe({path:Se(e,"auth/logout"),method:"POST"});if(!(await fetch(t,r)).ok)throw new Error("Failed to sign out.")}async function Nu(e,t,{email:r}){const{fetchPath:n,options:o}=Pe({path:Se(e,"auth/forgot-password"),method:"POST",body:{email:r}}),s=await fetch(n,o);if(!s.ok)throw new Error("Couldn't request token to reset password");const i=await s.json(),{token:a}=i,{fetchPath:c,options:u}=Pe({path:Se(e,"auth/reset-password"),method:"POST",body:{token:a,password:t}});if(!(await fetch(c,u)).ok)throw new Error("Couldn't reset password")}async function Lu(e,t,r,n){const o=Se(e,"auth/login",t);if(!r){window.location.href=Se(e,"auth/login",t);return}const s=500,i=500,a=window.screenLeft+window.outerWidth/2-s/2,c=window.screenTop+window.outerHeight/2-i/2,u=window.open(o+"?popup=true","auth",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${s}, height=${i}, top=${c}, left=${a}`),d=window.setInterval(function(){u.closed!==!1&&(window.clearInterval(d),n==null||n())},200)}async function ju(e,t){const{fetchPath:r,options:n}=Pe({path:Se(e,"info/"),method:"GET"}),o=await fetch(r,{signal:t,...n}),s=await o.json();if(!o.ok){const i=typeof s.detail=="string"?s.detail:JSON.stringify(s.detail,null,2);throw new Error(i)}return s}async function zu(e,t){const{fetchPath:r,options:n}=Pe({path:Se(e,"auth/user"),method:"GET"}),o=await fetch(r,{signal:t,...n}),s=await o.json();if(!o.ok){const i=typeof s.detail=="string"?s.detail:JSON.stringify(s.detail,null,2);throw new Error(i)}return s}async function Bu(e,t){const{fetchPath:r,options:n}=Pe({path:Se(e,"auth/user"),method:"PUT",body:t}),o=await fetch(r,n),s=await o.json();if(!o.ok){const i=typeof s.detail=="string"?s.detail:JSON.stringify(s.detail,null,2);throw new Error(i)}return s}function Uu(e){const t=rt.useQueryClient(),r=rt.useQuery({queryKey:["user"],queryFn:({signal:d})=>zu(e,d),retry:0}),[n,o]=v.useState(null),s=v.useCallback(({username:d,password:f})=>{o(null),Du(e,{username:d,password:f}).then(()=>t.invalidateQueries({queryKey:["user"]})).catch(p=>o(p))},[e,t]),i=v.useCallback(()=>{o(null),Fu(e).then(()=>t.resetQueries({queryKey:["user"]})).then(()=>t.resetQueries({queryKey:["info"]})).catch(d=>o(d))},[e,t]),a=v.useCallback(d=>{o(null),Bu(e,d).then(()=>t.invalidateQueries({queryKey:["user"]})).catch(f=>o(f))},[e,t]),c=v.useCallback(d=>{o(null),Nu(e,d,r.data).catch(f=>o(f))},[e,r.data]),u=v.useCallback((d,f)=>Lu(e,d,f,()=>t.invalidateQueries({queryKey:["user"]})),[e,t]);return{user:r.isError?null:r.data,loading:r.isFetching,error:n?n.message:null,signin:s,signout:i,update:a,resetPassword:c,oauth_signin:u,refetch:r.refetch}}function Vu(e,t){const r=rt.useQuery({queryKey:["info"],queryFn:({signal:n})=>ju(e,n),enabled:!1});return v.useEffect(()=>{t.user&&!r.data&&r.refetch()},[t.user,r]),{baseUrl:e,info:r.data,loading:r.isFetching,error:r.error}}function Wu(e){const t={baseUrl:new URL(document.baseURI).pathname+"/api/v1",inheritMantineTheme:!1},{baseUrl:r,children:n}={...t,...e},o=Uu(r),s=ir(o),i=Vu(r,o),a=ir(i);return l.jsx(Ts.Provider,{value:s,children:l.jsx(Ss.Provider,{value:a,children:n})})}function Gu(e){const[t]=v.useState(()=>new rt.QueryClient);return l.jsx(rt.QueryClientProvider,{client:t,children:l.jsx(Wu,{...e})})}const ws=v.createContext({bulkActions:{selectedIds:[],setSelectedIds:()=>{}},dispatchBulkActions:async(e,t)=>{},error:null});function Hu(){const e=v.useContext(ws);if(e===void 0)throw new Error("useBulkActions must be used within a ApiProvider");return e}const Yu=async(e,t)=>{const{fetchPath:r,options:n}=Pe({path:Se(e,"/"),method:"POST",body:t}),o=await fetch(r,n);let s=null;const i=o.headers.get("content-type");if(i&&i.includes("application/json")?s=await o.json():s=await o.text(),!o.ok)throw typeof s=="object"?new Error(typeof s.detail=="string"?s.detail:JSON.stringify(s,null,2)):new Error(s);return s},qu=async(e,t)=>{const{fetchPath:r,options:n}=Pe({path:Se(e,t.toString()),method:"DELETE"}),o=await fetch(r,n);let s=null;const i=o.headers.get("content-type");if(i&&i.includes("application/json")?s=await o.json():s=await o.text(),!o.ok)throw typeof s=="object"?new Error(typeof s.detail=="string"?s.detail:JSON.stringify(s,null,2)):new Error(s);return s},Ku=async(e,t)=>{const{fetchPath:r,options:n}=Pe({path:e,method:"GET"}),o=await fetch(r,{signal:t,...n}),s=await o.json();if(!o.ok){const i=typeof s.detail=="string"?s.detail:JSON.stringify(s.detail,null,2);throw new Error(i)}return s},Ju=async(e,t)=>{const{fetchPath:r,options:n}=Pe({path:Se(e,t.toString()),method:"GET"}),o=await fetch(r,n);let s=null;const i=o.headers.get("content-type");if(i&&i.includes("application/json")?s=await o.json():s=await o.text(),!o.ok)throw typeof s=="object"?new Error(typeof s.detail=="string"?s.detail:JSON.stringify(s,null,2)):new Error(s);return s},Zu=async(e,t,r)=>{const{fetchPath:n,options:o}=Pe({path:e,method:"GET",queryParams:t}),s=await fetch(n,{signal:r,...o});let i=null;const a=s.headers.get("content-type");if(a&&a.includes("application/json")?i=await s.json():i=await s.text(),!s.ok)throw typeof i=="object"?new Error(typeof i.detail=="string"?i.detail:JSON.stringify(i,null,2)):new Error(i);return i},Xu=async(e,t,r)=>{const{fetchPath:n,options:o}=Pe({path:Se(e,t.toString()),method:"PUT",body:r}),s=await fetch(n,o);let i=null;const a=s.headers.get("content-type");if(a&&a.includes("application/json")?i=await s.json():i=await s.text(),!s.ok)throw typeof i=="object"?new Error(typeof i.detail=="string"?i.detail:JSON.stringify(i,null,2)):new Error(i);return i},je=e=>e&&typeof e=="object"?Array.isArray(e)?e.join(","):JSON.stringify(e):e,Qu={columns:[],filters:[],page:0,page_size:25};function Ar(e,t={}){return Object.entries(t).reduce((r,[n,o])=>o==null?(delete r[n],r):{...r,[n]:o},e||Qu)}const Cs=e=>{const t={};for(const r of e)switch(r.type){case"RelatedList":t[r.name]=[];break;case"Boolean":t[r.name]="false";break;case"Date":case"DateTime":case"Integer":case"Float":case"Geometry":case"Raw":case"Related":t[r.name]=void 0;break;default:t[r.name]=""}return t};var Or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ft(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function vt(e){this._maxSize=e,this.clear()}vt.prototype.clear=function(){this._size=0,this._values=Object.create(null)},vt.prototype.get=function(e){return this._values[e]},vt.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var Ru=/[^.^\]^[]+|(?=\[\]|\.\.)/g,Es=/^\d+$/,ef=/^\d/,tf=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,rf=/^\s*(['"]?)(.*?)(\1)\s*$/,Dn=512,xs=new vt(Dn),As=new vt(Dn),Os=new vt(Dn),Tt={Cache:vt,split:Nn,normalizePath:Fn,setter:function(e){var t=Fn(e);return As.get(e)||As.set(e,function(n,o){for(var s=0,i=t.length,a=n;s<i-1;){var c=t[s];if(c==="__proto__"||c==="constructor"||c==="prototype")return n;a=a[t[s++]]}a[t[s]]=o})},getter:function(e,t){var r=Fn(e);return Os.get(e)||Os.set(e,function(o){for(var s=0,i=r.length;s<i;)if(o!=null||!t)o=o[r[s++]];else return;return o})},join:function(e){return e.reduce(function(t,r){return t+(Ln(r)||Es.test(r)?"["+r+"]":(t?".":"")+r)},"")},forEach:function(e,t,r){nf(Array.isArray(e)?e:Nn(e),t,r)}};function Fn(e){return xs.get(e)||xs.set(e,Nn(e).map(function(t){return t.replace(rf,"$2")}))}function Nn(e){return e.match(Ru)||[""]}function nf(e,t,r){var n=e.length,o,s,i,a;for(s=0;s<n;s++)o=e[s],o&&(af(o)&&(o='"'+o+'"'),a=Ln(o),i=!a&&/^\d+$/.test(o),t.call(r,o,a,i,s,e))}function Ln(e){return typeof e=="string"&&e&&["'",'"'].indexOf(e.charAt(0))!==-1}function of(e){return e.match(ef)&&!e.match(Es)}function sf(e){return tf.test(e)}function af(e){return!Ln(e)&&(of(e)||sf(e))}const lf=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,$r=e=>e.match(lf)||[],Pr=e=>e[0].toUpperCase()+e.slice(1),jn=(e,t)=>$r(e).join(t).toLowerCase(),$s=e=>$r(e).reduce((t,r)=>`${t}${t?r[0].toUpperCase()+r.slice(1).toLowerCase():r.toLowerCase()}`,"");var zn={words:$r,upperFirst:Pr,camelCase:$s,pascalCase:e=>Pr($s(e)),snakeCase:e=>jn(e,"_"),kebabCase:e=>jn(e,"-"),sentenceCase:e=>Pr(jn(e," ")),titleCase:e=>$r(e).map(Pr).join(" ")},Bn={exports:{}};Bn.exports=function(e){return Ps(cf(e),e)},Bn.exports.array=Ps;function Ps(e,t){var r=e.length,n=new Array(r),o={},s=r,i=uf(t),a=ff(e);for(t.forEach(function(u){if(!a.has(u[0])||!a.has(u[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});s--;)o[s]||c(e[s],s,new Set);return n;function c(u,d,f){if(f.has(u)){var p;try{p=", node was:"+JSON.stringify(u)}catch{p=""}throw new Error("Cyclic dependency"+p)}if(!a.has(u))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(u));if(!o[d]){o[d]=!0;var y=i.get(u)||new Set;if(y=Array.from(y),d=y.length){f.add(u);do{var b=y[--d];c(b,a.get(b),f)}while(d);f.delete(u)}n[--r]=u}}}function cf(e){for(var t=new Set,r=0,n=e.length;r<n;r++){var o=e[r];t.add(o[0]),t.add(o[1])}return Array.from(t)}function uf(e){for(var t=new Map,r=0,n=e.length;r<n;r++){var o=e[r];t.has(o[0])||t.set(o[0],new Set),t.has(o[1])||t.set(o[1],new Set),t.get(o[0]).add(o[1])}return t}function ff(e){for(var t=new Map,r=0,n=e.length;r<n;r++)t.set(e[r],r);return t}var df=Bn.exports;const pf=ft(df),hf=Object.prototype.toString,gf=Error.prototype.toString,mf=RegExp.prototype.toString,yf=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",bf=/^Symbol\((.*)\)(.*)$/;function vf(e){return e!=+e?"NaN":e===0&&1/e<0?"-0":""+e}function Is(e,t=!1){if(e==null||e===!0||e===!1)return""+e;const r=typeof e;if(r==="number")return vf(e);if(r==="string")return t?`"${e}"`:e;if(r==="function")return"[Function "+(e.name||"anonymous")+"]";if(r==="symbol")return yf.call(e).replace(bf,"Symbol($1)");const n=hf.call(e).slice(8,-1);return n==="Date"?isNaN(e.getTime())?""+e:e.toISOString(e):n==="Error"||e instanceof Error?"["+gf.call(e)+"]":n==="RegExp"?mf.call(e):null}function Je(e,t){let r=Is(e,t);return r!==null?r:JSON.stringify(e,function(n,o){let s=Is(this[n],t);return s!==null?s:o},2)}function ks(e){return e==null?[]:[].concat(e)}let Ms,Ds,Fs,Tf=/\$\{\s*(\w+)\s*\}/g;Ms=Symbol.toStringTag;class Ns{constructor(t,r,n,o){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[Ms]="Error",this.name="ValidationError",this.value=r,this.path=n,this.type=o,this.errors=[],this.inner=[],ks(t).forEach(s=>{if(Ce.isError(s)){this.errors.push(...s.errors);const i=s.inner.length?s.inner:[s];this.inner.push(...i)}else this.errors.push(s)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}Ds=Symbol.hasInstance,Fs=Symbol.toStringTag;class Ce extends Error{static formatError(t,r){const n=r.label||r.path||"this";return r=Object.assign({},r,{path:n,originalPath:r.path}),typeof t=="string"?t.replace(Tf,(o,s)=>Je(r[s])):typeof t=="function"?t(r):t}static isError(t){return t&&t.name==="ValidationError"}constructor(t,r,n,o,s){const i=new Ns(t,r,n,o);if(s)return i;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[Fs]="Error",this.name=i.name,this.message=i.message,this.type=i.type,this.value=i.value,this.path=i.path,this.errors=i.errors,this.inner=i.inner,Error.captureStackTrace&&Error.captureStackTrace(this,Ce)}static[Ds](t){return Ns[Symbol.hasInstance](t)||super[Symbol.hasInstance](t)}}let Ze={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:r,originalValue:n})=>{const o=n!=null&&n!==r?` (cast from the value \`${Je(n,!0)}\`).`:".";return t!=="mixed"?`${e} must be a \`${t}\` type, but the final value was: \`${Je(r,!0)}\``+o:`${e} must match the configured type. The validated value was: \`${Je(r,!0)}\``+o}},Fe={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},dt={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},Un={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},Vn={isValue:"${path} field must be ${value}"},Ir={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"},kr={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},Ls={notType:e=>{const{path:t,value:r,spec:n}=e,o=n.types.length;if(Array.isArray(r)){if(r.length<o)return`${t} tuple value has too few items, expected a length of ${o} but got ${r.length} for value: \`${Je(r,!0)}\``;if(r.length>o)return`${t} tuple value has too many items, expected a length of ${o} but got ${r.length} for value: \`${Je(r,!0)}\``}return Ce.formatError(Ze.notType,e)}};var js=Object.assign(Object.create(null),{mixed:Ze,string:Fe,number:dt,date:Un,object:Ir,array:kr,boolean:Vn,tuple:Ls});const St=e=>e&&e.__isYupSchema__;class Mr{static fromOptions(t,r){if(!r.then&&!r.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:n,then:o,otherwise:s}=r,i=typeof n=="function"?n:(...a)=>a.every(c=>c===n);return new Mr(t,(a,c)=>{var u;let d=i(...a)?o:s;return(u=d==null?void 0:d(c))!=null?u:c})}constructor(t,r){this.fn=void 0,this.refs=t,this.refs=t,this.fn=r}resolve(t,r){let n=this.refs.map(s=>s.getValue(r==null?void 0:r.value,r==null?void 0:r.parent,r==null?void 0:r.context)),o=this.fn(n,t,r);if(o===void 0||o===t)return t;if(!St(o))throw new TypeError("conditions must return a schema object");return o.resolve(r)}}const Dr={context:"$",value:"."};function Sf(e,t){return new pt(e,t)}class pt{constructor(t,r={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof t!="string")throw new TypeError("ref must be a string, got: "+t);if(this.key=t.trim(),t==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===Dr.context,this.isValue=this.key[0]===Dr.value,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?Dr.context:this.isValue?Dr.value:"";this.path=this.key.slice(n.length),this.getter=this.path&&Tt.getter(this.path,!0),this.map=r.map}getValue(t,r,n){let o=this.isContext?n:this.isValue?t:r;return this.getter&&(o=this.getter(o||{})),this.map&&(o=this.map(o)),o}cast(t,r){return this.getValue(t,r==null?void 0:r.parent,r==null?void 0:r.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(t){return t&&t.__isYupRef}}pt.prototype.__isYupRef=!0;const He=e=>e==null;function Ot(e){function t({value:r,path:n="",options:o,originalValue:s,schema:i},a,c){const{name:u,test:d,params:f,message:p,skipAbsent:y}=e;let{parent:b,context:h,abortEarly:w=i.spec.abortEarly,disableStackTrace:E=i.spec.disableStackTrace}=o;function M(O){return pt.isRef(O)?O.getValue(r,b,h):O}function A(O={}){const B=Object.assign({value:r,originalValue:s,label:i.spec.label,path:O.path||n,spec:i.spec,disableStackTrace:O.disableStackTrace||E},f,O.params);for(const ee of Object.keys(B))B[ee]=M(B[ee]);const q=new Ce(Ce.formatError(O.message||p,B),r,B.path,O.type||u,B.disableStackTrace);return q.params=B,q}const _=w?a:c;let S={path:n,parent:b,type:u,from:o.from,createError:A,resolve:M,options:o,originalValue:s,schema:i};const P=O=>{Ce.isError(O)?_(O):O?c(null):_(A())},F=O=>{Ce.isError(O)?_(O):a(O)};if(y&&He(r))return P(!0);let z;try{var m;if(z=d.call(S,r,S),typeof((m=z)==null?void 0:m.then)=="function"){if(o.sync)throw new Error(`Validation test of type: "${S.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(z).then(P,F)}}catch(O){F(O);return}P(z)}return t.OPTIONS=e,t}function Wn(e,t,r,n=r){let o,s,i;return t?(Tt.forEach(t,(a,c,u)=>{let d=c?a.slice(1,a.length-1):a;e=e.resolve({context:n,parent:o,value:r});let f=e.type==="tuple",p=u?parseInt(d,10):0;if(e.innerType||f){if(f&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${i}" must contain an index to the tuple element, e.g. "${i}[0]"`);if(r&&p>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${t}. because there is no value at that index. `);o=r,r=r&&r[p],e=f?e.spec.types[p]:e.innerType}if(!u){if(!e.fields||!e.fields[d])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${i} which is a type: "${e.type}")`);o=r,r=r&&r[d],e=e.fields[d]}s=d,i=c?"["+a+"]":"."+a}),{schema:e,parent:o,parentPath:s}):{parent:o,parentPath:t,schema:e}}function _f(e,t,r,n){return Wn(e,t,r,n).schema}class Fr extends Set{describe(){const t=[];for(const r of this.values())t.push(pt.isRef(r)?r.describe():r);return t}resolveAll(t){let r=[];for(const n of this.values())r.push(t(n));return r}clone(){return new Fr(this.values())}merge(t,r){const n=this.clone();return t.forEach(o=>n.add(o)),r.forEach(o=>n.delete(o)),n}}function $t(e,t=new Map){if(St(e)||!e||typeof e!="object")return e;if(t.has(e))return t.get(e);let r;if(e instanceof Date)r=new Date(e.getTime()),t.set(e,r);else if(e instanceof RegExp)r=new RegExp(e),t.set(e,r);else if(Array.isArray(e)){r=new Array(e.length),t.set(e,r);for(let n=0;n<e.length;n++)r[n]=$t(e[n],t)}else if(e instanceof Map){r=new Map,t.set(e,r);for(const[n,o]of e.entries())r.set(n,$t(o,t))}else if(e instanceof Set){r=new Set,t.set(e,r);for(const n of e)r.add($t(n,t))}else if(e instanceof Object){r={},t.set(e,r);for(const[n,o]of Object.entries(e))r[n]=$t(o,t)}else throw Error(`Unable to clone ${e}`);return r}class Ae{constructor(t){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new Fr,this._blacklist=new Fr,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(Ze.notType)}),this.type=t.type,this._typeCheck=t.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},t==null?void 0:t.spec),this.withMutation(r=>{r.nonNullable()})}get _type(){return this.type}clone(t){if(this._mutate)return t&&Object.assign(this.spec,t),this;const r=Object.create(Object.getPrototypeOf(this));return r.type=this.type,r._typeCheck=this._typeCheck,r._whitelist=this._whitelist.clone(),r._blacklist=this._blacklist.clone(),r.internalTests=Object.assign({},this.internalTests),r.exclusiveTests=Object.assign({},this.exclusiveTests),r.deps=[...this.deps],r.conditions=[...this.conditions],r.tests=[...this.tests],r.transforms=[...this.transforms],r.spec=$t(Object.assign({},this.spec,t)),r}label(t){let r=this.clone();return r.spec.label=t,r}meta(...t){if(t.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},t[0]),r}withMutation(t){let r=this._mutate;this._mutate=!0;let n=t(this);return this._mutate=r,n}concat(t){if(!t||t===this)return this;if(t.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${t.type}`);let r=this,n=t.clone();const o=Object.assign({},r.spec,n.spec);return n.spec=o,n.internalTests=Object.assign({},r.internalTests,n.internalTests),n._whitelist=r._whitelist.merge(t._whitelist,t._blacklist),n._blacklist=r._blacklist.merge(t._blacklist,t._whitelist),n.tests=r.tests,n.exclusiveTests=r.exclusiveTests,n.withMutation(s=>{t.tests.forEach(i=>{s.test(i.OPTIONS)})}),n.transforms=[...r.transforms,...n.transforms],n}isType(t){return t==null?!!(this.spec.nullable&&t===null||this.spec.optional&&t===void 0):this._typeCheck(t)}resolve(t){let r=this;if(r.conditions.length){let n=r.conditions;r=r.clone(),r.conditions=[],r=n.reduce((o,s)=>s.resolve(o,t),r),r=r.resolve(t)}return r}resolveOptions(t){var r,n,o,s;return Object.assign({},t,{from:t.from||[],strict:(r=t.strict)!=null?r:this.spec.strict,abortEarly:(n=t.abortEarly)!=null?n:this.spec.abortEarly,recursive:(o=t.recursive)!=null?o:this.spec.recursive,disableStackTrace:(s=t.disableStackTrace)!=null?s:this.spec.disableStackTrace})}cast(t,r={}){let n=this.resolve(Object.assign({value:t},r)),o=r.assert==="ignore-optionality",s=n._cast(t,r);if(r.assert!==!1&&!n.isType(s)){if(o&&He(s))return s;let i=Je(t),a=Je(s);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${n.type}".
2
2
 
3
3
  attempted value: ${i}
4
4
  `+(a!==i?`result of cast: ${a}`:""))}return s}_cast(t,r){let n=t===void 0?t:this.transforms.reduce((o,s)=>s.call(this,o,t,this),t);return n===void 0&&(n=this.getDefault(r)),n}_validate(t,r={},n,o){let{path:s,originalValue:i=t,strict:a=this.spec.strict}=r,c=t;a||(c=this._cast(c,Object.assign({assert:!1},r)));let u=[];for(let d of Object.values(this.internalTests))d&&u.push(d);this.runTests({path:s,value:c,originalValue:i,options:r,tests:u},n,d=>{if(d.length)return o(d,c);this.runTests({path:s,value:c,originalValue:i,options:r,tests:this.tests},n,o)})}runTests(t,r,n){let o=!1,{tests:s,value:i,originalValue:a,path:c,options:u}=t,d=h=>{o||(o=!0,r(h,i))},f=h=>{o||(o=!0,n(h,i))},p=s.length,y=[];if(!p)return f([]);let b={value:i,originalValue:a,path:c,options:u,schema:this};for(let h=0;h<s.length;h++){const w=s[h];w(b,d,function(M){M&&(Array.isArray(M)?y.push(...M):y.push(M)),--p<=0&&f(y)})}}asNestedTest({key:t,index:r,parent:n,parentPath:o,originalParent:s,options:i}){const a=t??r;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const c=typeof a=="number";let u=n[a];const d=Object.assign({},i,{strict:!0,parent:n,value:u,originalValue:s[a],key:void 0,[c?"index":"key"]:a,path:c||a.includes(".")?`${o||""}[${c?a:`"${a}"`}]`:(o?`${o}.`:"")+t});return(f,p,y)=>this.resolve(d)._validate(u,d,p,y)}validate(t,r){var n;let o=this.resolve(Object.assign({},r,{value:t})),s=(n=r==null?void 0:r.disableStackTrace)!=null?n:o.spec.disableStackTrace;return new Promise((i,a)=>o._validate(t,r,(c,u)=>{Ce.isError(c)&&(c.value=u),a(c)},(c,u)=>{c.length?a(new Ce(c,u,void 0,void 0,s)):i(u)}))}validateSync(t,r){var n;let o=this.resolve(Object.assign({},r,{value:t})),s,i=(n=r==null?void 0:r.disableStackTrace)!=null?n:o.spec.disableStackTrace;return o._validate(t,Object.assign({},r,{sync:!0}),(a,c)=>{throw Ce.isError(a)&&(a.value=c),a},(a,c)=>{if(a.length)throw new Ce(a,t,void 0,void 0,i);s=c}),s}isValid(t,r){return this.validate(t,r).then(()=>!0,n=>{if(Ce.isError(n))return!1;throw n})}isValidSync(t,r){try{return this.validateSync(t,r),!0}catch(n){if(Ce.isError(n))return!1;throw n}}_getDefault(t){let r=this.spec.default;return r==null?r:typeof r=="function"?r.call(this,t):$t(r)}getDefault(t){return this.resolve(t||{})._getDefault(t)}default(t){return arguments.length===0?this._getDefault():this.clone({default:t})}strict(t=!0){return this.clone({strict:t})}nullability(t,r){const n=this.clone({nullable:t});return n.internalTests.nullable=Ot({message:r,name:"nullable",test(o){return o===null?this.schema.spec.nullable:!0}}),n}optionality(t,r){const n=this.clone({optional:t});return n.internalTests.optionality=Ot({message:r,name:"optionality",test(o){return o===void 0?this.schema.spec.optional:!0}}),n}optional(){return this.optionality(!0)}defined(t=Ze.defined){return this.optionality(!1,t)}nullable(){return this.nullability(!0)}nonNullable(t=Ze.notNull){return this.nullability(!1,t)}required(t=Ze.required){return this.clone().withMutation(r=>r.nonNullable(t).defined(t))}notRequired(){return this.clone().withMutation(t=>t.nullable().optional())}transform(t){let r=this.clone();return r.transforms.push(t),r}test(...t){let r;if(t.length===1?typeof t[0]=="function"?r={test:t[0]}:r=t[0]:t.length===2?r={name:t[0],test:t[1]}:r={name:t[0],message:t[1],test:t[2]},r.message===void 0&&(r.message=Ze.default),typeof r.test!="function")throw new TypeError("`test` is a required parameters");let n=this.clone(),o=Ot(r),s=r.exclusive||r.name&&n.exclusiveTests[r.name]===!0;if(r.exclusive&&!r.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return r.name&&(n.exclusiveTests[r.name]=!!r.exclusive),n.tests=n.tests.filter(i=>!(i.OPTIONS.name===r.name&&(s||i.OPTIONS.test===o.OPTIONS.test))),n.tests.push(o),n}when(t,r){!Array.isArray(t)&&typeof t!="string"&&(r=t,t=".");let n=this.clone(),o=ks(t).map(s=>new pt(s));return o.forEach(s=>{s.isSibling&&n.deps.push(s.key)}),n.conditions.push(typeof r=="function"?new Mr(o,r):Mr.fromOptions(o,r)),n}typeError(t){let r=this.clone();return r.internalTests.typeError=Ot({message:t,name:"typeError",skipAbsent:!0,test(n){return this.schema._typeCheck(n)?!0:this.createError({params:{type:this.schema.type}})}}),r}oneOf(t,r=Ze.oneOf){let n=this.clone();return t.forEach(o=>{n._whitelist.add(o),n._blacklist.delete(o)}),n.internalTests.whiteList=Ot({message:r,name:"oneOf",skipAbsent:!0,test(o){let s=this.schema._whitelist,i=s.resolveAll(this.resolve);return i.includes(o)?!0:this.createError({params:{values:Array.from(s).join(", "),resolved:i}})}}),n}notOneOf(t,r=Ze.notOneOf){let n=this.clone();return t.forEach(o=>{n._blacklist.add(o),n._whitelist.delete(o)}),n.internalTests.blacklist=Ot({message:r,name:"notOneOf",test(o){let s=this.schema._blacklist,i=s.resolveAll(this.resolve);return i.includes(o)?this.createError({params:{values:Array.from(s).join(", "),resolved:i}}):!0}}),n}strip(t=!0){let r=this.clone();return r.spec.strip=t,r}describe(t){const r=(t?this.resolve(t):this).clone(),{label:n,meta:o,optional:s,nullable:i}=r.spec;return{meta:o,label:n,optional:s,nullable:i,default:r.getDefault(t),type:r.type,oneOf:r._whitelist.describe(),notOneOf:r._blacklist.describe(),tests:r.tests.map(c=>({name:c.OPTIONS.name,params:c.OPTIONS.params})).filter((c,u,d)=>d.findIndex(f=>f.name===c.name)===u)}}}Ae.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])Ae.prototype[`${e}At`]=function(t,r,n={}){const{parent:o,parentPath:s,schema:i}=Wn(this,t,r,n.context);return i[e](o&&o[s],Object.assign({},n,{parent:o,path:t}))};for(const e of["equals","is"])Ae.prototype[e]=Ae.prototype.oneOf;for(const e of["not","nope"])Ae.prototype[e]=Ae.prototype.notOneOf;const wf=()=>!0;function Nr(e){return new Gn(e)}class Gn extends Ae{constructor(t){super(typeof t=="function"?{type:"mixed",check:t}:Object.assign({type:"mixed",check:wf},t))}}Nr.prototype=Gn.prototype;function Hn(){return new Yn}class Yn extends Ae{constructor(){super({type:"boolean",check(t){return t instanceof Boolean&&(t=t.valueOf()),typeof t=="boolean"}}),this.withMutation(()=>{this.transform((t,r,n)=>{if(n.spec.coerce&&!n.isType(t)){if(/^(true|1)$/i.test(String(t)))return!0;if(/^(false|0)$/i.test(String(t)))return!1}return t})})}isTrue(t=Vn.isValue){return this.test({message:t,name:"is-value",exclusive:!0,params:{value:"true"},test(r){return He(r)||r===!0}})}isFalse(t=Vn.isValue){return this.test({message:t,name:"is-value",exclusive:!0,params:{value:"false"},test(r){return He(r)||r===!1}})}default(t){return super.default(t)}defined(t){return super.defined(t)}optional(){return super.optional()}required(t){return super.required(t)}notRequired(){return super.notRequired()}nullable(){return super.nullable()}nonNullable(t){return super.nonNullable(t)}strip(t){return super.strip(t)}}Hn.prototype=Yn.prototype;const Cf=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function Ef(e){const t=qn(e);if(!t)return Date.parse?Date.parse(e):Number.NaN;if(t.z===void 0&&t.plusMinus===void 0)return new Date(t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond).valueOf();let r=0;return t.z!=="Z"&&t.plusMinus!==void 0&&(r=t.hourOffset*60+t.minuteOffset,t.plusMinus==="+"&&(r=0-r)),Date.UTC(t.year,t.month,t.day,t.hour,t.minute+r,t.second,t.millisecond)}function qn(e){var t,r;const n=Cf.exec(e);return n?{year:nt(n[1]),month:nt(n[2],1)-1,day:nt(n[3],1),hour:nt(n[4]),minute:nt(n[5]),second:nt(n[6]),millisecond:n[7]?nt(n[7].substring(0,3)):0,precision:(t=(r=n[7])==null?void 0:r.length)!=null?t:void 0,z:n[8]||void 0,plusMinus:n[9]||void 0,hourOffset:nt(n[10]),minuteOffset:nt(n[11])}:null}function nt(e,t=0){return Number(e)||t}let xf=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[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])?)*$/,Af=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,Of=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,$f="^\\d{4}-\\d{2}-\\d{2}",Pf="\\d{2}:\\d{2}:\\d{2}",If="(([+-]\\d{2}(:?\\d{2})?)|Z)",kf=new RegExp(`${$f}T${Pf}(\\.\\d+)?${If}$`),Mf=e=>He(e)||e===e.trim(),Df={}.toString();function Lr(){return new Kn}class Kn extends Ae{constructor(){super({type:"string",check(t){return t instanceof String&&(t=t.valueOf()),typeof t=="string"}}),this.withMutation(()=>{this.transform((t,r,n)=>{if(!n.spec.coerce||n.isType(t)||Array.isArray(t))return t;const o=t!=null&&t.toString?t.toString():t;return o===Df?t:o})})}required(t){return super.required(t).withMutation(r=>r.test({message:t||Ze.required,name:"required",skipAbsent:!0,test:n=>!!n.length}))}notRequired(){return super.notRequired().withMutation(t=>(t.tests=t.tests.filter(r=>r.OPTIONS.name!=="required"),t))}length(t,r=Fe.length){return this.test({message:r,name:"length",exclusive:!0,params:{length:t},skipAbsent:!0,test(n){return n.length===this.resolve(t)}})}min(t,r=Fe.min){return this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(n){return n.length>=this.resolve(t)}})}max(t,r=Fe.max){return this.test({name:"max",exclusive:!0,message:r,params:{max:t},skipAbsent:!0,test(n){return n.length<=this.resolve(t)}})}matches(t,r){let n=!1,o,s;return r&&(typeof r=="object"?{excludeEmptyString:n=!1,message:o,name:s}=r:o=r),this.test({name:s||"matches",message:o||Fe.matches,params:{regex:t},skipAbsent:!0,test:i=>i===""&&n||i.search(t)!==-1})}email(t=Fe.email){return this.matches(xf,{name:"email",message:t,excludeEmptyString:!0})}url(t=Fe.url){return this.matches(Af,{name:"url",message:t,excludeEmptyString:!0})}uuid(t=Fe.uuid){return this.matches(Of,{name:"uuid",message:t,excludeEmptyString:!1})}datetime(t){let r="",n,o;return t&&(typeof t=="object"?{message:r="",allowOffset:n=!1,precision:o=void 0}=t:r=t),this.matches(kf,{name:"datetime",message:r||Fe.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:r||Fe.datetime_offset,params:{allowOffset:n},skipAbsent:!0,test:s=>{if(!s||n)return!0;const i=qn(s);return i?!!i.z:!1}}).test({name:"datetime_precision",message:r||Fe.datetime_precision,params:{precision:o},skipAbsent:!0,test:s=>{if(!s||o==null)return!0;const i=qn(s);return i?i.precision===o:!1}})}ensure(){return this.default("").transform(t=>t===null?"":t)}trim(t=Fe.trim){return this.transform(r=>r!=null?r.trim():r).test({message:t,name:"trim",test:Mf})}lowercase(t=Fe.lowercase){return this.transform(r=>He(r)?r:r.toLowerCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>He(r)||r===r.toLowerCase()})}uppercase(t=Fe.uppercase){return this.transform(r=>He(r)?r:r.toUpperCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>He(r)||r===r.toUpperCase()})}}Lr.prototype=Kn.prototype;let Ff=e=>e!=+e;function zs(){return new Jn}class Jn extends Ae{constructor(){super({type:"number",check(t){return t instanceof Number&&(t=t.valueOf()),typeof t=="number"&&!Ff(t)}}),this.withMutation(()=>{this.transform((t,r,n)=>{if(!n.spec.coerce)return t;let o=t;if(typeof o=="string"){if(o=o.replace(/\s/g,""),o==="")return NaN;o=+o}return n.isType(o)||o===null?o:parseFloat(o)})})}min(t,r=dt.min){return this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(n){return n>=this.resolve(t)}})}max(t,r=dt.max){return this.test({message:r,name:"max",exclusive:!0,params:{max:t},skipAbsent:!0,test(n){return n<=this.resolve(t)}})}lessThan(t,r=dt.lessThan){return this.test({message:r,name:"max",exclusive:!0,params:{less:t},skipAbsent:!0,test(n){return n<this.resolve(t)}})}moreThan(t,r=dt.moreThan){return this.test({message:r,name:"min",exclusive:!0,params:{more:t},skipAbsent:!0,test(n){return n>this.resolve(t)}})}positive(t=dt.positive){return this.moreThan(0,t)}negative(t=dt.negative){return this.lessThan(0,t)}integer(t=dt.integer){return this.test({name:"integer",message:t,skipAbsent:!0,test:r=>Number.isInteger(r)})}truncate(){return this.transform(t=>He(t)?t:t|0)}round(t){var r;let n=["ceil","floor","round","trunc"];if(t=((r=t)==null?void 0:r.toLowerCase())||"round",t==="trunc")return this.truncate();if(n.indexOf(t.toLowerCase())===-1)throw new TypeError("Only valid options for round() are: "+n.join(", "));return this.transform(o=>He(o)?o:Math[t](o))}}zs.prototype=Jn.prototype;let Bs=new Date(""),Nf=e=>Object.prototype.toString.call(e)==="[object Date]";function Zn(){return new Pt}class Pt extends Ae{constructor(){super({type:"date",check(t){return Nf(t)&&!isNaN(t.getTime())}}),this.withMutation(()=>{this.transform((t,r,n)=>!n.spec.coerce||n.isType(t)||t===null?t:(t=Ef(t),isNaN(t)?Pt.INVALID_DATE:new Date(t)))})}prepareParam(t,r){let n;if(pt.isRef(t))n=t;else{let o=this.cast(t);if(!this._typeCheck(o))throw new TypeError(`\`${r}\` must be a Date or a value that can be \`cast()\` to a Date`);n=o}return n}min(t,r=Un.min){let n=this.prepareParam(t,"min");return this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(o){return o>=this.resolve(n)}})}max(t,r=Un.max){let n=this.prepareParam(t,"max");return this.test({message:r,name:"max",exclusive:!0,params:{max:t},skipAbsent:!0,test(o){return o<=this.resolve(n)}})}}Pt.INVALID_DATE=Bs,Zn.prototype=Pt.prototype,Zn.INVALID_DATE=Bs;function Lf(e,t=[]){let r=[],n=new Set,o=new Set(t.map(([i,a])=>`${i}-${a}`));function s(i,a){let c=Tt.split(i)[0];n.add(c),o.has(`${a}-${c}`)||r.push([a,c])}for(const i of Object.keys(e)){let a=e[i];n.add(i),pt.isRef(a)&&a.isSibling?s(a.path,i):St(a)&&"deps"in a&&a.deps.forEach(c=>s(c,i))}return pf.array(Array.from(n),r).reverse()}function Us(e,t){let r=1/0;return e.some((n,o)=>{var s;if((s=t.path)!=null&&s.includes(n))return r=o,!0}),r}function Vs(e){return(t,r)=>Us(e,t)-Us(e,r)}const Ws=(e,t,r)=>{if(typeof e!="string")return e;let n=e;try{n=JSON.parse(e)}catch{}return r.isType(n)?n:e};function jr(e){if("fields"in e){const t={};for(const[r,n]of Object.entries(e.fields))t[r]=jr(n);return e.setFields(t)}if(e.type==="array"){const t=e.optional();return t.innerType&&(t.innerType=jr(t.innerType)),t}return e.type==="tuple"?e.optional().clone({types:e.spec.types.map(jr)}):"optional"in e?e.optional():e}const jf=(e,t)=>{const r=[...Tt.normalizePath(t)];if(r.length===1)return r[0]in e;let n=r.pop(),o=Tt.getter(Tt.join(r),!0)(e);return!!(o&&n in o)};let Gs=e=>Object.prototype.toString.call(e)==="[object Object]";function Hs(e,t){let r=Object.keys(e.fields);return Object.keys(t).filter(n=>r.indexOf(n)===-1)}const zf=Vs([]);function ar(e){return new Xn(e)}class Xn extends Ae{constructor(t){super({type:"object",check(r){return Gs(r)||typeof r=="function"}}),this.fields=Object.create(null),this._sortErrors=zf,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{t&&this.shape(t)})}_cast(t,r={}){var n;let o=super._cast(t,r);if(o===void 0)return this.getDefault(r);if(!this._typeCheck(o))return o;let s=this.fields,i=(n=r.stripUnknown)!=null?n:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(o).filter(f=>!this._nodes.includes(f))),c={},u=Object.assign({},r,{parent:c,__validating:r.__validating||!1}),d=!1;for(const f of a){let p=s[f],y=f in o;if(p){let b,h=o[f];u.path=(r.path?`${r.path}.`:"")+f,p=p.resolve({value:h,context:r.context,parent:c});let w=p instanceof Ae?p.spec:void 0,E=w==null?void 0:w.strict;if(w!=null&&w.strip){d=d||f in o;continue}b=!r.__validating||!E?p.cast(o[f],u):o[f],b!==void 0&&(c[f]=b)}else y&&!i&&(c[f]=o[f]);(y!==f in c||c[f]!==o[f])&&(d=!0)}return d?c:o}_validate(t,r={},n,o){let{from:s=[],originalValue:i=t,recursive:a=this.spec.recursive}=r;r.from=[{schema:this,value:i},...s],r.__validating=!0,r.originalValue=i,super._validate(t,r,n,(c,u)=>{if(!a||!Gs(u)){o(c,u);return}i=i||u;let d=[];for(let f of this._nodes){let p=this.fields[f];!p||pt.isRef(p)||d.push(p.asNestedTest({options:r,key:f,parent:u,parentPath:r.path,originalParent:i}))}this.runTests({tests:d,value:u,originalValue:i,options:r},n,f=>{o(f.sort(this._sortErrors).concat(c),u)})})}clone(t){const r=super.clone(t);return r.fields=Object.assign({},this.fields),r._nodes=this._nodes,r._excludedEdges=this._excludedEdges,r._sortErrors=this._sortErrors,r}concat(t){let r=super.concat(t),n=r.fields;for(let[o,s]of Object.entries(this.fields)){const i=n[o];n[o]=i===void 0?s:i}return r.withMutation(o=>o.setFields(n,[...this._excludedEdges,...t._excludedEdges]))}_getDefault(t){if("default"in this.spec)return super._getDefault(t);if(!this._nodes.length)return;let r={};return this._nodes.forEach(n=>{var o;const s=this.fields[n];let i=t;(o=i)!=null&&o.value&&(i=Object.assign({},i,{parent:i.value,value:i.value[n]})),r[n]=s&&"getDefault"in s?s.getDefault(i):void 0}),r}setFields(t,r){let n=this.clone();return n.fields=t,n._nodes=Lf(t,r),n._sortErrors=Vs(Object.keys(t)),r&&(n._excludedEdges=r),n}shape(t,r=[]){return this.clone().withMutation(n=>{let o=n._excludedEdges;return r.length&&(Array.isArray(r[0])||(r=[r]),o=[...n._excludedEdges,...r]),n.setFields(Object.assign(n.fields,t),o)})}partial(){const t={};for(const[r,n]of Object.entries(this.fields))t[r]="optional"in n&&n.optional instanceof Function?n.optional():n;return this.setFields(t)}deepPartial(){return jr(this)}pick(t){const r={};for(const n of t)this.fields[n]&&(r[n]=this.fields[n]);return this.setFields(r,this._excludedEdges.filter(([n,o])=>t.includes(n)&&t.includes(o)))}omit(t){const r=[];for(const n of Object.keys(this.fields))t.includes(n)||r.push(n);return this.pick(r)}from(t,r,n){let o=Tt.getter(t,!0);return this.transform(s=>{if(!s)return s;let i=s;return jf(s,t)&&(i=Object.assign({},s),n||delete i[t],i[r]=o(s)),i})}json(){return this.transform(Ws)}exact(t){return this.test({name:"exact",exclusive:!0,message:t||Ir.exact,test(r){if(r==null)return!0;const n=Hs(this.schema,r);return n.length===0||this.createError({params:{properties:n.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(t=!0,r=Ir.noUnknown){typeof t!="boolean"&&(r=t,t=!0);let n=this.test({name:"noUnknown",exclusive:!0,message:r,test(o){if(o==null)return!0;const s=Hs(this.schema,o);return!t||s.length===0||this.createError({params:{unknown:s.join(", ")}})}});return n.spec.noUnknown=t,n}unknown(t=!0,r=Ir.noUnknown){return this.noUnknown(!t,r)}transformKeys(t){return this.transform(r=>{if(!r)return r;const n={};for(const o of Object.keys(r))n[t(o)]=r[o];return n})}camelCase(){return this.transformKeys(zn.camelCase)}snakeCase(){return this.transformKeys(zn.snakeCase)}constantCase(){return this.transformKeys(t=>zn.snakeCase(t).toUpperCase())}describe(t){const r=(t?this.resolve(t):this).clone(),n=super.describe(t);n.fields={};for(const[s,i]of Object.entries(r.fields)){var o;let a=t;(o=a)!=null&&o.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[s]})),n.fields[s]=i.describe(a)}return n}}ar.prototype=Xn.prototype;function Qn(e){return new Rn(e)}class Rn extends Ae{constructor(t){super({type:"array",spec:{types:t},check(r){return Array.isArray(r)}}),this.innerType=void 0,this.innerType=t}_cast(t,r){const n=super._cast(t,r);if(!this._typeCheck(n)||!this.innerType)return n;let o=!1;const s=n.map((i,a)=>{const c=this.innerType.cast(i,Object.assign({},r,{path:`${r.path||""}[${a}]`}));return c!==i&&(o=!0),c});return o?s:n}_validate(t,r={},n,o){var s;let i=this.innerType,a=(s=r.recursive)!=null?s:this.spec.recursive;r.originalValue!=null&&r.originalValue,super._validate(t,r,n,(c,u)=>{var d;if(!a||!i||!this._typeCheck(u)){o(c,u);return}let f=new Array(u.length);for(let y=0;y<u.length;y++){var p;f[y]=i.asNestedTest({options:r,index:y,parent:u,parentPath:r.path,originalParent:(p=r.originalValue)!=null?p:t})}this.runTests({value:u,tests:f,originalValue:(d=r.originalValue)!=null?d:t,options:r},n,y=>o(y.concat(c),u))})}clone(t){const r=super.clone(t);return r.innerType=this.innerType,r}json(){return this.transform(Ws)}concat(t){let r=super.concat(t);return r.innerType=this.innerType,t.innerType&&(r.innerType=r.innerType?r.innerType.concat(t.innerType):t.innerType),r}of(t){let r=this.clone();if(!St(t))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+Je(t));return r.innerType=t,r.spec=Object.assign({},r.spec,{types:t}),r}length(t,r=kr.length){return this.test({message:r,name:"length",exclusive:!0,params:{length:t},skipAbsent:!0,test(n){return n.length===this.resolve(t)}})}min(t,r){return r=r||kr.min,this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(n){return n.length>=this.resolve(t)}})}max(t,r){return r=r||kr.max,this.test({message:r,name:"max",exclusive:!0,params:{max:t},skipAbsent:!0,test(n){return n.length<=this.resolve(t)}})}ensure(){return this.default(()=>[]).transform((t,r)=>this._typeCheck(t)?t:r==null?[]:[].concat(r))}compact(t){let r=t?(n,o,s)=>!t(n,o,s):n=>!!n;return this.transform(n=>n!=null?n.filter(r):n)}describe(t){const r=(t?this.resolve(t):this).clone(),n=super.describe(t);if(r.innerType){var o;let s=t;(o=s)!=null&&o.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[0]})),n.innerType=r.innerType.describe(s)}return n}}Qn.prototype=Rn.prototype;function Ys(e){return new eo(e)}class eo extends Ae{constructor(t){super({type:"tuple",spec:{types:t},check(r){const n=this.spec.types;return Array.isArray(r)&&r.length===n.length}}),this.withMutation(()=>{this.typeError(Ls.notType)})}_cast(t,r){const{types:n}=this.spec,o=super._cast(t,r);if(!this._typeCheck(o))return o;let s=!1;const i=n.map((a,c)=>{const u=a.cast(o[c],Object.assign({},r,{path:`${r.path||""}[${c}]`}));return u!==o[c]&&(s=!0),u});return s?i:o}_validate(t,r={},n,o){let s=this.spec.types;super._validate(t,r,n,(i,a)=>{var c;if(!this._typeCheck(a)){o(i,a);return}let u=[];for(let[f,p]of s.entries()){var d;u[f]=p.asNestedTest({options:r,index:f,parent:a,parentPath:r.path,originalParent:(d=r.originalValue)!=null?d:t})}this.runTests({value:a,tests:u,originalValue:(c=r.originalValue)!=null?c:t,options:r},n,f=>o(f.concat(i),a))})}describe(t){const r=(t?this.resolve(t):this).clone(),n=super.describe(t);return n.innerType=r.spec.types.map((o,s)=>{var i;let a=t;return(i=a)!=null&&i.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[s]})),o.describe(a)}),n}}Ys.prototype=eo.prototype;function Bf(e){return new zr(e)}function qs(e){try{return e()}catch(t){if(Ce.isError(t))return Promise.reject(t);throw t}}class zr{constructor(t){this.type="lazy",this.__isYupSchema__=!0,this.spec=void 0,this._resolve=(r,n={})=>{let o=this.builder(r,n);if(!St(o))throw new TypeError("lazy() functions must return a valid schema");return this.spec.optional&&(o=o.optional()),o.resolve(n)},this.builder=t,this.spec={meta:void 0,optional:!1}}clone(t){const r=new zr(this.builder);return r.spec=Object.assign({},this.spec,t),r}optionality(t){return this.clone({optional:t})}optional(){return this.optionality(!0)}resolve(t){return this._resolve(t.value,t)}cast(t,r){return this._resolve(t,r).cast(t,r)}asNestedTest(t){let{key:r,index:n,parent:o,options:s}=t,i=o[n??r];return this._resolve(i,Object.assign({},s,{value:i,parent:o})).asNestedTest(t)}validate(t,r){return qs(()=>this._resolve(t,r).validate(t,r))}validateSync(t,r){return this._resolve(t,r).validateSync(t,r)}validateAt(t,r,n){return qs(()=>this._resolve(r,n).validateAt(t,r,n))}validateSyncAt(t,r,n){return this._resolve(r,n).validateSyncAt(t,r,n)}isValid(t,r){try{return this._resolve(t,r).isValid(t,r)}catch(n){if(Ce.isError(n))return Promise.resolve(!1);throw n}}isValidSync(t,r){return this._resolve(t,r).isValidSync(t,r)}describe(t){return t?this.resolve(t).describe(t):{type:"lazy",meta:this.spec.meta,label:void 0}}meta(...t){if(t.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},t[0]),r}}function Uf(e){Object.keys(e).forEach(t=>{Object.keys(e[t]).forEach(r=>{js[t][r]=e[t][r]})})}function Vf(e,t,r){if(!e||!St(e.prototype))throw new TypeError("You must provide a yup schema constructor function");if(typeof t!="string")throw new TypeError("A Method name must be provided");if(typeof r!="function")throw new TypeError("Method function must be provided");e.prototype[t]=r}const Ks=Object.freeze(Object.defineProperty({__proto__:null,ArraySchema:Rn,BooleanSchema:Yn,DateSchema:Pt,LazySchema:zr,MixedSchema:Gn,NumberSchema:Jn,ObjectSchema:Xn,Schema:Ae,StringSchema:Kn,TupleSchema:eo,ValidationError:Ce,addMethod:Vf,array:Qn,bool:Hn,boolean:Hn,date:Zn,defaultLocale:js,getIn:Wn,isSchema:St,lazy:Bf,mixed:Nr,number:zs,object:ar,printValue:Je,reach:_f,ref:Sf,setLocale:Uf,string:Lr,tuple:Ys},Symbol.toStringTag,{value:"Module"})),Js=e=>{const t=e.reduce((r,n)=>{let{name:o,required:s,type:i}=n;switch(i){case"RelatedList":i="array";break;case"Integer":case"Float":i="number";break;case"Related":case"Geometry":case"Raw":i="mixed";break;default:i="string"}let a;try{s?a=Ks[i]().typeError(`Field must be of type ${i}`).required("Field is required"):a=Ks[i]().typeError(`Field must be of type ${i}`).nullable(!0)}catch(c){console.log(c)}return r[o]=a,r},{});return ar().shape(t)},Zs=e=>!e&&typeof e!="boolean"&&typeof e!="number"?null:typeof e=="boolean"?e.toString():Array.isArray(e)?e.map(t=>t.name_||JSON.stringify(t,null,2)).join(", "):typeof e=="object"?e.name_||JSON.stringify(e):e,Wf=e=>e?{...e,add:{columns:e.add_columns,title:e.add_title,schema:Js(e.add_columns),defaultValues:Cs(e.add_columns)},edit:{columns:e.edit_columns,title:e.edit_title,schema:Js(e.edit_columns),defaultValues:Cs(e.edit_columns)}}:null,Gf=async(e,t,r)=>{const{fetchPath:n,options:o}=Pe({path:Se(t,"/download"),method:"POST"}),s=await fetch(n,{...o,body:JSON.stringify(r)});let i=null;const a=s.headers.get("content-type");if(a&&a.includes("application/json")?i=await s.json():i=await s.blob(),!s.ok)throw typeof i=="object"?new Error(typeof i.detail=="string"?i.detail:JSON.stringify(i,null,2)):new Error(i);const c=document.createElement("a"),u=URL.createObjectURL(i);c.href=u,c.download=e.toLowerCase()+".csv",c.click()};function Hf({path:e,initialQueryParams:t,relation:r,fetchInfo:n=!0,clearInfoOnRefetch:o=!1,clearDataOnRefetch:s=!1,resetQueryParamsOnPathChange:i=!0,infoQueryProps:a,dataQueryProps:c,streaming:u=!1}){const[d,f]=v.useState(t?Ar(null,t):null),p=v.useMemo(()=>r?{...d,filters:[...d.filters,{col:r.foreign_key,opr:r.type,value:je(r.id)}]}:d,[r,d]),y=v.useCallback(G=>f(x=>{if(typeof G=="function"&&(G=G(x)),!x)return Ar(null,G);const $=Ar({...x},G);if((G.filters||G.order_column||G.order_direction)&&!G.page&&($.page=0),u){if(G.page&&G.page!==x.page&&!G.streaming)throw new Error("You cannot change page in streaming mode, use streaming.fetch() instead");if(G.page_size&&G.page_size!==x.page_size)throw new Error("You cannot change page size in streaming mode, use streaming.fetch() instead")}return $}),[u]),[b,h]=v.useState(null),w=v.useMemo(()=>b,[b]),E=v.useCallback(()=>h(null),[]),{data:M,isFetching:A,refetch:_,error:S}=rt.useQuery({queryKey:[`info-${e}`],queryFn:({signal:G})=>Ku(Se(e,"_info"),G).then(Wf),enabled:n,placeholderData:o?null:rt.keepPreviousData,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,...a}),{data:P,isFetching:F,refetch:j,error:z}=rt.useQuery({queryKey:[`data-${e}`,JSON.stringify(p)],queryFn:({signal:G})=>p?Zu(Se(e,"/"),p,G).then(x=>({...x,result:x.result.map(($,K)=>({...$,id:x.ids[K]}))})):null,placeholderData:s?null:rt.keepPreviousData,staleTime:1/0,refetchOnReconnect:"always",refetchOnWindowFocus:"always",...c});v.useEffect(()=>{p&&j()},[j,p]),v.useEffect(()=>{if(S){h({message:"Couldn't fetch info",originalError:S});return}if(z){h({message:"Couldn't fetch list",originalError:z});return}E()},[S,z,E]);const m=v.useMemo(()=>A||F,[A,F]);Te.useDidUpdate(()=>{if(!i)return;const G=Ar(null,t);d!=null&&d.page_size&&(G.page_size=d.page_size),y(G)},[e]);const O=v.useCallback(async G=>{try{const x=await Ju(e,je(G));return E(),x}catch(x){h({message:`Couldn't fetch item with id ${G}`,originalError:x})}},[e,E]),B=v.useCallback(async(G,x)=>{try{const $=await Yu(e,G);return x||(_(),j()),E(),$}catch($){h({message:"Couldn't add item",originalError:$})}},[j,_,e,E]),q=v.useCallback(async(G,x,$)=>{try{const K=await Xu(e,je(G),x);return $||(_(),j()),E(),K}catch(K){h({message:`Couldn't update item with id ${G}`,originalError:K})}},[j,_,e,E]),ee=v.useCallback(async(G,x)=>{try{const $=await qu(e,je(G));return x||(_(),j()),E(),$}catch($){h({message:`Couldn't delete item with id ${G}`,originalError:$})}},[j,_,e,E]),fe=v.useCallback(async G=>{try{await Gf(G,e,p)}catch(x){h({message:"Couldn't download",originalError:x})}},[e,p]),[se,be]=Te.useSetState({data:{},isEnd:!1,fetch:()=>null});v.useEffect(()=>{u&&be({fetch:()=>y({page:0,streaming:!0})})},[y,be,u]),v.useEffect(()=>{u&&P&&be(G=>{let x=Object.keys(G.data).length;const $={isEnd:!1};return p.page<x?(x=p.page,$.data={[p.page]:P.result}):$.data={...G.data,[p.page]:P.result},P.result.length<p.page_size?($.isEnd=!0,$.fetch=()=>null):$.fetch=()=>y({page:x+1,streaming:!0}),$})},[P,y,be,u]);const we=v.useMemo(()=>{const G={all:"all",actions:"actions"};return P==null||P.list_columns.forEach(x=>{G[x]&&(G[x]=`_${x}`)}),G},[P==null?void 0:P.list_columns]);return{path:e,data:P,info:M,queryParams:p,loading:m,error:w,streaming:se,specialKey:we,setQueryParams:y,refetch:j,refetchInfo:_,getEntry:O,addEntry:B,updateEntry:q,deleteEntry:ee,download:fe}}const Yf=async(e,t,r)=>{const{fetchPath:n,options:o}=Pe({path:Se(e,"/bulk",t),method:"POST",body:r}),s=await fetch(n,o);let i=null;const a=s.headers.get("content-type");if(a&&a.includes("application/json")?i=await s.json():i=await s.text(),!s.ok)throw typeof i=="object"?new Error(typeof i.detail=="string"?i.detail:JSON.stringify(i,null,2)):new Error(i);return i},qf=({Api:e})=>{const[t,r]=v.useState([]),[n,o]=v.useState(null),s=v.useCallback(async(a,c)=>{try{o(null);const u=await Yf(e.path,a,t);return c?void 0:(e.refetch(),u)}catch(u){console.error(u),o({message:"Couldn't perform bulk action",originalError:u})}},[e,t]);return{bulkActions:v.useMemo(()=>({selectedIds:t,setSelectedIds:r}),[t,r]),dispatchBulkActions:s,error:n}};function Xs({resource_name:e="",initialQueryParams:t,relation:r,fetchInfo:n,clearInfoOnRefetch:o,clearDataOnRefetch:s,resetQueryParamsOnPathChange:i,infoQueryProps:a,dataQueryProps:c,children:u,streaming:d}){const{baseUrl:f}=_s(),p=Hf({path:Se(f,e),initialQueryParams:t,relation:r,fetchInfo:n,clearInfoOnRefetch:o,clearDataOnRefetch:s,resetQueryParamsOnPathChange:i,infoQueryProps:a,dataQueryProps:c,streaming:d}),y=ir(p),b=qf({path:Se(f,e),Api:p}),h=ir(b);return l.jsx(vs.Provider,{value:y,children:l.jsx(ws.Provider,{value:h,children:u})})}/**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastapi-rtk",
3
- "version": "0.0.99",
3
+ "version": "0.0.101",
4
4
  "private": false,
5
5
  "description": "A react component library for Flask Appbuilder",
6
6
  "license": "MIT",