import{__require as r}from"./global-this.mjs";import{__require as e}from"./function-uncurry-this.mjs";import{__require as t}from"./an-object-or-undefined.mjs";import{__require as i}from"./a-string.mjs";import{__require as a}from"./has-own-property.mjs";import{__require as n}from"./base64-map.mjs";import{__require as o}from"./get-alphabet-option.mjs";import{__require as f}from"./array-buffer-not-detached.mjs";var s,h;function l(){if(h)return s;h=1;var l=r(),u=e(),p=t(),m=i(),c=a(),d=n(),g=o(),b=f(),w=d.c2i,_=d.c2iUrl,v=l.SyntaxError,j=l.TypeError,k=u("".charAt),q=function(r,e){for(var t=r.length;e<t;e++){var i=k(r,e);if(" "!==i&&"\t"!==i&&"\n"!==i&&"\f"!==i&&"\r"!==i)break}return e},y=function(r,e,t){var i=r.length;i<4&&(r+=2===i?"AA":"A");var a=(e[k(r,0)]<<18)+(e[k(r,1)]<<12)+(e[k(r,2)]<<6)+e[k(r,3)],n=[a>>16&255,a>>8&255,255&a];if(2===i){if(t&&0!==n[1])throw new v("Extra bits");return[n[0]]}if(3===i){if(t&&0!==n[2])throw new v("Extra bits");return[n[0],n[1]]}return n},x=function(r,e,t){for(var i=e.length,a=0;a<i;a++)r[t+a]=e[a];return t+i};return s=function(r,e,t,i){m(r),p(e);var a="base64"===g(e)?w:_,n=e?e.lastChunkHandling:void 0;if(void 0===n&&(n="loose"),"loose"!==n&&"strict"!==n&&"stop-before-partial"!==n)throw new j("Incorrect `lastChunkHandling` option");t&&b(t.buffer);var o=r.length,f=t||[],s=0,h=0,l="",u=0;if(i)for(;;){if((u=q(r,u))===o){if(l.length>0){if("stop-before-partial"===n)break;if("loose"!==n)throw new v("Missing padding");if(1===l.length)throw new v("Malformed padding: exactly one additional character");s=x(f,y(l,a,!1),s)}h=o;break}var d=k(r,u);if(++u,"="===d){if(l.length<2)throw new v("Padding is too early");if(u=q(r,u),2===l.length){if(u===o){if("stop-before-partial"===n)break;throw new v("Malformed padding: only one =")}"="===k(r,u)&&(++u,u=q(r,u))}if(u<o)throw new v("Unexpected character after padding");s=x(f,y(l,a,"strict"===n),s),h=o;break}if(!c(a,d))throw new v("Unexpected character");var A=i-s;if(1===A&&2===l.length||2===A&&3===l.length)break;if(4===(l+=d).length&&(s=x(f,y(l,a,!1),s),l="",h=u,s===i))break}return{bytes:f,read:h,written:s}}}export{l as __require};