1 | import{objectSpread2 as r,slicedToArray as e,asyncToGenerator as t,regeneratorRuntime as a,defineProperty as n}from"./_virtual/_rollupPluginBabelHelpers.js";import s from"react";var o={service:function(r){},data:{},message:{},param:{type:"type",path:"path"}},u=function(e,t){return"SET"===t.type?r(r({},e),t.payload):{}},c=function(c){var p=new AbortController,i=r(r({},o),c),f=s.useState(!1),y=e(f,2),l=y[0],m=y[1],d=s.useReducer(u,{}),v=e(d,2),h=v[0],g=v[1],b=function(){var e=t(a().mark((function e(t){var n,s,o;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r({service:i.service},t),s={ctr:p,data:c.data,parser:w(g)},m(!0),e.next=5,n.service(s);case 5:return o=e.sent,m(!1),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),w=function r(e){return function(t){Array.isArray(t)?t.forEach((function(t){return r(e)(t)})):i.hasOwnProperty("message")&&i.message.hasOwnProperty(t[i.param.type])&&e({type:"SET",payload:n({},t[i.param.path],i.message[t[i.param.type]](t))})}};return{processing:l,validate:b,message:function(r){return h[r]||""},error:function(r){return r?h.hasOwnProperty(r):0!==Object.keys(h).length},clear:function(){g({type:"CLEAR"})},cancel:function(){p.abort()}}};export{c as default};
|