fastapi-rtk 0.0.72 → 0.0.74

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.
@@ -2974,7 +2974,8 @@ function xp(e) {
2974
2974
  signout: s,
2975
2975
  update: l,
2976
2976
  resetPassword: c,
2977
- oauth_signin: f
2977
+ oauth_signin: f,
2978
+ refetch: i
2978
2979
  };
2979
2980
  }
2980
2981
  function _p(e, t) {
@@ -3014,7 +3015,8 @@ const da = tc({
3014
3015
  signout: async () => null,
3015
3016
  update: async (e) => null,
3016
3017
  resetPassword: async (e) => null,
3017
- oauth_signin: (e, t) => null
3018
+ oauth_signin: (e, t) => null,
3019
+ refetch: async () => null
3018
3020
  },
3019
3021
  info: {
3020
3022
  /**
@@ -30,7 +30,7 @@ React keys must be passed directly to JSX without using spread:
30
30
  <%s key={someKey} {...props} />`,Xe,Ee,Kt,Ee),hi[Ee+Xe]=!0}}return g===n?pi($):di($),$}}function xr(g,w,z){return rt(g,w,z,!0)}function mi(g,w,z){return rt(g,w,z,!1)}var gi=mi,yi=xr;_r.Fragment=n,_r.jsx=gi,_r.jsxs=yi}()),_r}process.env.NODE_ENV==="production"?bi.exports=Pf():bi.exports=jf();var d=bi.exports;function ze({path:e,method:t,body:r=void 0,queryParams:n=void 0}){const i=Object.entries(n||{}).reduce((s,[l,u])=>((Array.isArray(u)||typeof u=="object")&&(u=JSON.stringify(u)),s[l]=u,s),{}),o=new Ft.createSearchParams(i);e=e+"?"+o;const a={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:a}}function If(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 i=0;i<e.length;i++){let o=e[i];if(typeof o!="string")throw new TypeError("Url must be a string. Received "+o);o!==""&&(i>0&&(o=o.replace(/^[\/]+/,"")),i<e.length-1?o=o.replace(/[\/]+$/,""):o=o.replace(/[\/]+$/,"/"),t.push(o))}let r=t.join("/");r=r.replace(/\/(\?|&|#[^!])/g,"$1");const n=r.split("?");return r=n.shift()+(n.length>0?"?":"")+n.join("&"),r}function De(...e){const t=Array.from(Array.isArray(e[0])?e[0]:e);return If(t)}function Xr(e,{autoInvoke:t=!0,initialLoading:r=!1,clearDataOnRefetch:n=!1,...i}={}){const[o,a]=_.useState(null),[s,l]=_.useState(r),[u,f]=_.useState(null),c=_.useRef(null),p=_.useCallback(()=>{if(e)return n&&a(null),f(null),c.current&&c.current.abort(),c.current=new AbortController,l(!0),fetch(e,{signal:c.current.signal,...i}).then(async m=>{const y=await m.json();if(!m.ok){const T=typeof y.detail=="string"?y.detail:JSON.stringify(y.detail,null,2);throw new Error(T)}return a(y),l(!1),y}).catch(m=>(m&&m.name!=="AbortError"&&(f(m),l(!1)),m))},[e]),v=_.useCallback(()=>{var m;c.current&&((m=c.current)==null||m.abort(""),l(!1))},[]);return _.useEffect(()=>(t&&p(),()=>{c.current&&c.current.abort("")}),[p,t]),{data:o,loading:s,error:u,refetch:p,abort:v}}function xa({path:e,autoInvoke:t=!0,initialLoading:r=!0}){const{fetchPath:n,options:i}=_.useMemo(()=>ze({path:De(e,"auth/user"),method:"GET"}),[e]),{data:o,loading:a,refetch:s,error:l}=Xr(n,{autoInvoke:t,initialLoading:r,...i});return{user:o,loading:a,refetch:s,error:l}}function Ta({path:e,queryParams:t,autoInvoke:r=!0,clearDataOnRefetch:n=!1}){const{fetchPath:i,options:o}=_.useMemo(()=>ze({path:De(e,"/"),method:"GET",queryParams:t}),[e,t]),{data:a,loading:s,refetch:l,error:u}=Xr(i,{autoInvoke:r,clearDataOnRefetch:n,...o});return{data:_.useMemo(()=>{if(!a)return null;const c=a.result.map((p,v)=>{const m=a.ids[v];return{...p,id:m}});return{...a,result:c}},[a]),loading:s,refetch:l,error:u}}const Df=async(e,t)=>{const{fetchPath:r,options:n}=ze({path:De(e,"/"),method:"POST",body:t}),i=await fetch(r,n);let o=null;const a=i.headers.get("content-type");if(a&&a.includes("application/json")?o=await i.json():o=await i.text(),!i.ok)throw typeof o=="object"?new Error(typeof o.detail=="string"?o.detail:JSON.stringify(o,null,2)):new Error(o);return o},$f=async(e,t)=>{const{fetchPath:r,options:n}=ze({path:De(e,t.toString()),method:"DELETE"}),i=await fetch(r,n);let o=null;const a=i.headers.get("content-type");if(a&&a.includes("application/json")?o=await i.json():o=await i.text(),!i.ok)throw typeof o=="object"?new Error(typeof o.detail=="string"?o.detail:JSON.stringify(o,null,2)):new Error(o);return o},Mf=async(e,t)=>{const{fetchPath:r,options:n}=ze({path:De(e,t.toString()),method:"GET"}),i=await fetch(r,n);let o=null;const a=i.headers.get("content-type");if(a&&a.includes("application/json")?o=await i.json():o=await i.text(),!i.ok)throw typeof o=="object"?new Error(typeof o.detail=="string"?o.detail:JSON.stringify(o,null,2)):new Error(o);return o},Rf=async(e,t,r)=>{const{fetchPath:n,options:i}=ze({path:De(e,t.toString()),method:"PUT",body:r}),o=await fetch(n,i);let a=null;const s=o.headers.get("content-type");if(s&&s.includes("application/json")?a=await o.json():a=await o.text(),!o.ok)throw typeof a=="object"?new Error(typeof a.detail=="string"?a.detail:JSON.stringify(a,null,2)):new Error(a);return a},Ze=e=>e&&typeof e=="object"?Array.isArray(e)?e.join(","):JSON.stringify(e):e;function Jr(e,t){const r=e||{columns:[],filters:[],page:0,page_size:25};return t.hasOwnProperty("columns")&&(r.columns=t.columns),t.hasOwnProperty("filters")&&(r.filters=t.filters),t.hasOwnProperty("order_column")&&(r.order_column=t.order_column),t.hasOwnProperty("order_direction")&&(r.order_direction=t.order_direction),t.hasOwnProperty("page")&&(r.page=t.page),t.hasOwnProperty("page_size")&&(r.page_size=t.page_size),r}const _a=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};function Lt(e){this._maxSize=e,this.clear()}Lt.prototype.clear=function(){this._size=0,this._values=Object.create(null)},Lt.prototype.get=function(e){return this._values[e]},Lt.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var Nf=/[^.^\]^[]+|(?=\[\]|\.\.)/g,Sa=/^\d+$/,Ff=/^\d/,Lf=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,zf=/^\s*(['"]?)(.*?)(\1)\s*$/,xi=512,Ea=new Lt(xi),Ca=new Lt(xi),wa=new Lt(xi),zt={Cache:Lt,split:_i,normalizePath:Ti,setter:function(e){var t=Ti(e);return Ca.get(e)||Ca.set(e,function(n,i){for(var o=0,a=t.length,s=n;o<a-1;){var l=t[o];if(l==="__proto__"||l==="constructor"||l==="prototype")return n;s=s[t[o++]]}s[t[o]]=i})},getter:function(e,t){var r=Ti(e);return wa.get(e)||wa.set(e,function(i){for(var o=0,a=r.length;o<a;)if(i!=null||!t)i=i[r[o++]];else return;return i})},join:function(e){return e.reduce(function(t,r){return t+(Si(r)||Sa.test(r)?"["+r+"]":(t?".":"")+r)},"")},forEach:function(e,t,r){Bf(Array.isArray(e)?e:_i(e),t,r)}};function Ti(e){return Ea.get(e)||Ea.set(e,_i(e).map(function(t){return t.replace(zf,"$2")}))}function _i(e){return e.match(Nf)||[""]}function Bf(e,t,r){var n=e.length,i,o,a,s;for(o=0;o<n;o++)i=e[o],i&&(Wf(i)&&(i='"'+i+'"'),s=Si(i),a=!s&&/^\d+$/.test(i),t.call(r,i,s,a,o,e))}function Si(e){return typeof e=="string"&&e&&["'",'"'].indexOf(e.charAt(0))!==-1}function Uf(e){return e.match(Ff)&&!e.match(Sa)}function Vf(e){return Lf.test(e)}function Wf(e){return!Si(e)&&(Uf(e)||Vf(e))}const Hf=/[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,Zr=e=>e.match(Hf)||[],Qr=e=>e[0].toUpperCase()+e.slice(1),Ei=(e,t)=>Zr(e).join(t).toLowerCase(),Aa=e=>Zr(e).reduce((t,r)=>`${t}${t?r[0].toUpperCase()+r.slice(1).toLowerCase():r.toLowerCase()}`,"");var Ci={words:Zr,upperFirst:Qr,camelCase:Aa,pascalCase:e=>Qr(Aa(e)),snakeCase:e=>Ei(e,"_"),kebabCase:e=>Ei(e,"-"),sentenceCase:e=>Qr(Ei(e," ")),titleCase:e=>Zr(e).map(Qr).join(" ")},wi={exports:{}};wi.exports=function(e){return Oa(Gf(e),e)},wi.exports.array=Oa;function Oa(e,t){var r=e.length,n=new Array(r),i={},o=r,a=Yf(t),s=qf(e);for(t.forEach(function(u){if(!s.has(u[0])||!s.has(u[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});o--;)i[o]||l(e[o],o,new Set);return n;function l(u,f,c){if(c.has(u)){var p;try{p=", node was:"+JSON.stringify(u)}catch{p=""}throw new Error("Cyclic dependency"+p)}if(!s.has(u))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(u));if(!i[f]){i[f]=!0;var v=a.get(u)||new Set;if(v=Array.from(v),f=v.length){c.add(u);do{var m=v[--f];l(m,s.get(m),c)}while(f);c.delete(u)}n[--r]=u}}}function Gf(e){for(var t=new Set,r=0,n=e.length;r<n;r++){var i=e[r];t.add(i[0]),t.add(i[1])}return Array.from(t)}function Yf(e){for(var t=new Map,r=0,n=e.length;r<n;r++){var i=e[r];t.has(i[0])||t.set(i[0],new Set),t.has(i[1])||t.set(i[1],new Set),t.get(i[0]).add(i[1])}return t}function qf(e){for(var t=new Map,r=0,n=e.length;r<n;r++)t.set(e[r],r);return t}var Kf=wi.exports;const Xf=yt(Kf),Jf=Object.prototype.toString,Zf=Error.prototype.toString,Qf=RegExp.prototype.toString,ed=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",td=/^Symbol\((.*)\)(.*)$/;function rd(e){return e!=+e?"NaN":e===0&&1/e<0?"-0":""+e}function ka(e,t=!1){if(e==null||e===!0||e===!1)return""+e;const r=typeof e;if(r==="number")return rd(e);if(r==="string")return t?`"${e}"`:e;if(r==="function")return"[Function "+(e.name||"anonymous")+"]";if(r==="symbol")return ed.call(e).replace(td,"Symbol($1)");const n=Jf.call(e).slice(8,-1);return n==="Date"?isNaN(e.getTime())?""+e:e.toISOString(e):n==="Error"||e instanceof Error?"["+Zf.call(e)+"]":n==="RegExp"?Qf.call(e):null}function dt(e,t){let r=ka(e,t);return r!==null?r:JSON.stringify(e,function(n,i){let o=ka(this[n],t);return o!==null?o:i},2)}function Pa(e){return e==null?[]:[].concat(e)}let ja,Ia,Da,nd=/\$\{\s*(\w+)\s*\}/g;ja=Symbol.toStringTag;class $a{constructor(t,r,n,i){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[ja]="Error",this.name="ValidationError",this.value=r,this.path=n,this.type=i,this.errors=[],this.inner=[],Pa(t).forEach(o=>{if(Fe.isError(o)){this.errors.push(...o.errors);const a=o.inner.length?o.inner:[o];this.inner.push(...a)}else this.errors.push(o)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}Ia=Symbol.hasInstance,Da=Symbol.toStringTag;class Fe extends Error{static formatError(t,r){const n=r.label||r.path||"this";return n!==r.path&&(r=Object.assign({},r,{path:n})),typeof t=="string"?t.replace(nd,(i,o)=>dt(r[o])):typeof t=="function"?t(r):t}static isError(t){return t&&t.name==="ValidationError"}constructor(t,r,n,i,o){const a=new $a(t,r,n,i);if(o)return a;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[Da]="Error",this.name=a.name,this.message=a.message,this.type=a.type,this.value=a.value,this.path=a.path,this.errors=a.errors,this.inner=a.inner,Error.captureStackTrace&&Error.captureStackTrace(this,Fe)}static[Ia](t){return $a[Symbol.hasInstance](t)||super[Symbol.hasInstance](t)}}let pt={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 i=n!=null&&n!==r?` (cast from the value \`${dt(n,!0)}\`).`:".";return t!=="mixed"?`${e} must be a \`${t}\` type, but the final value was: \`${dt(r,!0)}\``+i:`${e} must match the configured type. The validated value was: \`${dt(r,!0)}\``+i}},Ye={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"},Ot={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"},Ai={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},Oi={isValue:"${path} field must be ${value}"},ki={noUnknown:"${path} field has unspecified keys: ${unknown}"},en={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"},Ma={notType:e=>{const{path:t,value:r,spec:n}=e,i=n.types.length;if(Array.isArray(r)){if(r.length<i)return`${t} tuple value has too few items, expected a length of ${i} but got ${r.length} for value: \`${dt(r,!0)}\``;if(r.length>i)return`${t} tuple value has too many items, expected a length of ${i} but got ${r.length} for value: \`${dt(r,!0)}\``}return Fe.formatError(pt.notType,e)}};var Ra=Object.assign(Object.create(null),{mixed:pt,string:Ye,number:Ot,date:Ai,object:ki,array:en,boolean:Oi,tuple:Ma});const Bt=e=>e&&e.__isYupSchema__;class tn{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:i,otherwise:o}=r,a=typeof n=="function"?n:(...s)=>s.every(l=>l===n);return new tn(t,(s,l)=>{var u;let f=a(...s)?i:o;return(u=f==null?void 0:f(l))!=null?u:l})}constructor(t,r){this.fn=void 0,this.refs=t,this.refs=t,this.fn=r}resolve(t,r){let n=this.refs.map(o=>o.getValue(r==null?void 0:r.value,r==null?void 0:r.parent,r==null?void 0:r.context)),i=this.fn(n,t,r);if(i===void 0||i===t)return t;if(!Bt(i))throw new TypeError("conditions must return a schema object");return i.resolve(r)}}const rn={context:"$",value:"."};function id(e,t){return new kt(e,t)}class kt{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]===rn.context,this.isValue=this.key[0]===rn.value,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?rn.context:this.isValue?rn.value:"";this.path=this.key.slice(n.length),this.getter=this.path&&zt.getter(this.path,!0),this.map=r.map}getValue(t,r,n){let i=this.isContext?n:this.isValue?t:r;return this.getter&&(i=this.getter(i||{})),this.map&&(i=this.map(i)),i}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}}kt.prototype.__isYupRef=!0;const st=e=>e==null;function Jt(e){function t({value:r,path:n="",options:i,originalValue:o,schema:a},s,l){const{name:u,test:f,params:c,message:p,skipAbsent:v}=e;let{parent:m,context:y,abortEarly:T=a.spec.abortEarly,disableStackTrace:j=a.spec.disableStackTrace}=i;function R(L){return kt.isRef(L)?L.getValue(r,m,y):L}function A(L={}){const V=Object.assign({value:r,originalValue:o,label:a.spec.label,path:L.path||n,spec:a.spec,disableStackTrace:L.disableStackTrace||j},c,L.params);for(const le of Object.keys(V))V[le]=R(V[le]);const te=new Fe(Fe.formatError(L.message||p,V),r,V.path,L.type||u,V.disableStackTrace);return te.params=V,te}const N=T?s:l;let S={path:n,parent:m,type:u,from:i.from,createError:A,resolve:R,options:i,originalValue:o,schema:a};const D=L=>{Fe.isError(L)?N(L):L?l(null):N(A())},G=L=>{Fe.isError(L)?N(L):s(L)};if(v&&st(r))return D(!0);let h;try{var F;if(h=f.call(S,r,S),typeof((F=h)==null?void 0:F.then)=="function"){if(i.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(h).then(D,G)}}catch(L){G(L);return}D(h)}return t.OPTIONS=e,t}function Pi(e,t,r,n=r){let i,o,a;return t?(zt.forEach(t,(s,l,u)=>{let f=l?s.slice(1,s.length-1):s;e=e.resolve({context:n,parent:i,value:r});let c=e.type==="tuple",p=u?parseInt(f,10):0;if(e.innerType||c){if(c&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${a}" must contain an index to the tuple element, e.g. "${a}[0]"`);if(r&&p>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${s}, in the path: ${t}. because there is no value at that index. `);i=r,r=r&&r[p],e=c?e.spec.types[p]:e.innerType}if(!u){if(!e.fields||!e.fields[f])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${a} which is a type: "${e.type}")`);i=r,r=r&&r[f],e=e.fields[f]}o=f,a=l?"["+s+"]":"."+s}),{schema:e,parent:i,parentPath:o}):{parent:i,parentPath:t,schema:e}}function od(e,t,r,n){return Pi(e,t,r,n).schema}class nn extends Set{describe(){const t=[];for(const r of this.values())t.push(kt.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 nn(this.values())}merge(t,r){const n=this.clone();return t.forEach(i=>n.add(i)),r.forEach(i=>n.delete(i)),n}}function Zt(e,t=new Map){if(Bt(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]=Zt(e[n],t)}else if(e instanceof Map){r=new Map,t.set(e,r);for(const[n,i]of e.entries())r.set(n,Zt(i,t))}else if(e instanceof Set){r=new Set,t.set(e,r);for(const n of e)r.add(Zt(n,t))}else if(e instanceof Object){r={},t.set(e,r);for(const[n,i]of Object.entries(e))r[n]=Zt(i,t)}else throw Error(`Unable to clone ${e}`);return r}class Le{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 nn,this._blacklist=new nn,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(pt.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=Zt(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 i=Object.assign({},r.spec,n.spec);return n.spec=i,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(o=>{t.tests.forEach(a=>{o.test(a.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((i,o)=>o.resolve(i,t),r),r=r.resolve(t)}return r}resolveOptions(t){var r,n,i,o;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:(i=t.recursive)!=null?i:this.spec.recursive,disableStackTrace:(o=t.disableStackTrace)!=null?o:this.spec.disableStackTrace})}cast(t,r={}){let n=this.resolve(Object.assign({value:t},r)),i=r.assert==="ignore-optionality",o=n._cast(t,r);if(r.assert!==!1&&!n.isType(o)){if(i&&st(o))return o;let a=dt(t),s=dt(o);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${n.type}".
31
31
 
32
32
  attempted value: ${a}
33
- `+(s!==a?`result of cast: ${s}`:""))}return o}_cast(t,r){let n=t===void 0?t:this.transforms.reduce((i,o)=>o.call(this,i,t,this),t);return n===void 0&&(n=this.getDefault(r)),n}_validate(t,r={},n,i){let{path:o,originalValue:a=t,strict:s=this.spec.strict}=r,l=t;s||(l=this._cast(l,Object.assign({assert:!1},r)));let u=[];for(let f of Object.values(this.internalTests))f&&u.push(f);this.runTests({path:o,value:l,originalValue:a,options:r,tests:u},n,f=>{if(f.length)return i(f,l);this.runTests({path:o,value:l,originalValue:a,options:r,tests:this.tests},n,i)})}runTests(t,r,n){let i=!1,{tests:o,value:a,originalValue:s,path:l,options:u}=t,f=y=>{i||(i=!0,r(y,a))},c=y=>{i||(i=!0,n(y,a))},p=o.length,v=[];if(!p)return c([]);let m={value:a,originalValue:s,path:l,options:u,schema:this};for(let y=0;y<o.length;y++){const T=o[y];T(m,f,function(R){R&&(Array.isArray(R)?v.push(...R):v.push(R)),--p<=0&&c(v)})}}asNestedTest({key:t,index:r,parent:n,parentPath:i,originalParent:o,options:a}){const s=t??r;if(s==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof s=="number";let u=n[s];const f=Object.assign({},a,{strict:!0,parent:n,value:u,originalValue:o[s],key:void 0,[l?"index":"key"]:s,path:l||s.includes(".")?`${i||""}[${l?s:`"${s}"`}]`:(i?`${i}.`:"")+t});return(c,p,v)=>this.resolve(f)._validate(u,f,p,v)}validate(t,r){var n;let i=this.resolve(Object.assign({},r,{value:t})),o=(n=r==null?void 0:r.disableStackTrace)!=null?n:i.spec.disableStackTrace;return new Promise((a,s)=>i._validate(t,r,(l,u)=>{Fe.isError(l)&&(l.value=u),s(l)},(l,u)=>{l.length?s(new Fe(l,u,void 0,void 0,o)):a(u)}))}validateSync(t,r){var n;let i=this.resolve(Object.assign({},r,{value:t})),o,a=(n=r==null?void 0:r.disableStackTrace)!=null?n:i.spec.disableStackTrace;return i._validate(t,Object.assign({},r,{sync:!0}),(s,l)=>{throw Fe.isError(s)&&(s.value=l),s},(s,l)=>{if(s.length)throw new Fe(s,t,void 0,void 0,a);o=l}),o}isValid(t,r){return this.validate(t,r).then(()=>!0,n=>{if(Fe.isError(n))return!1;throw n})}isValidSync(t,r){try{return this.validateSync(t,r),!0}catch(n){if(Fe.isError(n))return!1;throw n}}_getDefault(t){let r=this.spec.default;return r==null?r:typeof r=="function"?r.call(this,t):Zt(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=Jt({message:r,name:"nullable",test(i){return i===null?this.schema.spec.nullable:!0}}),n}optionality(t,r){const n=this.clone({optional:t});return n.internalTests.optionality=Jt({message:r,name:"optionality",test(i){return i===void 0?this.schema.spec.optional:!0}}),n}optional(){return this.optionality(!0)}defined(t=pt.defined){return this.optionality(!1,t)}nullable(){return this.nullability(!0)}nonNullable(t=pt.notNull){return this.nullability(!1,t)}required(t=pt.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=pt.default),typeof r.test!="function")throw new TypeError("`test` is a required parameters");let n=this.clone(),i=Jt(r),o=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(a=>!(a.OPTIONS.name===r.name&&(o||a.OPTIONS.test===i.OPTIONS.test))),n.tests.push(i),n}when(t,r){!Array.isArray(t)&&typeof t!="string"&&(r=t,t=".");let n=this.clone(),i=Pa(t).map(o=>new kt(o));return i.forEach(o=>{o.isSibling&&n.deps.push(o.key)}),n.conditions.push(typeof r=="function"?new tn(i,r):tn.fromOptions(i,r)),n}typeError(t){let r=this.clone();return r.internalTests.typeError=Jt({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=pt.oneOf){let n=this.clone();return t.forEach(i=>{n._whitelist.add(i),n._blacklist.delete(i)}),n.internalTests.whiteList=Jt({message:r,name:"oneOf",skipAbsent:!0,test(i){let o=this.schema._whitelist,a=o.resolveAll(this.resolve);return a.includes(i)?!0:this.createError({params:{values:Array.from(o).join(", "),resolved:a}})}}),n}notOneOf(t,r=pt.notOneOf){let n=this.clone();return t.forEach(i=>{n._blacklist.add(i),n._whitelist.delete(i)}),n.internalTests.blacklist=Jt({message:r,name:"notOneOf",test(i){let o=this.schema._blacklist,a=o.resolveAll(this.resolve);return a.includes(i)?this.createError({params:{values:Array.from(o).join(", "),resolved:a}}):!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:i,optional:o,nullable:a}=r.spec;return{meta:i,label:n,optional:o,nullable:a,default:r.getDefault(t),type:r.type,oneOf:r._whitelist.describe(),notOneOf:r._blacklist.describe(),tests:r.tests.map(l=>({name:l.OPTIONS.name,params:l.OPTIONS.params})).filter((l,u,f)=>f.findIndex(c=>c.name===l.name)===u)}}}Le.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])Le.prototype[`${e}At`]=function(t,r,n={}){const{parent:i,parentPath:o,schema:a}=Pi(this,t,r,n.context);return a[e](i&&i[o],Object.assign({},n,{parent:i,path:t}))};for(const e of["equals","is"])Le.prototype[e]=Le.prototype.oneOf;for(const e of["not","nope"])Le.prototype[e]=Le.prototype.notOneOf;const ad=()=>!0;function on(e){return new ji(e)}class ji extends Le{constructor(t){super(typeof t=="function"?{type:"mixed",check:t}:Object.assign({type:"mixed",check:ad},t))}}on.prototype=ji.prototype;function Ii(){return new Di}class Di extends Le{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=Oi.isValue){return this.test({message:t,name:"is-value",exclusive:!0,params:{value:"true"},test(r){return st(r)||r===!0}})}isFalse(t=Oi.isValue){return this.test({message:t,name:"is-value",exclusive:!0,params:{value:"false"},test(r){return st(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)}}Ii.prototype=Di.prototype;const sd=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function ld(e){const t=$i(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 $i(e){var t,r;const n=sd.exec(e);return n?{year:vt(n[1]),month:vt(n[2],1)-1,day:vt(n[3],1),hour:vt(n[4]),minute:vt(n[5]),second:vt(n[6]),millisecond:n[7]?vt(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:vt(n[10]),minuteOffset:vt(n[11])}:null}function vt(e,t=0){return Number(e)||t}let ud=/^[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])?)*$/,cd=/^((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,fd=/^(?:[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,dd="^\\d{4}-\\d{2}-\\d{2}",pd="\\d{2}:\\d{2}:\\d{2}",hd="(([+-]\\d{2}(:?\\d{2})?)|Z)",md=new RegExp(`${dd}T${pd}(\\.\\d+)?${hd}$`),gd=e=>st(e)||e===e.trim(),yd={}.toString();function an(){return new Mi}class Mi extends Le{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 i=t!=null&&t.toString?t.toString():t;return i===yd?t:i})})}required(t){return super.required(t).withMutation(r=>r.test({message:t||pt.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=Ye.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=Ye.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=Ye.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,i,o;return r&&(typeof r=="object"?{excludeEmptyString:n=!1,message:i,name:o}=r:i=r),this.test({name:o||"matches",message:i||Ye.matches,params:{regex:t},skipAbsent:!0,test:a=>a===""&&n||a.search(t)!==-1})}email(t=Ye.email){return this.matches(ud,{name:"email",message:t,excludeEmptyString:!0})}url(t=Ye.url){return this.matches(cd,{name:"url",message:t,excludeEmptyString:!0})}uuid(t=Ye.uuid){return this.matches(fd,{name:"uuid",message:t,excludeEmptyString:!1})}datetime(t){let r="",n,i;return t&&(typeof t=="object"?{message:r="",allowOffset:n=!1,precision:i=void 0}=t:r=t),this.matches(md,{name:"datetime",message:r||Ye.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:r||Ye.datetime_offset,params:{allowOffset:n},skipAbsent:!0,test:o=>{if(!o||n)return!0;const a=$i(o);return a?!!a.z:!1}}).test({name:"datetime_precision",message:r||Ye.datetime_precision,params:{precision:i},skipAbsent:!0,test:o=>{if(!o||i==null)return!0;const a=$i(o);return a?a.precision===i:!1}})}ensure(){return this.default("").transform(t=>t===null?"":t)}trim(t=Ye.trim){return this.transform(r=>r!=null?r.trim():r).test({message:t,name:"trim",test:gd})}lowercase(t=Ye.lowercase){return this.transform(r=>st(r)?r:r.toLowerCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>st(r)||r===r.toLowerCase()})}uppercase(t=Ye.uppercase){return this.transform(r=>st(r)?r:r.toUpperCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>st(r)||r===r.toUpperCase()})}}an.prototype=Mi.prototype;let vd=e=>e!=+e;function Na(){return new Ri}class Ri extends Le{constructor(){super({type:"number",check(t){return t instanceof Number&&(t=t.valueOf()),typeof t=="number"&&!vd(t)}}),this.withMutation(()=>{this.transform((t,r,n)=>{if(!n.spec.coerce)return t;let i=t;if(typeof i=="string"){if(i=i.replace(/\s/g,""),i==="")return NaN;i=+i}return n.isType(i)||i===null?i:parseFloat(i)})})}min(t,r=Ot.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=Ot.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=Ot.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=Ot.moreThan){return this.test({message:r,name:"min",exclusive:!0,params:{more:t},skipAbsent:!0,test(n){return n>this.resolve(t)}})}positive(t=Ot.positive){return this.moreThan(0,t)}negative(t=Ot.negative){return this.lessThan(0,t)}integer(t=Ot.integer){return this.test({name:"integer",message:t,skipAbsent:!0,test:r=>Number.isInteger(r)})}truncate(){return this.transform(t=>st(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(i=>st(i)?i:Math[t](i))}}Na.prototype=Ri.prototype;let Fa=new Date(""),bd=e=>Object.prototype.toString.call(e)==="[object Date]";function Ni(){return new Qt}class Qt extends Le{constructor(){super({type:"date",check(t){return bd(t)&&!isNaN(t.getTime())}}),this.withMutation(()=>{this.transform((t,r,n)=>!n.spec.coerce||n.isType(t)||t===null?t:(t=ld(t),isNaN(t)?Qt.INVALID_DATE:new Date(t)))})}prepareParam(t,r){let n;if(kt.isRef(t))n=t;else{let i=this.cast(t);if(!this._typeCheck(i))throw new TypeError(`\`${r}\` must be a Date or a value that can be \`cast()\` to a Date`);n=i}return n}min(t,r=Ai.min){let n=this.prepareParam(t,"min");return this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(i){return i>=this.resolve(n)}})}max(t,r=Ai.max){let n=this.prepareParam(t,"max");return this.test({message:r,name:"max",exclusive:!0,params:{max:t},skipAbsent:!0,test(i){return i<=this.resolve(n)}})}}Qt.INVALID_DATE=Fa,Ni.prototype=Qt.prototype,Ni.INVALID_DATE=Fa;function xd(e,t=[]){let r=[],n=new Set,i=new Set(t.map(([a,s])=>`${a}-${s}`));function o(a,s){let l=zt.split(a)[0];n.add(l),i.has(`${s}-${l}`)||r.push([s,l])}for(const a of Object.keys(e)){let s=e[a];n.add(a),kt.isRef(s)&&s.isSibling?o(s.path,a):Bt(s)&&"deps"in s&&s.deps.forEach(l=>o(l,a))}return Xf.array(Array.from(n),r).reverse()}function La(e,t){let r=1/0;return e.some((n,i)=>{var o;if((o=t.path)!=null&&o.includes(n))return r=i,!0}),r}function za(e){return(t,r)=>La(e,t)-La(e,r)}const Ba=(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 sn(e){if("fields"in e){const t={};for(const[r,n]of Object.entries(e.fields))t[r]=sn(n);return e.setFields(t)}if(e.type==="array"){const t=e.optional();return t.innerType&&(t.innerType=sn(t.innerType)),t}return e.type==="tuple"?e.optional().clone({types:e.spec.types.map(sn)}):"optional"in e?e.optional():e}const Td=(e,t)=>{const r=[...zt.normalizePath(t)];if(r.length===1)return r[0]in e;let n=r.pop(),i=zt.getter(zt.join(r),!0)(e);return!!(i&&n in i)};let Ua=e=>Object.prototype.toString.call(e)==="[object Object]";function _d(e,t){let r=Object.keys(e.fields);return Object.keys(t).filter(n=>r.indexOf(n)===-1)}const Sd=za([]);function Sr(e){return new Fi(e)}class Fi extends Le{constructor(t){super({type:"object",check(r){return Ua(r)||typeof r=="function"}}),this.fields=Object.create(null),this._sortErrors=Sd,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{t&&this.shape(t)})}_cast(t,r={}){var n;let i=super._cast(t,r);if(i===void 0)return this.getDefault(r);if(!this._typeCheck(i))return i;let o=this.fields,a=(n=r.stripUnknown)!=null?n:this.spec.noUnknown,s=[].concat(this._nodes,Object.keys(i).filter(c=>!this._nodes.includes(c))),l={},u=Object.assign({},r,{parent:l,__validating:r.__validating||!1}),f=!1;for(const c of s){let p=o[c],v=c in i;if(p){let m,y=i[c];u.path=(r.path?`${r.path}.`:"")+c,p=p.resolve({value:y,context:r.context,parent:l});let T=p instanceof Le?p.spec:void 0,j=T==null?void 0:T.strict;if(T!=null&&T.strip){f=f||c in i;continue}m=!r.__validating||!j?p.cast(i[c],u):i[c],m!==void 0&&(l[c]=m)}else v&&!a&&(l[c]=i[c]);(v!==c in l||l[c]!==i[c])&&(f=!0)}return f?l:i}_validate(t,r={},n,i){let{from:o=[],originalValue:a=t,recursive:s=this.spec.recursive}=r;r.from=[{schema:this,value:a},...o],r.__validating=!0,r.originalValue=a,super._validate(t,r,n,(l,u)=>{if(!s||!Ua(u)){i(l,u);return}a=a||u;let f=[];for(let c of this._nodes){let p=this.fields[c];!p||kt.isRef(p)||f.push(p.asNestedTest({options:r,key:c,parent:u,parentPath:r.path,originalParent:a}))}this.runTests({tests:f,value:u,originalValue:a,options:r},n,c=>{i(c.sort(this._sortErrors).concat(l),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[i,o]of Object.entries(this.fields)){const a=n[i];n[i]=a===void 0?o:a}return r.withMutation(i=>i.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 i;const o=this.fields[n];let a=t;(i=a)!=null&&i.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[n]})),r[n]=o&&"getDefault"in o?o.getDefault(a):void 0}),r}setFields(t,r){let n=this.clone();return n.fields=t,n._nodes=xd(t,r),n._sortErrors=za(Object.keys(t)),r&&(n._excludedEdges=r),n}shape(t,r=[]){return this.clone().withMutation(n=>{let i=n._excludedEdges;return r.length&&(Array.isArray(r[0])||(r=[r]),i=[...n._excludedEdges,...r]),n.setFields(Object.assign(n.fields,t),i)})}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 sn(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,i])=>t.includes(n)&&t.includes(i)))}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 i=zt.getter(t,!0);return this.transform(o=>{if(!o)return o;let a=o;return Td(o,t)&&(a=Object.assign({},o),n||delete a[t],a[r]=i(o)),a})}json(){return this.transform(Ba)}noUnknown(t=!0,r=ki.noUnknown){typeof t!="boolean"&&(r=t,t=!0);let n=this.test({name:"noUnknown",exclusive:!0,message:r,test(i){if(i==null)return!0;const o=_d(this.schema,i);return!t||o.length===0||this.createError({params:{unknown:o.join(", ")}})}});return n.spec.noUnknown=t,n}unknown(t=!0,r=ki.noUnknown){return this.noUnknown(!t,r)}transformKeys(t){return this.transform(r=>{if(!r)return r;const n={};for(const i of Object.keys(r))n[t(i)]=r[i];return n})}camelCase(){return this.transformKeys(Ci.camelCase)}snakeCase(){return this.transformKeys(Ci.snakeCase)}constantCase(){return this.transformKeys(t=>Ci.snakeCase(t).toUpperCase())}describe(t){const r=(t?this.resolve(t):this).clone(),n=super.describe(t);n.fields={};for(const[o,a]of Object.entries(r.fields)){var i;let s=t;(i=s)!=null&&i.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[o]})),n.fields[o]=a.describe(s)}return n}}Sr.prototype=Fi.prototype;function Li(e){return new zi(e)}class zi extends Le{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 i=!1;const o=n.map((a,s)=>{const l=this.innerType.cast(a,Object.assign({},r,{path:`${r.path||""}[${s}]`}));return l!==a&&(i=!0),l});return i?o:n}_validate(t,r={},n,i){var o;let a=this.innerType,s=(o=r.recursive)!=null?o:this.spec.recursive;r.originalValue!=null&&r.originalValue,super._validate(t,r,n,(l,u)=>{var f;if(!s||!a||!this._typeCheck(u)){i(l,u);return}let c=new Array(u.length);for(let v=0;v<u.length;v++){var p;c[v]=a.asNestedTest({options:r,index:v,parent:u,parentPath:r.path,originalParent:(p=r.originalValue)!=null?p:t})}this.runTests({value:u,tests:c,originalValue:(f=r.originalValue)!=null?f:t,options:r},n,v=>i(v.concat(l),u))})}clone(t){const r=super.clone(t);return r.innerType=this.innerType,r}json(){return this.transform(Ba)}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(!Bt(t))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+dt(t));return r.innerType=t,r.spec=Object.assign({},r.spec,{types:t}),r}length(t,r=en.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||en.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||en.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,i,o)=>!t(n,i,o):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 i;let o=t;(i=o)!=null&&i.value&&(o=Object.assign({},o,{parent:o.value,value:o.value[0]})),n.innerType=r.innerType.describe(o)}return n}}Li.prototype=zi.prototype;function Va(e){return new Bi(e)}class Bi extends Le{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(Ma.notType)})}_cast(t,r){const{types:n}=this.spec,i=super._cast(t,r);if(!this._typeCheck(i))return i;let o=!1;const a=n.map((s,l)=>{const u=s.cast(i[l],Object.assign({},r,{path:`${r.path||""}[${l}]`}));return u!==i[l]&&(o=!0),u});return o?a:i}_validate(t,r={},n,i){let o=this.spec.types;super._validate(t,r,n,(a,s)=>{var l;if(!this._typeCheck(s)){i(a,s);return}let u=[];for(let[c,p]of o.entries()){var f;u[c]=p.asNestedTest({options:r,index:c,parent:s,parentPath:r.path,originalParent:(f=r.originalValue)!=null?f:t})}this.runTests({value:s,tests:u,originalValue:(l=r.originalValue)!=null?l:t,options:r},n,c=>i(c.concat(a),s))})}describe(t){const r=(t?this.resolve(t):this).clone(),n=super.describe(t);return n.innerType=r.spec.types.map((i,o)=>{var a;let s=t;return(a=s)!=null&&a.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[o]})),i.describe(s)}),n}}Va.prototype=Bi.prototype;function Ed(e){return new Ui(e)}class Ui{constructor(t){this.type="lazy",this.__isYupSchema__=!0,this.spec=void 0,this._resolve=(r,n={})=>{let i=this.builder(r,n);if(!Bt(i))throw new TypeError("lazy() functions must return a valid schema");return this.spec.optional&&(i=i.optional()),i.resolve(n)},this.builder=t,this.spec={meta:void 0,optional:!1}}clone(t){const r=new Ui(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:i,options:o}=t,a=i[n??r];return this._resolve(a,Object.assign({},o,{value:a,parent:i})).asNestedTest(t)}validate(t,r){return this._resolve(t,r).validate(t,r)}validateSync(t,r){return this._resolve(t,r).validateSync(t,r)}validateAt(t,r,n){return this._resolve(r,n).validateAt(t,r,n)}validateSyncAt(t,r,n){return this._resolve(r,n).validateSyncAt(t,r,n)}isValid(t,r){return this._resolve(t,r).isValid(t,r)}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 Cd(e){Object.keys(e).forEach(t=>{Object.keys(e[t]).forEach(r=>{Ra[t][r]=e[t][r]})})}function wd(e,t,r){if(!e||!Bt(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 Wa=Object.freeze(Object.defineProperty({__proto__:null,ArraySchema:zi,BooleanSchema:Di,DateSchema:Qt,MixedSchema:ji,NumberSchema:Ri,ObjectSchema:Fi,Schema:Le,StringSchema:Mi,TupleSchema:Bi,ValidationError:Fe,addMethod:wd,array:Li,bool:Ii,boolean:Ii,date:Ni,defaultLocale:Ra,getIn:Pi,isSchema:Bt,lazy:Ed,mixed:on,number:Na,object:Sr,printValue:dt,reach:od,ref:id,setLocale:Cd,string:an,tuple:Va},Symbol.toStringTag,{value:"Module"})),Ha=e=>{const t=e.reduce((r,n)=>{let{name:i,required:o,type:a}=n;switch(a){case"RelatedList":a="array";break;case"Related":a="object";break;case"Integer":case"Float":a="number";break;case"Geometry":case"Raw":a="mixed";break;default:a="string"}let s;try{o?s=Wa[a]().typeError(`Field must be of type ${a}`).required("Field is required"):s=Wa[a]().typeError(`Field must be of type ${a}`).nullable(!0)}catch(l){console.log(l)}return r[i]=s,r},{});return Sr().shape(t)};function Ga({path:e,autoInvoke:t=!0,clearDataOnRefetch:r=!1}){const{fetchPath:n,options:i}=_.useMemo(()=>ze({path:De(e,"_info"),method:"GET"}),[e]),{data:o,loading:a,refetch:s,error:l}=Xr(n,{autoInvoke:t,clearDataOnRefetch:r,...i});return{info:_.useMemo(()=>o?{...o,add:{columns:o.add_columns,title:o.add_title,schema:Ha(o.add_columns),defaultValues:_a(o.add_columns)},edit:{columns:o.edit_columns,title:o.edit_title,schema:Ha(o.edit_columns),defaultValues:_a(o.edit_columns)}}:null,[o]),loading:a,refetch:s,error:l}}const Ya={user:null,loading:!0,error:null};function Ad(e,t){switch(t.type){case"initCall":return{...Ya,user:e.user};case"setUser":return{...e,user:t.payload,error:null};case"setError":return{...e,loading:!1,error:t.payload};case"setLoading":return{...e,loading:t.payload};default:return e}}function Od(e){const[t,r]=_.useReducer(Ad,Ya),{user:n,refetch:i,loading:o}=xa({path:e});_.useEffect(()=>{r({type:"setLoading",payload:o})},[o]),_.useEffect(()=>{r({type:"setUser",payload:n})},[n]);const a=_.useCallback(async({username:c,password:p})=>{r({type:"initCall"});try{const v=new FormData;v.append("username",c),v.append("password",p);const{fetchPath:m,options:y}=ze({path:De(e,"auth/login"),method:"POST"}),T=await fetch(m,{...y,headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(v)});T.ok||(T.status===400?r({type:"setError",payload:"Username or password wrong."}):r({type:"setError",payload:"Couldn't sign in user"})),i()}catch(v){console.error("signin error",v),r({type:"setError",payload:"Failed to fetch"})}},[e,i]),s=_.useCallback(async()=>{r({type:"initCall"});try{const{fetchPath:c,options:p}=ze({path:De(e,"auth/logout"),method:"POST"});(await fetch(c,p)).ok||r({type:"setError",payload:"Couldn't sign out user"}),r({type:"setUser",payload:null})}catch(c){console.error("signout error",c),r({type:"setError",payload:"Failed to fetch"})}finally{r({type:"setLoading",payload:!1})}},[e]),l=_.useCallback(async c=>{r({type:"initCall"});try{const{fetchPath:p,options:v}=ze({path:De(e,"auth/user"),method:"PUT",body:c});(await fetch(p,v)).ok||r({type:"setError",payload:"Couldn't update user data"}),i()}catch(p){console.error("update error",p),r({type:"setError",payload:"Failed to post"})}},[e,i]),u=_.useCallback(async c=>{if(!n.email)return r({type:"setError",payload:"No email found"});try{const{fetchPath:p,options:v}=ze({path:De(e,"auth/forgot-password"),method:"POST",body:{email:n.email}}),m=await fetch(p,v);if(!m.ok){r({type:"setError",payload:"Couldn't request token to reset password"});return}const y=await m.json(),{token:T}=y,{fetchPath:j,options:R}=ze({path:De(e,"auth/reset-password"),method:"POST",body:{token:T,password:c}});if(!(await fetch(j,R)).ok){r({type:"setError",payload:"Couldn't reset password"});return}i()}catch(p){console.error("resetPassword error",p),r({type:"setError",payload:"Failed to post"})}},[e,i,n==null?void 0:n.email]),f=_.useCallback((c,p)=>{const v=De(e,"auth/login",c);if(p){const T=window.screenLeft+window.outerWidth/2-250,j=window.screenTop+window.outerHeight/2-500/2,R=window.open(v+"?popup=true","auth",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=500, height=500, top=${j}, left=${T}`),A=window.setInterval(function(){R.closed!==!1&&(window.clearInterval(A),i())},200);return}window.location.href=De(e,"auth/login",c)},[e,i]);return{user:t.user,loading:t.loading,error:t.error,signin:a,signout:s,update:l,resetPassword:u,oauth_signin:f}}function kd(e,t){const{user:r}=t,[n,i]=_.useState(null),[o,a]=_.useState(!0),[s,l]=_.useState({error:"401 Not authorized",message:"User is not logged in."});_.useEffect(()=>{r&&u(e)},[r]);const u=async f=>{a(!0);try{const{fetchPath:c,options:p}=ze({path:De(f,"info/"),method:"GET"}),v=await fetch(c,p);if(v.ok){const m=await v.json();i(m)}else l({error:"404 Not Found",message:"Couldn't fetch info"})}catch{l({error:"Network error",message:"Failed to fetch"})}finally{a(!1)}};return{info:n,loading:o,error:s}}const Vi=_.createContext({auth:{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},info:{info:null,loading:!1,error:null}});function qa(){return _.useContext(Vi).auth}function Ka(){return _.useContext(Vi).info}function Pd(e){const t={baseUrl:new URL(document.baseURI).pathname+"/api/v1",inheritMantineTheme:!1},{baseUrl:r,children:n}={...t,...e},i=Od(r),o={baseUrl:r,...kd(r,i)};return d.jsx(Vi.Provider,{value:{auth:i,info:o},children:n})}const jd=async(e,t,r)=>{const{fetchPath:n,options:i}=ze({path:De(t,"/download"),method:"POST"}),o=await fetch(n,{...i,body:JSON.stringify(r)});let a=null;const s=o.headers.get("content-type");if(s&&s.includes("application/json")?a=await o.json():a=await o.blob(),!o.ok)throw typeof a=="object"?new Error(typeof a.detail=="string"?a.detail:JSON.stringify(a,null,2)):new Error(a);const l=document.createElement("a"),u=URL.createObjectURL(a);l.href=u,l.download=e.toLowerCase()+".csv",l.click()};function Id({path:e,initialQueryParams:t,relation:r,fetchInfo:n=!0,clearInfoOnRefetch:i=!1,clearDataOnRefetch:o=!1,resetQueryParamsOnPathChange:a=!0,streaming:s=!1}){const[l,u]=_.useState(t?Jr(null,t):null),f=_.useMemo(()=>r?{...l,filters:[...l.filters,{col:r.foreign_key,opr:r.type,value:Ze(r.id)}]}:l,[r,l]),c=_.useCallback(Y=>u(ie=>{if(!ie)return Jr(null,Y);const ce=Jr({...ie},Y);if(s){if(Y.page&&Y.page!==ie.page&&!Y.streaming)throw new Error("You cannot change page in streaming mode, use streaming.fetch() instead");if(Y.page_size&&Y.page_size!==ie.page_size)throw new Error("You cannot change page size in streaming mode, use streaming.fetch() instead");(Y.filters||Y.order_column||Y.order_direction)&&(ce.page=0)}return ce}),[s]),[p,v]=_.useState(null),m=_.useMemo(()=>p,[p]),y=_.useCallback(()=>v(null),[]),{info:T,loading:j,refetch:R,error:A}=Ga({path:e,autoInvoke:n,clearDataOnRefetch:i}),{data:N,loading:S,refetch:D,error:G}=Ta({path:e,queryParams:f,autoInvoke:!1,clearDataOnRefetch:o});_.useEffect(()=>{f&&D()},[D,f]),_.useEffect(()=>{if(A){v({message:"Couldn't fetch info",originalError:A});return}if(G){v({message:"Couldn't fetch list",originalError:G});return}y()},[A,G,y]);const se=_.useMemo(()=>j||S,[j,S]);At.useDidUpdate(()=>{a&&c(Jr(null,t||{}))},[e]);const h=_.useCallback(async Y=>{try{const ie=await Mf(e,Ze(Y));return y(),ie}catch(ie){v({message:`Couldn't fetch item with id ${Y}`,originalError:ie})}},[e,y]),F=_.useCallback(async(Y,ie)=>{try{const ce=await Df(e,Y);return ie||(R(),D()),y(),ce}catch(ce){v({message:"Couldn't add item",originalError:ce})}},[D,R,e,y]),L=_.useCallback(async(Y,ie,ce)=>{try{const He=await Rf(e,Ze(Y),ie);return ce||(R(),D()),y(),He}catch(He){v({message:`Couldn't update item with id ${Y}`,originalError:He})}},[D,R,e,y]),V=_.useCallback(async(Y,ie)=>{try{const ce=await $f(e,Ze(Y));return ie||(R(),D()),y(),ce}catch(ce){v({message:`Couldn't delete item with id ${Y}`,originalError:ce})}},[D,R,e,y]),te=_.useCallback(async Y=>{try{await jd(Y,e,f)}catch(ie){v({message:"Couldn't download",originalError:ie})}},[e,f]),[le,Te]=At.useSetState({data:{},isEnd:!1,fetch:()=>{throw new Error("Streaming mode not enabled, enable it by adding `streaming` prop to ApiProvider")}});return _.useEffect(()=>{s&&Te({fetch:()=>c({page:0,streaming:!0})})},[c,Te,s]),_.useEffect(()=>{s&&N&&Te(Y=>{let ie=Object.keys(Y.data).length;const ce={isEnd:!1};return f.page<ie?(ie=f.page,ce.data={[f.page]:N.result}):ce.data={...Y.data,[f.page]:N.result},N.result.length<f.page_size?(ce.isEnd=!0,ce.fetch=()=>null):ce.fetch=()=>c({page:ie+1,streaming:!0}),ce})},[N,c,Te,s]),{path:e,data:N,info:T,queryParams:f,loading:se,error:m,streaming:le,setQueryParams:c,refetch:D,refetchInfo:R,getEntry:h,addEntry:F,updateEntry:L,deleteEntry:V,download:te}}const Dd=async(e,t,r)=>{const{fetchPath:n,options:i}=ze({path:De(e,"/bulk",t),method:"POST",body:r}),o=await fetch(n,i);let a=null;const s=o.headers.get("content-type");if(s&&s.includes("application/json")?a=await o.json():a=await o.text(),!o.ok)throw typeof a=="object"?new Error(typeof a.detail=="string"?a.detail:JSON.stringify(a,null,2)):new Error(a);return a},$d=({Api:e})=>{const[t,r]=_.useState([]),[n,i]=_.useState(null),o=_.useCallback(async(s,l)=>{try{i(null);const u=await Dd(e.path,s,t);return l?void 0:(e.refetch(),u)}catch(u){console.error(u),i({message:"Couldn't perform bulk action",originalError:u})}},[e,t]);return{bulkActions:_.useMemo(()=>({selectedIds:t,setSelectedIds:r}),[t,r]),dispatchBulkActions:o,error:n}},Wi=_.createContext({Api:{path:"",data:null,info:null,queryParams:null,loading:!1,error:null,streaming: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},BulkActions:{bulkActions:{selectedIds:[],setSelectedIds:()=>{}},dispatchBulkActions:async(e,t)=>{},error:null}});function $e(){const e=_.useContext(Wi);if(e===void 0)throw new Error("useApi must be used within a ApiProvider");return e.Api}function Md(){const e=_.useContext(Wi);if(e===void 0)throw new Error("useBulkActions must be used within a ApiProvider");return e.BulkActions}function Xa({resource_name:e="",initialQueryParams:t,relation:r,fetchInfo:n,clearInfoOnRefetch:i,clearDataOnRefetch:o,resetQueryParamsOnPathChange:a,children:s,streaming:l}){const{baseUrl:u}=Ka(),f=Id({path:De(u,e),initialQueryParams:t,relation:r,fetchInfo:n,clearInfoOnRefetch:i,clearDataOnRefetch:o,resetQueryParamsOnPathChange:a,streaming:l}),c=$d({path:De(u,e),Api:f});return d.jsx(Wi.Provider,{value:{Api:f,BulkActions:c},children:s})}function Hi(e){return t=>{try{return e.validateSync(t,{abortEarly:!1}),{}}catch(r){const n={};return r instanceof Fe&&r.inner.forEach(i=>{n[i.path.replaceAll("[",".").replaceAll("]","")]=i.message}),n}}}function Rd({form:e,name:t,...r}){return d.jsx(d.Fragment,{children:d.jsx(Xt.DateInput,{...e.getInputProps(t),onChange:n=>{if(n instanceof Date){const i=new Date(n.getTime()-n.getTimezoneOffset()*6e4);e.setFieldValue(t,i.toISOString().substring(0,10))}},value:e.getInputProps(t).value?new Date(e.getInputProps(t).value):null,...r})})}function Nd({form:e,name:t,...r}){return d.jsx(d.Fragment,{children:d.jsx(Xt.DateTimePicker,{...e.getInputProps(t),onChange:n=>{if(n instanceof Date){const i=new Date(n);e.setFieldValue(t,i.toISOString())}},value:e.getInputProps(t).value?new Date(e.getInputProps(t).value):null,...r})})}function ln({form:e,name:t,...r}){const n=e.getInputProps(t).value,i=_.useMemo(()=>n&&typeof n=="object"?JSON.stringify(n):n||"",[n]);return t==="password"?d.jsx(b.PasswordInput,{...e.getInputProps(t),value:i,...r}):d.jsx(b.TextInput,{...e.getInputProps(t),value:i,...r})}function Ja({form:e,name:t,filter:r,...n}){const[i,o]=_.useState(""),a=e.getInputProps(t).value,s=_.useMemo(()=>a?typeof a=="object"?JSON.stringify(a,null,2):a:"",[a]);return _.useEffect(()=>{o(s)},[s]),r?d.jsx(ln,{form:e,name:t,...n}):d.jsx(b.JsonInput,{autosize:!0,minRows:4,maxRows:12,validationError:"Invalid JSON",...e.getInputProps(t),...n,value:i,onChange:l=>{if(o(l),!l){e.getInputProps(t).onChange(null);return}try{const u=JSON.parse(l);e.getInputProps(t).onChange(u)}catch{}}})}function Fd({form:e,name:t,filter:r,...n}){const[i,o]=_.useState(!!r);return d.jsxs(b.InputWrapper,{label:n.label,description:n.description,children:[!r&&d.jsxs(b.Group,{align:"center",gap:"xs",py:"0.25rem",children:[d.jsx(b.Checkbox,{checked:i,onChange:a=>o(a.currentTarget.checked)}),d.jsx(b.Text,{size:"xs",children:"WKT"})]}),i?d.jsx(ln,{form:e,name:t,...n,label:void 0,description:void 0}):d.jsx(Ja,{form:e,name:t,...n,label:void 0,description:void 0})]})}function Ld({form:e,name:t,items:r,...n}){const i=r.map(a=>({value:String(Ze(a.id)),label:a.value})),o=Array.isArray(e.getInputProps(t).value)?e.getInputProps(t).value.map(a=>String(typeof a=="object"?Ze(a.id):a)):[];return d.jsx(b.MultiSelect,{data:i,searchable:!0,...e.getInputProps(t),value:o||[],...n})}function zd({form:e,name:t,items:r,filter:n,...i}){var a;const o=r.map(s=>({value:String(Ze(s.id)),label:s.value}));return d.jsx(b.Select,{data:o,searchable:!0,...e.getInputProps(t),onChange:s=>{if(n){e.setFieldValue(t,s);return}const l=r.find(u=>String(Ze(u.id))===s)||null;e.setFieldValue(t,l)},value:n?e.getInputProps(t).value:String(Ze((a=e.getInputProps(t).value)==null?void 0:a.id))||"",...i})}function Za({form:e,name:t,items:r,...n}){return d.jsx(b.Select,{data:r,searchable:!0,...e.getInputProps(t),value:String(e.getInputProps(t).value)||"",...n})}function Gi({form:e,name:t,schema:r,filter:n,...i}){if(!r.type)return null;switch(r.type){case"Boolean":return d.jsx(Za,{form:e,name:t,items:[{label:"true",value:n?"1":"true"},{label:"false",value:n?"0":"false"}],...i});case"RelatedList":return d.jsx(Ld,{form:e,name:t,items:r.values,...i});case"Related":return d.jsx(zd,{form:e,name:t,items:r.values,filter:n,...i});case"DateTime":return d.jsx(Nd,{form:e,name:t,valueFormat:"DD.MM.YYYY HH:mm:ss",schema:r,...i});case"Date":return d.jsx(Rd,{form:e,name:t,valueFormat:"DD.MM.YYYY",schema:r,...i});case"Geometry":return d.jsx(Fd,{form:e,name:t,filter:n,...i});case"Raw":return d.jsx(Ja,{form:e,name:t,filter:n,...i});case"Integer":case"Float":return d.jsx(ln,{form:e,name:t,...i});case"Enum":return d.jsx(Za,{form:e,name:t,items:r.values,...i});default:return d.jsx(ln,{form:e,name:t,...i})}}function Qa({opened:e,onClose:t,...r}){const{info:n,addEntry:i}=$e(),o={modal:{},stack:{},addButton:{}},{addButton:a,modal:s,stack:l}=b.useProps("AddDialog",o,r),u=vi.useForm({initialValues:n.add.defaultValues,validate:Hi(n.add.schema)}),f=async c=>{await i(c),u.reset(),t()};return _.useEffect(()=>{u.setInitialValues(n.add.defaultValues),u.reset()},[n.add.defaultValues]),d.jsx(b.Modal,{opened:e,onClose:()=>{u.reset(),t()},title:n.add.title,size:"lg",centered:!0,...s,children:d.jsx(b.Box,{component:"form",onSubmit:u.onSubmit(f),children:d.jsx(b.Stack,{spacing:"md",...l,children:d.jsxs(b.ScrollArea.Autosize,{mah:450,type:"auto",children:[n.add.columns.map((c,p)=>d.jsx(Gi,{form:u,name:c.name,label:c.label,description:c.description,schema:c,withAsterisk:c.required},p)),d.jsx(b.Group,{position:"right",mt:"xl",children:d.jsx(b.Button,{type:"submit",...a,children:"Add"})})]})})})})}/**
33
+ `+(s!==a?`result of cast: ${s}`:""))}return o}_cast(t,r){let n=t===void 0?t:this.transforms.reduce((i,o)=>o.call(this,i,t,this),t);return n===void 0&&(n=this.getDefault(r)),n}_validate(t,r={},n,i){let{path:o,originalValue:a=t,strict:s=this.spec.strict}=r,l=t;s||(l=this._cast(l,Object.assign({assert:!1},r)));let u=[];for(let f of Object.values(this.internalTests))f&&u.push(f);this.runTests({path:o,value:l,originalValue:a,options:r,tests:u},n,f=>{if(f.length)return i(f,l);this.runTests({path:o,value:l,originalValue:a,options:r,tests:this.tests},n,i)})}runTests(t,r,n){let i=!1,{tests:o,value:a,originalValue:s,path:l,options:u}=t,f=y=>{i||(i=!0,r(y,a))},c=y=>{i||(i=!0,n(y,a))},p=o.length,v=[];if(!p)return c([]);let m={value:a,originalValue:s,path:l,options:u,schema:this};for(let y=0;y<o.length;y++){const T=o[y];T(m,f,function(R){R&&(Array.isArray(R)?v.push(...R):v.push(R)),--p<=0&&c(v)})}}asNestedTest({key:t,index:r,parent:n,parentPath:i,originalParent:o,options:a}){const s=t??r;if(s==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof s=="number";let u=n[s];const f=Object.assign({},a,{strict:!0,parent:n,value:u,originalValue:o[s],key:void 0,[l?"index":"key"]:s,path:l||s.includes(".")?`${i||""}[${l?s:`"${s}"`}]`:(i?`${i}.`:"")+t});return(c,p,v)=>this.resolve(f)._validate(u,f,p,v)}validate(t,r){var n;let i=this.resolve(Object.assign({},r,{value:t})),o=(n=r==null?void 0:r.disableStackTrace)!=null?n:i.spec.disableStackTrace;return new Promise((a,s)=>i._validate(t,r,(l,u)=>{Fe.isError(l)&&(l.value=u),s(l)},(l,u)=>{l.length?s(new Fe(l,u,void 0,void 0,o)):a(u)}))}validateSync(t,r){var n;let i=this.resolve(Object.assign({},r,{value:t})),o,a=(n=r==null?void 0:r.disableStackTrace)!=null?n:i.spec.disableStackTrace;return i._validate(t,Object.assign({},r,{sync:!0}),(s,l)=>{throw Fe.isError(s)&&(s.value=l),s},(s,l)=>{if(s.length)throw new Fe(s,t,void 0,void 0,a);o=l}),o}isValid(t,r){return this.validate(t,r).then(()=>!0,n=>{if(Fe.isError(n))return!1;throw n})}isValidSync(t,r){try{return this.validateSync(t,r),!0}catch(n){if(Fe.isError(n))return!1;throw n}}_getDefault(t){let r=this.spec.default;return r==null?r:typeof r=="function"?r.call(this,t):Zt(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=Jt({message:r,name:"nullable",test(i){return i===null?this.schema.spec.nullable:!0}}),n}optionality(t,r){const n=this.clone({optional:t});return n.internalTests.optionality=Jt({message:r,name:"optionality",test(i){return i===void 0?this.schema.spec.optional:!0}}),n}optional(){return this.optionality(!0)}defined(t=pt.defined){return this.optionality(!1,t)}nullable(){return this.nullability(!0)}nonNullable(t=pt.notNull){return this.nullability(!1,t)}required(t=pt.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=pt.default),typeof r.test!="function")throw new TypeError("`test` is a required parameters");let n=this.clone(),i=Jt(r),o=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(a=>!(a.OPTIONS.name===r.name&&(o||a.OPTIONS.test===i.OPTIONS.test))),n.tests.push(i),n}when(t,r){!Array.isArray(t)&&typeof t!="string"&&(r=t,t=".");let n=this.clone(),i=Pa(t).map(o=>new kt(o));return i.forEach(o=>{o.isSibling&&n.deps.push(o.key)}),n.conditions.push(typeof r=="function"?new tn(i,r):tn.fromOptions(i,r)),n}typeError(t){let r=this.clone();return r.internalTests.typeError=Jt({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=pt.oneOf){let n=this.clone();return t.forEach(i=>{n._whitelist.add(i),n._blacklist.delete(i)}),n.internalTests.whiteList=Jt({message:r,name:"oneOf",skipAbsent:!0,test(i){let o=this.schema._whitelist,a=o.resolveAll(this.resolve);return a.includes(i)?!0:this.createError({params:{values:Array.from(o).join(", "),resolved:a}})}}),n}notOneOf(t,r=pt.notOneOf){let n=this.clone();return t.forEach(i=>{n._blacklist.add(i),n._whitelist.delete(i)}),n.internalTests.blacklist=Jt({message:r,name:"notOneOf",test(i){let o=this.schema._blacklist,a=o.resolveAll(this.resolve);return a.includes(i)?this.createError({params:{values:Array.from(o).join(", "),resolved:a}}):!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:i,optional:o,nullable:a}=r.spec;return{meta:i,label:n,optional:o,nullable:a,default:r.getDefault(t),type:r.type,oneOf:r._whitelist.describe(),notOneOf:r._blacklist.describe(),tests:r.tests.map(l=>({name:l.OPTIONS.name,params:l.OPTIONS.params})).filter((l,u,f)=>f.findIndex(c=>c.name===l.name)===u)}}}Le.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])Le.prototype[`${e}At`]=function(t,r,n={}){const{parent:i,parentPath:o,schema:a}=Pi(this,t,r,n.context);return a[e](i&&i[o],Object.assign({},n,{parent:i,path:t}))};for(const e of["equals","is"])Le.prototype[e]=Le.prototype.oneOf;for(const e of["not","nope"])Le.prototype[e]=Le.prototype.notOneOf;const ad=()=>!0;function on(e){return new ji(e)}class ji extends Le{constructor(t){super(typeof t=="function"?{type:"mixed",check:t}:Object.assign({type:"mixed",check:ad},t))}}on.prototype=ji.prototype;function Ii(){return new Di}class Di extends Le{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=Oi.isValue){return this.test({message:t,name:"is-value",exclusive:!0,params:{value:"true"},test(r){return st(r)||r===!0}})}isFalse(t=Oi.isValue){return this.test({message:t,name:"is-value",exclusive:!0,params:{value:"false"},test(r){return st(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)}}Ii.prototype=Di.prototype;const sd=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function ld(e){const t=$i(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 $i(e){var t,r;const n=sd.exec(e);return n?{year:vt(n[1]),month:vt(n[2],1)-1,day:vt(n[3],1),hour:vt(n[4]),minute:vt(n[5]),second:vt(n[6]),millisecond:n[7]?vt(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:vt(n[10]),minuteOffset:vt(n[11])}:null}function vt(e,t=0){return Number(e)||t}let ud=/^[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])?)*$/,cd=/^((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,fd=/^(?:[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,dd="^\\d{4}-\\d{2}-\\d{2}",pd="\\d{2}:\\d{2}:\\d{2}",hd="(([+-]\\d{2}(:?\\d{2})?)|Z)",md=new RegExp(`${dd}T${pd}(\\.\\d+)?${hd}$`),gd=e=>st(e)||e===e.trim(),yd={}.toString();function an(){return new Mi}class Mi extends Le{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 i=t!=null&&t.toString?t.toString():t;return i===yd?t:i})})}required(t){return super.required(t).withMutation(r=>r.test({message:t||pt.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=Ye.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=Ye.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=Ye.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,i,o;return r&&(typeof r=="object"?{excludeEmptyString:n=!1,message:i,name:o}=r:i=r),this.test({name:o||"matches",message:i||Ye.matches,params:{regex:t},skipAbsent:!0,test:a=>a===""&&n||a.search(t)!==-1})}email(t=Ye.email){return this.matches(ud,{name:"email",message:t,excludeEmptyString:!0})}url(t=Ye.url){return this.matches(cd,{name:"url",message:t,excludeEmptyString:!0})}uuid(t=Ye.uuid){return this.matches(fd,{name:"uuid",message:t,excludeEmptyString:!1})}datetime(t){let r="",n,i;return t&&(typeof t=="object"?{message:r="",allowOffset:n=!1,precision:i=void 0}=t:r=t),this.matches(md,{name:"datetime",message:r||Ye.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:r||Ye.datetime_offset,params:{allowOffset:n},skipAbsent:!0,test:o=>{if(!o||n)return!0;const a=$i(o);return a?!!a.z:!1}}).test({name:"datetime_precision",message:r||Ye.datetime_precision,params:{precision:i},skipAbsent:!0,test:o=>{if(!o||i==null)return!0;const a=$i(o);return a?a.precision===i:!1}})}ensure(){return this.default("").transform(t=>t===null?"":t)}trim(t=Ye.trim){return this.transform(r=>r!=null?r.trim():r).test({message:t,name:"trim",test:gd})}lowercase(t=Ye.lowercase){return this.transform(r=>st(r)?r:r.toLowerCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>st(r)||r===r.toLowerCase()})}uppercase(t=Ye.uppercase){return this.transform(r=>st(r)?r:r.toUpperCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>st(r)||r===r.toUpperCase()})}}an.prototype=Mi.prototype;let vd=e=>e!=+e;function Na(){return new Ri}class Ri extends Le{constructor(){super({type:"number",check(t){return t instanceof Number&&(t=t.valueOf()),typeof t=="number"&&!vd(t)}}),this.withMutation(()=>{this.transform((t,r,n)=>{if(!n.spec.coerce)return t;let i=t;if(typeof i=="string"){if(i=i.replace(/\s/g,""),i==="")return NaN;i=+i}return n.isType(i)||i===null?i:parseFloat(i)})})}min(t,r=Ot.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=Ot.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=Ot.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=Ot.moreThan){return this.test({message:r,name:"min",exclusive:!0,params:{more:t},skipAbsent:!0,test(n){return n>this.resolve(t)}})}positive(t=Ot.positive){return this.moreThan(0,t)}negative(t=Ot.negative){return this.lessThan(0,t)}integer(t=Ot.integer){return this.test({name:"integer",message:t,skipAbsent:!0,test:r=>Number.isInteger(r)})}truncate(){return this.transform(t=>st(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(i=>st(i)?i:Math[t](i))}}Na.prototype=Ri.prototype;let Fa=new Date(""),bd=e=>Object.prototype.toString.call(e)==="[object Date]";function Ni(){return new Qt}class Qt extends Le{constructor(){super({type:"date",check(t){return bd(t)&&!isNaN(t.getTime())}}),this.withMutation(()=>{this.transform((t,r,n)=>!n.spec.coerce||n.isType(t)||t===null?t:(t=ld(t),isNaN(t)?Qt.INVALID_DATE:new Date(t)))})}prepareParam(t,r){let n;if(kt.isRef(t))n=t;else{let i=this.cast(t);if(!this._typeCheck(i))throw new TypeError(`\`${r}\` must be a Date or a value that can be \`cast()\` to a Date`);n=i}return n}min(t,r=Ai.min){let n=this.prepareParam(t,"min");return this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(i){return i>=this.resolve(n)}})}max(t,r=Ai.max){let n=this.prepareParam(t,"max");return this.test({message:r,name:"max",exclusive:!0,params:{max:t},skipAbsent:!0,test(i){return i<=this.resolve(n)}})}}Qt.INVALID_DATE=Fa,Ni.prototype=Qt.prototype,Ni.INVALID_DATE=Fa;function xd(e,t=[]){let r=[],n=new Set,i=new Set(t.map(([a,s])=>`${a}-${s}`));function o(a,s){let l=zt.split(a)[0];n.add(l),i.has(`${s}-${l}`)||r.push([s,l])}for(const a of Object.keys(e)){let s=e[a];n.add(a),kt.isRef(s)&&s.isSibling?o(s.path,a):Bt(s)&&"deps"in s&&s.deps.forEach(l=>o(l,a))}return Xf.array(Array.from(n),r).reverse()}function La(e,t){let r=1/0;return e.some((n,i)=>{var o;if((o=t.path)!=null&&o.includes(n))return r=i,!0}),r}function za(e){return(t,r)=>La(e,t)-La(e,r)}const Ba=(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 sn(e){if("fields"in e){const t={};for(const[r,n]of Object.entries(e.fields))t[r]=sn(n);return e.setFields(t)}if(e.type==="array"){const t=e.optional();return t.innerType&&(t.innerType=sn(t.innerType)),t}return e.type==="tuple"?e.optional().clone({types:e.spec.types.map(sn)}):"optional"in e?e.optional():e}const Td=(e,t)=>{const r=[...zt.normalizePath(t)];if(r.length===1)return r[0]in e;let n=r.pop(),i=zt.getter(zt.join(r),!0)(e);return!!(i&&n in i)};let Ua=e=>Object.prototype.toString.call(e)==="[object Object]";function _d(e,t){let r=Object.keys(e.fields);return Object.keys(t).filter(n=>r.indexOf(n)===-1)}const Sd=za([]);function Sr(e){return new Fi(e)}class Fi extends Le{constructor(t){super({type:"object",check(r){return Ua(r)||typeof r=="function"}}),this.fields=Object.create(null),this._sortErrors=Sd,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{t&&this.shape(t)})}_cast(t,r={}){var n;let i=super._cast(t,r);if(i===void 0)return this.getDefault(r);if(!this._typeCheck(i))return i;let o=this.fields,a=(n=r.stripUnknown)!=null?n:this.spec.noUnknown,s=[].concat(this._nodes,Object.keys(i).filter(c=>!this._nodes.includes(c))),l={},u=Object.assign({},r,{parent:l,__validating:r.__validating||!1}),f=!1;for(const c of s){let p=o[c],v=c in i;if(p){let m,y=i[c];u.path=(r.path?`${r.path}.`:"")+c,p=p.resolve({value:y,context:r.context,parent:l});let T=p instanceof Le?p.spec:void 0,j=T==null?void 0:T.strict;if(T!=null&&T.strip){f=f||c in i;continue}m=!r.__validating||!j?p.cast(i[c],u):i[c],m!==void 0&&(l[c]=m)}else v&&!a&&(l[c]=i[c]);(v!==c in l||l[c]!==i[c])&&(f=!0)}return f?l:i}_validate(t,r={},n,i){let{from:o=[],originalValue:a=t,recursive:s=this.spec.recursive}=r;r.from=[{schema:this,value:a},...o],r.__validating=!0,r.originalValue=a,super._validate(t,r,n,(l,u)=>{if(!s||!Ua(u)){i(l,u);return}a=a||u;let f=[];for(let c of this._nodes){let p=this.fields[c];!p||kt.isRef(p)||f.push(p.asNestedTest({options:r,key:c,parent:u,parentPath:r.path,originalParent:a}))}this.runTests({tests:f,value:u,originalValue:a,options:r},n,c=>{i(c.sort(this._sortErrors).concat(l),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[i,o]of Object.entries(this.fields)){const a=n[i];n[i]=a===void 0?o:a}return r.withMutation(i=>i.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 i;const o=this.fields[n];let a=t;(i=a)!=null&&i.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[n]})),r[n]=o&&"getDefault"in o?o.getDefault(a):void 0}),r}setFields(t,r){let n=this.clone();return n.fields=t,n._nodes=xd(t,r),n._sortErrors=za(Object.keys(t)),r&&(n._excludedEdges=r),n}shape(t,r=[]){return this.clone().withMutation(n=>{let i=n._excludedEdges;return r.length&&(Array.isArray(r[0])||(r=[r]),i=[...n._excludedEdges,...r]),n.setFields(Object.assign(n.fields,t),i)})}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 sn(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,i])=>t.includes(n)&&t.includes(i)))}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 i=zt.getter(t,!0);return this.transform(o=>{if(!o)return o;let a=o;return Td(o,t)&&(a=Object.assign({},o),n||delete a[t],a[r]=i(o)),a})}json(){return this.transform(Ba)}noUnknown(t=!0,r=ki.noUnknown){typeof t!="boolean"&&(r=t,t=!0);let n=this.test({name:"noUnknown",exclusive:!0,message:r,test(i){if(i==null)return!0;const o=_d(this.schema,i);return!t||o.length===0||this.createError({params:{unknown:o.join(", ")}})}});return n.spec.noUnknown=t,n}unknown(t=!0,r=ki.noUnknown){return this.noUnknown(!t,r)}transformKeys(t){return this.transform(r=>{if(!r)return r;const n={};for(const i of Object.keys(r))n[t(i)]=r[i];return n})}camelCase(){return this.transformKeys(Ci.camelCase)}snakeCase(){return this.transformKeys(Ci.snakeCase)}constantCase(){return this.transformKeys(t=>Ci.snakeCase(t).toUpperCase())}describe(t){const r=(t?this.resolve(t):this).clone(),n=super.describe(t);n.fields={};for(const[o,a]of Object.entries(r.fields)){var i;let s=t;(i=s)!=null&&i.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[o]})),n.fields[o]=a.describe(s)}return n}}Sr.prototype=Fi.prototype;function Li(e){return new zi(e)}class zi extends Le{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 i=!1;const o=n.map((a,s)=>{const l=this.innerType.cast(a,Object.assign({},r,{path:`${r.path||""}[${s}]`}));return l!==a&&(i=!0),l});return i?o:n}_validate(t,r={},n,i){var o;let a=this.innerType,s=(o=r.recursive)!=null?o:this.spec.recursive;r.originalValue!=null&&r.originalValue,super._validate(t,r,n,(l,u)=>{var f;if(!s||!a||!this._typeCheck(u)){i(l,u);return}let c=new Array(u.length);for(let v=0;v<u.length;v++){var p;c[v]=a.asNestedTest({options:r,index:v,parent:u,parentPath:r.path,originalParent:(p=r.originalValue)!=null?p:t})}this.runTests({value:u,tests:c,originalValue:(f=r.originalValue)!=null?f:t,options:r},n,v=>i(v.concat(l),u))})}clone(t){const r=super.clone(t);return r.innerType=this.innerType,r}json(){return this.transform(Ba)}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(!Bt(t))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+dt(t));return r.innerType=t,r.spec=Object.assign({},r.spec,{types:t}),r}length(t,r=en.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||en.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||en.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,i,o)=>!t(n,i,o):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 i;let o=t;(i=o)!=null&&i.value&&(o=Object.assign({},o,{parent:o.value,value:o.value[0]})),n.innerType=r.innerType.describe(o)}return n}}Li.prototype=zi.prototype;function Va(e){return new Bi(e)}class Bi extends Le{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(Ma.notType)})}_cast(t,r){const{types:n}=this.spec,i=super._cast(t,r);if(!this._typeCheck(i))return i;let o=!1;const a=n.map((s,l)=>{const u=s.cast(i[l],Object.assign({},r,{path:`${r.path||""}[${l}]`}));return u!==i[l]&&(o=!0),u});return o?a:i}_validate(t,r={},n,i){let o=this.spec.types;super._validate(t,r,n,(a,s)=>{var l;if(!this._typeCheck(s)){i(a,s);return}let u=[];for(let[c,p]of o.entries()){var f;u[c]=p.asNestedTest({options:r,index:c,parent:s,parentPath:r.path,originalParent:(f=r.originalValue)!=null?f:t})}this.runTests({value:s,tests:u,originalValue:(l=r.originalValue)!=null?l:t,options:r},n,c=>i(c.concat(a),s))})}describe(t){const r=(t?this.resolve(t):this).clone(),n=super.describe(t);return n.innerType=r.spec.types.map((i,o)=>{var a;let s=t;return(a=s)!=null&&a.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[o]})),i.describe(s)}),n}}Va.prototype=Bi.prototype;function Ed(e){return new Ui(e)}class Ui{constructor(t){this.type="lazy",this.__isYupSchema__=!0,this.spec=void 0,this._resolve=(r,n={})=>{let i=this.builder(r,n);if(!Bt(i))throw new TypeError("lazy() functions must return a valid schema");return this.spec.optional&&(i=i.optional()),i.resolve(n)},this.builder=t,this.spec={meta:void 0,optional:!1}}clone(t){const r=new Ui(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:i,options:o}=t,a=i[n??r];return this._resolve(a,Object.assign({},o,{value:a,parent:i})).asNestedTest(t)}validate(t,r){return this._resolve(t,r).validate(t,r)}validateSync(t,r){return this._resolve(t,r).validateSync(t,r)}validateAt(t,r,n){return this._resolve(r,n).validateAt(t,r,n)}validateSyncAt(t,r,n){return this._resolve(r,n).validateSyncAt(t,r,n)}isValid(t,r){return this._resolve(t,r).isValid(t,r)}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 Cd(e){Object.keys(e).forEach(t=>{Object.keys(e[t]).forEach(r=>{Ra[t][r]=e[t][r]})})}function wd(e,t,r){if(!e||!Bt(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 Wa=Object.freeze(Object.defineProperty({__proto__:null,ArraySchema:zi,BooleanSchema:Di,DateSchema:Qt,MixedSchema:ji,NumberSchema:Ri,ObjectSchema:Fi,Schema:Le,StringSchema:Mi,TupleSchema:Bi,ValidationError:Fe,addMethod:wd,array:Li,bool:Ii,boolean:Ii,date:Ni,defaultLocale:Ra,getIn:Pi,isSchema:Bt,lazy:Ed,mixed:on,number:Na,object:Sr,printValue:dt,reach:od,ref:id,setLocale:Cd,string:an,tuple:Va},Symbol.toStringTag,{value:"Module"})),Ha=e=>{const t=e.reduce((r,n)=>{let{name:i,required:o,type:a}=n;switch(a){case"RelatedList":a="array";break;case"Related":a="object";break;case"Integer":case"Float":a="number";break;case"Geometry":case"Raw":a="mixed";break;default:a="string"}let s;try{o?s=Wa[a]().typeError(`Field must be of type ${a}`).required("Field is required"):s=Wa[a]().typeError(`Field must be of type ${a}`).nullable(!0)}catch(l){console.log(l)}return r[i]=s,r},{});return Sr().shape(t)};function Ga({path:e,autoInvoke:t=!0,clearDataOnRefetch:r=!1}){const{fetchPath:n,options:i}=_.useMemo(()=>ze({path:De(e,"_info"),method:"GET"}),[e]),{data:o,loading:a,refetch:s,error:l}=Xr(n,{autoInvoke:t,clearDataOnRefetch:r,...i});return{info:_.useMemo(()=>o?{...o,add:{columns:o.add_columns,title:o.add_title,schema:Ha(o.add_columns),defaultValues:_a(o.add_columns)},edit:{columns:o.edit_columns,title:o.edit_title,schema:Ha(o.edit_columns),defaultValues:_a(o.edit_columns)}}:null,[o]),loading:a,refetch:s,error:l}}const Ya={user:null,loading:!0,error:null};function Ad(e,t){switch(t.type){case"initCall":return{...Ya,user:e.user};case"setUser":return{...e,user:t.payload,error:null};case"setError":return{...e,loading:!1,error:t.payload};case"setLoading":return{...e,loading:t.payload};default:return e}}function Od(e){const[t,r]=_.useReducer(Ad,Ya),{user:n,refetch:i,loading:o}=xa({path:e});_.useEffect(()=>{r({type:"setLoading",payload:o})},[o]),_.useEffect(()=>{r({type:"setUser",payload:n})},[n]);const a=_.useCallback(async({username:c,password:p})=>{r({type:"initCall"});try{const v=new FormData;v.append("username",c),v.append("password",p);const{fetchPath:m,options:y}=ze({path:De(e,"auth/login"),method:"POST"}),T=await fetch(m,{...y,headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(v)});T.ok||(T.status===400?r({type:"setError",payload:"Username or password wrong."}):r({type:"setError",payload:"Couldn't sign in user"})),i()}catch(v){console.error("signin error",v),r({type:"setError",payload:"Failed to fetch"})}},[e,i]),s=_.useCallback(async()=>{r({type:"initCall"});try{const{fetchPath:c,options:p}=ze({path:De(e,"auth/logout"),method:"POST"});(await fetch(c,p)).ok||r({type:"setError",payload:"Couldn't sign out user"}),r({type:"setUser",payload:null})}catch(c){console.error("signout error",c),r({type:"setError",payload:"Failed to fetch"})}finally{r({type:"setLoading",payload:!1})}},[e]),l=_.useCallback(async c=>{r({type:"initCall"});try{const{fetchPath:p,options:v}=ze({path:De(e,"auth/user"),method:"PUT",body:c});(await fetch(p,v)).ok||r({type:"setError",payload:"Couldn't update user data"}),i()}catch(p){console.error("update error",p),r({type:"setError",payload:"Failed to post"})}},[e,i]),u=_.useCallback(async c=>{if(!n.email)return r({type:"setError",payload:"No email found"});try{const{fetchPath:p,options:v}=ze({path:De(e,"auth/forgot-password"),method:"POST",body:{email:n.email}}),m=await fetch(p,v);if(!m.ok){r({type:"setError",payload:"Couldn't request token to reset password"});return}const y=await m.json(),{token:T}=y,{fetchPath:j,options:R}=ze({path:De(e,"auth/reset-password"),method:"POST",body:{token:T,password:c}});if(!(await fetch(j,R)).ok){r({type:"setError",payload:"Couldn't reset password"});return}i()}catch(p){console.error("resetPassword error",p),r({type:"setError",payload:"Failed to post"})}},[e,i,n==null?void 0:n.email]),f=_.useCallback((c,p)=>{const v=De(e,"auth/login",c);if(p){const T=window.screenLeft+window.outerWidth/2-250,j=window.screenTop+window.outerHeight/2-500/2,R=window.open(v+"?popup=true","auth",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=500, height=500, top=${j}, left=${T}`),A=window.setInterval(function(){R.closed!==!1&&(window.clearInterval(A),i())},200);return}window.location.href=De(e,"auth/login",c)},[e,i]);return{user:t.user,loading:t.loading,error:t.error,signin:a,signout:s,update:l,resetPassword:u,oauth_signin:f,refetch:i}}function kd(e,t){const{user:r}=t,[n,i]=_.useState(null),[o,a]=_.useState(!0),[s,l]=_.useState({error:"401 Not authorized",message:"User is not logged in."});_.useEffect(()=>{r&&u(e)},[r]);const u=async f=>{a(!0);try{const{fetchPath:c,options:p}=ze({path:De(f,"info/"),method:"GET"}),v=await fetch(c,p);if(v.ok){const m=await v.json();i(m)}else l({error:"404 Not Found",message:"Couldn't fetch info"})}catch{l({error:"Network error",message:"Failed to fetch"})}finally{a(!1)}};return{info:n,loading:o,error:s}}const Vi=_.createContext({auth:{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},info:{info:null,loading:!1,error:null}});function qa(){return _.useContext(Vi).auth}function Ka(){return _.useContext(Vi).info}function Pd(e){const t={baseUrl:new URL(document.baseURI).pathname+"/api/v1",inheritMantineTheme:!1},{baseUrl:r,children:n}={...t,...e},i=Od(r),o={baseUrl:r,...kd(r,i)};return d.jsx(Vi.Provider,{value:{auth:i,info:o},children:n})}const jd=async(e,t,r)=>{const{fetchPath:n,options:i}=ze({path:De(t,"/download"),method:"POST"}),o=await fetch(n,{...i,body:JSON.stringify(r)});let a=null;const s=o.headers.get("content-type");if(s&&s.includes("application/json")?a=await o.json():a=await o.blob(),!o.ok)throw typeof a=="object"?new Error(typeof a.detail=="string"?a.detail:JSON.stringify(a,null,2)):new Error(a);const l=document.createElement("a"),u=URL.createObjectURL(a);l.href=u,l.download=e.toLowerCase()+".csv",l.click()};function Id({path:e,initialQueryParams:t,relation:r,fetchInfo:n=!0,clearInfoOnRefetch:i=!1,clearDataOnRefetch:o=!1,resetQueryParamsOnPathChange:a=!0,streaming:s=!1}){const[l,u]=_.useState(t?Jr(null,t):null),f=_.useMemo(()=>r?{...l,filters:[...l.filters,{col:r.foreign_key,opr:r.type,value:Ze(r.id)}]}:l,[r,l]),c=_.useCallback(Y=>u(ie=>{if(!ie)return Jr(null,Y);const ce=Jr({...ie},Y);if(s){if(Y.page&&Y.page!==ie.page&&!Y.streaming)throw new Error("You cannot change page in streaming mode, use streaming.fetch() instead");if(Y.page_size&&Y.page_size!==ie.page_size)throw new Error("You cannot change page size in streaming mode, use streaming.fetch() instead");(Y.filters||Y.order_column||Y.order_direction)&&(ce.page=0)}return ce}),[s]),[p,v]=_.useState(null),m=_.useMemo(()=>p,[p]),y=_.useCallback(()=>v(null),[]),{info:T,loading:j,refetch:R,error:A}=Ga({path:e,autoInvoke:n,clearDataOnRefetch:i}),{data:N,loading:S,refetch:D,error:G}=Ta({path:e,queryParams:f,autoInvoke:!1,clearDataOnRefetch:o});_.useEffect(()=>{f&&D()},[D,f]),_.useEffect(()=>{if(A){v({message:"Couldn't fetch info",originalError:A});return}if(G){v({message:"Couldn't fetch list",originalError:G});return}y()},[A,G,y]);const se=_.useMemo(()=>j||S,[j,S]);At.useDidUpdate(()=>{a&&c(Jr(null,t||{}))},[e]);const h=_.useCallback(async Y=>{try{const ie=await Mf(e,Ze(Y));return y(),ie}catch(ie){v({message:`Couldn't fetch item with id ${Y}`,originalError:ie})}},[e,y]),F=_.useCallback(async(Y,ie)=>{try{const ce=await Df(e,Y);return ie||(R(),D()),y(),ce}catch(ce){v({message:"Couldn't add item",originalError:ce})}},[D,R,e,y]),L=_.useCallback(async(Y,ie,ce)=>{try{const He=await Rf(e,Ze(Y),ie);return ce||(R(),D()),y(),He}catch(He){v({message:`Couldn't update item with id ${Y}`,originalError:He})}},[D,R,e,y]),V=_.useCallback(async(Y,ie)=>{try{const ce=await $f(e,Ze(Y));return ie||(R(),D()),y(),ce}catch(ce){v({message:`Couldn't delete item with id ${Y}`,originalError:ce})}},[D,R,e,y]),te=_.useCallback(async Y=>{try{await jd(Y,e,f)}catch(ie){v({message:"Couldn't download",originalError:ie})}},[e,f]),[le,Te]=At.useSetState({data:{},isEnd:!1,fetch:()=>{throw new Error("Streaming mode not enabled, enable it by adding `streaming` prop to ApiProvider")}});return _.useEffect(()=>{s&&Te({fetch:()=>c({page:0,streaming:!0})})},[c,Te,s]),_.useEffect(()=>{s&&N&&Te(Y=>{let ie=Object.keys(Y.data).length;const ce={isEnd:!1};return f.page<ie?(ie=f.page,ce.data={[f.page]:N.result}):ce.data={...Y.data,[f.page]:N.result},N.result.length<f.page_size?(ce.isEnd=!0,ce.fetch=()=>null):ce.fetch=()=>c({page:ie+1,streaming:!0}),ce})},[N,c,Te,s]),{path:e,data:N,info:T,queryParams:f,loading:se,error:m,streaming:le,setQueryParams:c,refetch:D,refetchInfo:R,getEntry:h,addEntry:F,updateEntry:L,deleteEntry:V,download:te}}const Dd=async(e,t,r)=>{const{fetchPath:n,options:i}=ze({path:De(e,"/bulk",t),method:"POST",body:r}),o=await fetch(n,i);let a=null;const s=o.headers.get("content-type");if(s&&s.includes("application/json")?a=await o.json():a=await o.text(),!o.ok)throw typeof a=="object"?new Error(typeof a.detail=="string"?a.detail:JSON.stringify(a,null,2)):new Error(a);return a},$d=({Api:e})=>{const[t,r]=_.useState([]),[n,i]=_.useState(null),o=_.useCallback(async(s,l)=>{try{i(null);const u=await Dd(e.path,s,t);return l?void 0:(e.refetch(),u)}catch(u){console.error(u),i({message:"Couldn't perform bulk action",originalError:u})}},[e,t]);return{bulkActions:_.useMemo(()=>({selectedIds:t,setSelectedIds:r}),[t,r]),dispatchBulkActions:o,error:n}},Wi=_.createContext({Api:{path:"",data:null,info:null,queryParams:null,loading:!1,error:null,streaming: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},BulkActions:{bulkActions:{selectedIds:[],setSelectedIds:()=>{}},dispatchBulkActions:async(e,t)=>{},error:null}});function $e(){const e=_.useContext(Wi);if(e===void 0)throw new Error("useApi must be used within a ApiProvider");return e.Api}function Md(){const e=_.useContext(Wi);if(e===void 0)throw new Error("useBulkActions must be used within a ApiProvider");return e.BulkActions}function Xa({resource_name:e="",initialQueryParams:t,relation:r,fetchInfo:n,clearInfoOnRefetch:i,clearDataOnRefetch:o,resetQueryParamsOnPathChange:a,children:s,streaming:l}){const{baseUrl:u}=Ka(),f=Id({path:De(u,e),initialQueryParams:t,relation:r,fetchInfo:n,clearInfoOnRefetch:i,clearDataOnRefetch:o,resetQueryParamsOnPathChange:a,streaming:l}),c=$d({path:De(u,e),Api:f});return d.jsx(Wi.Provider,{value:{Api:f,BulkActions:c},children:s})}function Hi(e){return t=>{try{return e.validateSync(t,{abortEarly:!1}),{}}catch(r){const n={};return r instanceof Fe&&r.inner.forEach(i=>{n[i.path.replaceAll("[",".").replaceAll("]","")]=i.message}),n}}}function Rd({form:e,name:t,...r}){return d.jsx(d.Fragment,{children:d.jsx(Xt.DateInput,{...e.getInputProps(t),onChange:n=>{if(n instanceof Date){const i=new Date(n.getTime()-n.getTimezoneOffset()*6e4);e.setFieldValue(t,i.toISOString().substring(0,10))}},value:e.getInputProps(t).value?new Date(e.getInputProps(t).value):null,...r})})}function Nd({form:e,name:t,...r}){return d.jsx(d.Fragment,{children:d.jsx(Xt.DateTimePicker,{...e.getInputProps(t),onChange:n=>{if(n instanceof Date){const i=new Date(n);e.setFieldValue(t,i.toISOString())}},value:e.getInputProps(t).value?new Date(e.getInputProps(t).value):null,...r})})}function ln({form:e,name:t,...r}){const n=e.getInputProps(t).value,i=_.useMemo(()=>n&&typeof n=="object"?JSON.stringify(n):n||"",[n]);return t==="password"?d.jsx(b.PasswordInput,{...e.getInputProps(t),value:i,...r}):d.jsx(b.TextInput,{...e.getInputProps(t),value:i,...r})}function Ja({form:e,name:t,filter:r,...n}){const[i,o]=_.useState(""),a=e.getInputProps(t).value,s=_.useMemo(()=>a?typeof a=="object"?JSON.stringify(a,null,2):a:"",[a]);return _.useEffect(()=>{o(s)},[s]),r?d.jsx(ln,{form:e,name:t,...n}):d.jsx(b.JsonInput,{autosize:!0,minRows:4,maxRows:12,validationError:"Invalid JSON",...e.getInputProps(t),...n,value:i,onChange:l=>{if(o(l),!l){e.getInputProps(t).onChange(null);return}try{const u=JSON.parse(l);e.getInputProps(t).onChange(u)}catch{}}})}function Fd({form:e,name:t,filter:r,...n}){const[i,o]=_.useState(!!r);return d.jsxs(b.InputWrapper,{label:n.label,description:n.description,children:[!r&&d.jsxs(b.Group,{align:"center",gap:"xs",py:"0.25rem",children:[d.jsx(b.Checkbox,{checked:i,onChange:a=>o(a.currentTarget.checked)}),d.jsx(b.Text,{size:"xs",children:"WKT"})]}),i?d.jsx(ln,{form:e,name:t,...n,label:void 0,description:void 0}):d.jsx(Ja,{form:e,name:t,...n,label:void 0,description:void 0})]})}function Ld({form:e,name:t,items:r,...n}){const i=r.map(a=>({value:String(Ze(a.id)),label:a.value})),o=Array.isArray(e.getInputProps(t).value)?e.getInputProps(t).value.map(a=>String(typeof a=="object"?Ze(a.id):a)):[];return d.jsx(b.MultiSelect,{data:i,searchable:!0,...e.getInputProps(t),value:o||[],...n})}function zd({form:e,name:t,items:r,filter:n,...i}){var a;const o=r.map(s=>({value:String(Ze(s.id)),label:s.value}));return d.jsx(b.Select,{data:o,searchable:!0,...e.getInputProps(t),onChange:s=>{if(n){e.setFieldValue(t,s);return}const l=r.find(u=>String(Ze(u.id))===s)||null;e.setFieldValue(t,l)},value:n?e.getInputProps(t).value:String(Ze((a=e.getInputProps(t).value)==null?void 0:a.id))||"",...i})}function Za({form:e,name:t,items:r,...n}){return d.jsx(b.Select,{data:r,searchable:!0,...e.getInputProps(t),value:String(e.getInputProps(t).value)||"",...n})}function Gi({form:e,name:t,schema:r,filter:n,...i}){if(!r.type)return null;switch(r.type){case"Boolean":return d.jsx(Za,{form:e,name:t,items:[{label:"true",value:n?"1":"true"},{label:"false",value:n?"0":"false"}],...i});case"RelatedList":return d.jsx(Ld,{form:e,name:t,items:r.values,...i});case"Related":return d.jsx(zd,{form:e,name:t,items:r.values,filter:n,...i});case"DateTime":return d.jsx(Nd,{form:e,name:t,valueFormat:"DD.MM.YYYY HH:mm:ss",schema:r,...i});case"Date":return d.jsx(Rd,{form:e,name:t,valueFormat:"DD.MM.YYYY",schema:r,...i});case"Geometry":return d.jsx(Fd,{form:e,name:t,filter:n,...i});case"Raw":return d.jsx(Ja,{form:e,name:t,filter:n,...i});case"Integer":case"Float":return d.jsx(ln,{form:e,name:t,...i});case"Enum":return d.jsx(Za,{form:e,name:t,items:r.values,...i});default:return d.jsx(ln,{form:e,name:t,...i})}}function Qa({opened:e,onClose:t,...r}){const{info:n,addEntry:i}=$e(),o={modal:{},stack:{},addButton:{}},{addButton:a,modal:s,stack:l}=b.useProps("AddDialog",o,r),u=vi.useForm({initialValues:n.add.defaultValues,validate:Hi(n.add.schema)}),f=async c=>{await i(c),u.reset(),t()};return _.useEffect(()=>{u.setInitialValues(n.add.defaultValues),u.reset()},[n.add.defaultValues]),d.jsx(b.Modal,{opened:e,onClose:()=>{u.reset(),t()},title:n.add.title,size:"lg",centered:!0,...s,children:d.jsx(b.Box,{component:"form",onSubmit:u.onSubmit(f),children:d.jsx(b.Stack,{spacing:"md",...l,children:d.jsxs(b.ScrollArea.Autosize,{mah:450,type:"auto",children:[n.add.columns.map((c,p)=>d.jsx(Gi,{form:u,name:c.name,label:c.label,description:c.description,schema:c,withAsterisk:c.required},p)),d.jsx(b.Group,{position:"right",mt:"xl",children:d.jsx(b.Button,{type:"submit",...a,children:"Add"})})]})})})})}/**
34
34
  * @license @tabler/icons-react v3.17.0 - MIT
35
35
  *
36
36
  * This source code is licensed under the MIT license.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastapi-rtk",
3
- "version": "0.0.72",
3
+ "version": "0.0.74",
4
4
  "private": false,
5
5
  "description": "A react component library for Flask Appbuilder",
6
6
  "license": "MIT",