var $8zHUo$apolloclientcore = require("@apollo/client/core");
var $8zHUo$apolloclientcache = require("@apollo/client/cache");
var $8zHUo$apolloclientlinkcontext = require("@apollo/client/link/context");
var $8zHUo$crossfetch = require("cross-fetch");
var $8zHUo$browserornode = require("browser-or-node");
var $8zHUo$apolloclient = require("@apollo/client");
var $8zHUo$ramda = require("ramda");
var $8zHUo$yup = require("yup");
var $8zHUo$reactjsxruntime = require("react/jsx-runtime");
var $8zHUo$react = require("react");

function $parcel$exportWildcard(dest, source) {
  Object.keys(source).forEach(function(key) {
    if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
      return;
    }

    Object.defineProperty(dest, key, {
      enumerable: true,
      get: function get() {
        return source[key];
      }
    });
  });

  return dest;
}
function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}
function $parcel$export(e, n, v, s) {
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var $3dfd1fda730923b6$exports = {};

$parcel$export($3dfd1fda730923b6$exports, "AuthenticationAPI", () => $3dfd1fda730923b6$export$ef7143fab23da9fa);








const $b1b75bec82e5d2e4$var$defaultOptions = {};
let $b1b75bec82e5d2e4$export$3a8840c5b2ecf003;
(function(Category1) {
    Category1["Tech"] = "TECH";
})($b1b75bec82e5d2e4$export$3a8840c5b2ecf003 || ($b1b75bec82e5d2e4$export$3a8840c5b2ecf003 = {}));
let $b1b75bec82e5d2e4$export$32a7462f6a06cbd5;
(function(Choice1) {
    Choice1["All"] = "ALL";
    Choice1["Blocked"] = "BLOCKED";
    Choice1["Removed"] = "REMOVED";
})($b1b75bec82e5d2e4$export$32a7462f6a06cbd5 || ($b1b75bec82e5d2e4$export$32a7462f6a06cbd5 = {}));
let $b1b75bec82e5d2e4$export$ce4fe1c9e6520c1a;
(function(Language1) {
    Language1["English"] = "ENGLISH";
})($b1b75bec82e5d2e4$export$ce4fe1c9e6520c1a || ($b1b75bec82e5d2e4$export$ce4fe1c9e6520c1a = {}));
let $b1b75bec82e5d2e4$export$d705376a55e9a010;
(function(Pre_Comment_Moderation1) {
    Pre_Comment_Moderation1["All"] = "ALL";
    Pre_Comment_Moderation1["NewComments"] = "NEW_COMMENTS";
    Pre_Comment_Moderation1["None"] = "NONE";
})($b1b75bec82e5d2e4$export$d705376a55e9a010 || ($b1b75bec82e5d2e4$export$d705376a55e9a010 = {}));
let $b1b75bec82e5d2e4$export$23b2c85c6956e202;
(function(Report_Reason1) {
    Report_Reason1["Disagree"] = "DISAGREE";
    Report_Reason1["InappropriateProfile"] = "INAPPROPRIATE_PROFILE";
    Report_Reason1["PrivateInformation"] = "PRIVATE_INFORMATION";
    Report_Reason1["Spam"] = "SPAM";
    Report_Reason1["ThreateningContent"] = "THREATENING_CONTENT";
})($b1b75bec82e5d2e4$export$23b2c85c6956e202 || ($b1b75bec82e5d2e4$export$23b2c85c6956e202 = {}));
let $b1b75bec82e5d2e4$export$96e9906d6d93a972;
(function(Status1) {
    Status1["Away"] = "AWAY";
    Status1["Invisble"] = "INVISBLE";
    Status1["Offline"] = "OFFLINE";
    Status1["Online"] = "ONLINE";
})($b1b75bec82e5d2e4$export$96e9906d6d93a972 || ($b1b75bec82e5d2e4$export$96e9906d6d93a972 = {}));
let $b1b75bec82e5d2e4$export$14faa19a0f3bbeb2;
(function(Theme1) {
    Theme1["Auto"] = "AUTO";
    Theme1["Dark"] = "DARK";
    Theme1["Light"] = "LIGHT";
})($b1b75bec82e5d2e4$export$14faa19a0f3bbeb2 || ($b1b75bec82e5d2e4$export$14faa19a0f3bbeb2 = {}));
let $b1b75bec82e5d2e4$export$b905c5eb2371f30d;
(function(User_Role1) {
    User_Role1["Admin"] = "ADMIN";
    User_Role1["Moderator"] = "MODERATOR";
    User_Role1["Owner"] = "OWNER";
    User_Role1["SuperAdmin"] = "SUPER_ADMIN";
    User_Role1["User"] = "USER";
})($b1b75bec82e5d2e4$export$b905c5eb2371f30d || ($b1b75bec82e5d2e4$export$b905c5eb2371f30d = {}));
let $b1b75bec82e5d2e4$export$d43f91ac58cde147;
(function(Sort1) {
    Sort1["Asc"] = "ASC";
    Sort1["Desc"] = "DESC";
    Sort1["TopVotes"] = "TOP_VOTES";
})($b1b75bec82e5d2e4$export$d43f91ac58cde147 || ($b1b75bec82e5d2e4$export$d43f91ac58cde147 = {}));
let $b1b75bec82e5d2e4$export$a8e3f2ebb00eaac0;
(function(Where1) {
    Where1["All"] = "ALL";
    Where1["Appoved"] = "APPOVED";
    Where1["Deleted"] = "DELETED";
    Where1["Pending"] = "PENDING";
    Where1["Spam"] = "SPAM";
})($b1b75bec82e5d2e4$export$a8e3f2ebb00eaac0 || ($b1b75bec82e5d2e4$export$a8e3f2ebb00eaac0 = {}));
const $b1b75bec82e5d2e4$export$69e203829f4c1afc = (0, $8zHUo$apolloclient.gql)`
    fragment LoginResponseFragment on LoginResponse {
  success
  message
  token
  refresh_token
  two_factor_authentication
  user {
    username
    id
  }
}
    `;
const $b1b75bec82e5d2e4$export$ead756aa7ba90749 = (0, $8zHUo$apolloclient.gql)`
    fragment TwoFactorLoginResponseFragment on TwoFactorLoginResponse {
  success
  message
  two_factor_authentication
}
    `;
const $b1b75bec82e5d2e4$export$6b3464c5d7f85714 = (0, $8zHUo$apolloclient.gql)`
    mutation Registration($registrationInput: RegistrationInput!) {
  register_user(registrationInput: $registrationInput) {
    success
    message
  }
}
    `;
function $b1b75bec82e5d2e4$export$3428a3cdfa5b163c(baseOptions) {
    const options = {
        ...$b1b75bec82e5d2e4$var$defaultOptions,
        ...baseOptions
    };
    return $8zHUo$apolloclient.useMutation($b1b75bec82e5d2e4$export$6b3464c5d7f85714, options);
}
const $b1b75bec82e5d2e4$export$e934c7e7cbd240d3 = (0, $8zHUo$apolloclient.gql)`
    mutation Login($loginInput: LoginInput!) {
  login_user(loginInput: $loginInput) {
    ... on LoginResponse {
      ...LoginResponseFragment
    }
    ... on TwoFactorLoginResponse {
      ...TwoFactorLoginResponseFragment
    }
  }
}
    ${$b1b75bec82e5d2e4$export$69e203829f4c1afc}
${$b1b75bec82e5d2e4$export$ead756aa7ba90749}`;
function $b1b75bec82e5d2e4$export$cddfb6c1bfa4d45f(baseOptions) {
    const options = {
        ...$b1b75bec82e5d2e4$var$defaultOptions,
        ...baseOptions
    };
    return $8zHUo$apolloclient.useMutation($b1b75bec82e5d2e4$export$e934c7e7cbd240d3, options);
}
const $b1b75bec82e5d2e4$export$dcbf711a03b8c02 = (0, $8zHUo$apolloclient.gql)`
    mutation ForgotPassword($forgotPasswordInput: ForgotPasswordInput!) {
  forgot_password(forgotPasswordInput: $forgotPasswordInput) {
    success
    message
  }
}
    `;
function $b1b75bec82e5d2e4$export$5cc27ec90be72f47(baseOptions) {
    const options = {
        ...$b1b75bec82e5d2e4$var$defaultOptions,
        ...baseOptions
    };
    return $8zHUo$apolloclient.useMutation($b1b75bec82e5d2e4$export$dcbf711a03b8c02, options);
}
const $b1b75bec82e5d2e4$export$28cb95ad8abc2a39 = (0, $8zHUo$apolloclient.gql)`
    mutation TwoFactorLogin($twoFactorInput: TwoFactorInput!) {
  two_factor_login(twoFactorInput: $twoFactorInput) {
    success
    message
    token
    refresh_token
    two_factor_authentication
    user {
      username
      id
    }
  }
}
    `;
function $b1b75bec82e5d2e4$export$4570e77180b264f5(baseOptions) {
    const options = {
        ...$b1b75bec82e5d2e4$var$defaultOptions,
        ...baseOptions
    };
    return $8zHUo$apolloclient.useMutation($b1b75bec82e5d2e4$export$28cb95ad8abc2a39, options);
}
const $b1b75bec82e5d2e4$export$ea98dd21a39d1e2f = (0, $8zHUo$apolloclient.gql)`
    mutation DeleteUser($deleteUserInput: DeleteUserInput!) {
  delete_user(deleteUserInput: $deleteUserInput) {
    success
    message
  }
}
    `;
function $b1b75bec82e5d2e4$export$2e519bb6ce31dd11(baseOptions) {
    const options = {
        ...$b1b75bec82e5d2e4$var$defaultOptions,
        ...baseOptions
    };
    return $8zHUo$apolloclient.useMutation($b1b75bec82e5d2e4$export$ea98dd21a39d1e2f, options);
}
const $b1b75bec82e5d2e4$export$14a4aacbf5cbc9bc = (0, $8zHUo$apolloclient.gql)`
    mutation ChangePassword($changePasswordInput: ChangePasswordInput!) {
  change_password(changePasswordInput: $changePasswordInput) {
    success
    message
  }
}
    `;
function $b1b75bec82e5d2e4$export$4742f5cd36d944ba(baseOptions) {
    const options = {
        ...$b1b75bec82e5d2e4$var$defaultOptions,
        ...baseOptions
    };
    return $8zHUo$apolloclient.useMutation($b1b75bec82e5d2e4$export$14a4aacbf5cbc9bc, options);
}
const $b1b75bec82e5d2e4$export$397516600bb4d3a2 = (0, $8zHUo$apolloclient.gql)`
    query CurrentUser {
  current_user {
    id
    username
  }
}
    `;
function $b1b75bec82e5d2e4$export$318bde49185e5a43(baseOptions) {
    const options = {
        ...$b1b75bec82e5d2e4$var$defaultOptions,
        ...baseOptions
    };
    return $8zHUo$apolloclient.useQuery($b1b75bec82e5d2e4$export$397516600bb4d3a2, options);
}
function $b1b75bec82e5d2e4$export$5c2913b448ed52a3(baseOptions) {
    const options = {
        ...$b1b75bec82e5d2e4$var$defaultOptions,
        ...baseOptions
    };
    return $8zHUo$apolloclient.useLazyQuery($b1b75bec82e5d2e4$export$397516600bb4d3a2, options);
}


class $4e29a4477e40358d$export$90336a80f6540e2a {
    constructor(client){
        this.client = client;
    }
    async currentUser() {
        try {
            const result = await this.client.query({
                query: (0, $b1b75bec82e5d2e4$export$397516600bb4d3a2)
            });
            return result;
        } catch (error) {
            throw new (0, $8zHUo$apolloclientcore.ApolloError)({});
        }
    }
}




const $16f6c609ee5c0325$export$61e1cef5e3ce01f4 = async (args, global)=>{
    try {
        const { client: client  } = global;
        return client.mutate({
            mutation: (0, $b1b75bec82e5d2e4$export$14a4aacbf5cbc9bc),
            variables: {
                changePasswordInput: {
                    ...args
                }
            }
        });
    } catch (error) {
        console.log("CHANGE_PASSWORD_ERROR", error);
        throw new Error();
    }
};



const $f72cea435b5bb56f$export$16a77fc53c22c001 = async (args, global)=>{
    try {
        const { client: client  } = global;
        return client.mutate({
            mutation: (0, $b1b75bec82e5d2e4$export$ea98dd21a39d1e2f),
            variables: {
                deleteUserInput: {
                    ...args
                }
            }
        });
    } catch (error) {
        throw new Error();
    }
};



const $381c0aca42c58a48$export$7bcb52fd164768d7 = async (args, global)=>{
    try {
        const { client: client  } = global;
        return client.mutate({
            mutation: (0, $b1b75bec82e5d2e4$export$dcbf711a03b8c02),
            variables: {
                forgotPasswordInput: {
                    ...args
                }
            }
        });
    } catch (error) {
        throw new Error();
    }
};



const $c00954a35581532e$export$596d806903d1f59e = async (args, global)=>{
    try {
        const { client: client , application_short_name: application_short_name  } = global;
        const { email: email , password: password  } = args;
        return client.mutate({
            mutation: (0, $b1b75bec82e5d2e4$export$e934c7e7cbd240d3),
            variables: {
                loginInput: {
                    password: password,
                    email: email,
                    application_short_name: application_short_name
                }
            }
        });
    } catch (error) {
        throw new Error();
    }
};




const $ffc14b5fe38f5a13$export$18161bf0c2cc33bf = (args, global)=>{
    try {
        const { client: client , application_short_name: application_short_name  } = global;
        const newArgs = (0, $8zHUo$ramda.omit)([
            "repeat_password"
        ], args);
        console.log("APPLICATION_SHORT_NAME", application_short_name);
        console.log("ARGUMENTS", args);
        console.log("CLIENT", client);
        return client.mutate({
            mutation: (0, $b1b75bec82e5d2e4$export$6b3464c5d7f85714),
            variables: {
                registrationInput: {
                    ...newArgs,
                    application_short_name: application_short_name
                }
            }
        });
    } catch (error) {
        throw new Error(`Error ${error}`);
    }
};



const $d17db102ac16a72b$export$a9d9691a7d4db6bd = async (args, global)=>{
    try {
        const { client: client  } = global;
        return client.mutate({
            mutation: (0, $b1b75bec82e5d2e4$export$28cb95ad8abc2a39),
            variables: {
                twoFactorInput: {
                    ...args
                }
            }
        });
    } catch (error) {
        console.log("EVEN BIGGER", error);
        throw new Error();
    }
};



const $1445c36b1a29aa1e$var$validationSchema = $8zHUo$yup.object({
    email: $8zHUo$yup.string().email("Invalid Email").required("Email is required"),
    password: $8zHUo$yup.string().min(3, "Password should be of minimum 3 characters length").required("Password is required")
});
const $1445c36b1a29aa1e$export$e73d7cc0004a77b9 = $8zHUo$yup.object({
    email: $8zHUo$yup.string().email("Invalid Email").required("Email is required"),
    two_factor_id: $8zHUo$yup.string().required()
});
const $1445c36b1a29aa1e$export$1d35000822dca729 = $1445c36b1a29aa1e$var$validationSchema;
const $1445c36b1a29aa1e$export$2b99294c6bccdf0 = $1445c36b1a29aa1e$var$validationSchema;
const $1445c36b1a29aa1e$export$3ea8111132f48fd1 = $1445c36b1a29aa1e$var$validationSchema.concat($8zHUo$yup.object().shape({
    username: $8zHUo$yup.string().required(),
    repeat_password: $8zHUo$yup.string().test("passwords-match", "Passwords must match", function(value) {
        return this.parent.password === value;
    })
}));


class $2bc800b104ff1022$export$9be6299caf82539 {
    constructor({ client: client , cache: cache , application_short_name: application_short_name  }){
        console.log("AuthenticationMutations.constructor", application_short_name);
        this.application_short_name = application_short_name;
        this.client = client;
        this.cache = cache;
    }
    async login(args) {
        try {
            await (0, $1445c36b1a29aa1e$export$2b99294c6bccdf0).validate(args);
            return (0, $c00954a35581532e$export$596d806903d1f59e)(args, {
                ...this
            });
        } catch (error) {
            throw new (0, $8zHUo$apolloclientcore.ApolloError)({});
        }
    }
    async register(args) {
        try {
            await (0, $1445c36b1a29aa1e$export$3ea8111132f48fd1).validate(args);
            return (0, $ffc14b5fe38f5a13$export$18161bf0c2cc33bf)(args, {
                ...this
            });
        } catch (error) {
            console.log(error);
            throw new (0, $8zHUo$apolloclientcore.ApolloError)({});
        }
    }
    async two_factor_login(args) {
        try {
            await (0, $1445c36b1a29aa1e$export$e73d7cc0004a77b9).validate(args);
            return (0, $d17db102ac16a72b$export$a9d9691a7d4db6bd)(args, {
                ...this
            });
        } catch (error) {
            console.log("BIG ERROR", error);
            throw new (0, $8zHUo$apolloclientcore.ApolloError)({});
        }
    }
    async forgot_password(args) {
        try {
            return (0, $381c0aca42c58a48$export$7bcb52fd164768d7)(args, {
                ...this
            });
        } catch (error) {
            throw new (0, $8zHUo$apolloclientcore.ApolloError)({});
        }
    }
    async change_password(args) {
        try {
            await (0, $1445c36b1a29aa1e$export$1d35000822dca729).validate(args);
            return (0, $16f6c609ee5c0325$export$61e1cef5e3ce01f4)(args, {
                ...this
            });
        } catch (error) {
            console.log("CHANGE_PASSWORD_FRONT", error);
            throw new (0, $8zHUo$apolloclientcore.ApolloError)({});
        }
    }
    async delete_user(args) {
        try {
            return (0, $f72cea435b5bb56f$export$16a77fc53c22c001)(args, {
                ...this
            });
        } catch (error) {
            throw new (0, $8zHUo$apolloclientcore.ApolloError)({});
        }
    }
}


const $3dfd1fda730923b6$var$TEST_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImVhOGZkMzc2LWI0MjMtNGU3Yi1hOWQzLWMyOWEwYjliM2MwZSIsInVzZXJuYW1lIjoic2NvdHQiLCJlbWFpbCI6InNjb3R0YmVycnk5MUBnbWFpbC5jb20iLCJjb25maXJtZWQiOnRydWUsImlhdCI6MTY1Mzk5NjgxMywiZXhwIjoxNjU0NjAxNjEzfQ.5YoHp3JTFiNTfXBW64tAEBmhg0KtSxx6vZPX1x_je04";
class $3dfd1fda730923b6$export$ef7143fab23da9fa {
    constructor(uri, application_short_name, cache, token_name){
        this.application_short_name = application_short_name;
        this.generateClient(uri, cache);
        this.bootstrap();
    }
    generateClient(uri, cache) {
        let token;
        if (0, $8zHUo$browserornode.isBrowser) token = localStorage.getItem("binary-stash-token");
        else token = $3dfd1fda730923b6$var$TEST_TOKEN;
        if (!token && !(0, $8zHUo$browserornode.isBrowser)) throw new Error("Token is required");
        if (!cache) this.cache = new (0, $8zHUo$apolloclientcache.InMemoryCache)({});
        else this.cache = cache;
        const httpLink = (0, $8zHUo$apolloclientcore.createHttpLink)({
            uri: uri,
            fetch: ($parcel$interopDefault($8zHUo$crossfetch))
        });
        const authLink = (0, $8zHUo$apolloclientlinkcontext.setContext)((_, { headers: headers  })=>{
            return {
                headers: {
                    ...headers,
                    authorization: `Bearer ${token}`
                }
            };
        });
        // const subUri =
        //     process.env.NODE_ENV === 'production'
        //         ? 'wss://lasthurrah.co.uk/ws-graphql'
        //         : 'ws://localhost:4003/graphql'
        // const wsLink = new WebSocketLink({
        //     webSocketImpl: ws,
        //     uri: subUri,
        //     options: {
        //         reconnect: true,
        //         connectionParams: {
        //             Authorization: `Bearer ${token}`,
        //         },
        //     },
        // })
        const authHttpLink = authLink.concat(httpLink);
        // const splitLink = split(
        //     ({ query }) => {
        //         const definition = getMainDefinition(query)
        //         return (
        //             definition.kind === 'OperationDefinition' &&
        //             definition.operation === 'subscription'
        //         )
        //     },
        //     wsLink,
        //     authHttpLink,
        // )
        this.client = new (0, $8zHUo$apolloclientcore.ApolloClient)({
            link: authHttpLink,
            cache: this.cache
        });
    }
    bootstrap() {
        this.queries = new (0, $4e29a4477e40358d$export$90336a80f6540e2a)(this.client);
        this.mutations = new (0, $2bc800b104ff1022$export$9be6299caf82539)({
            application_short_name: this.application_short_name,
            client: this.client,
            cache: this.cache
        });
    }
}


var $e0c351cbc3cd5b05$exports = {};

$parcel$export($e0c351cbc3cd5b05$exports, "AuthenticationAPIProvider", () => $e0c351cbc3cd5b05$export$c1cdcc2ef2e85ec2);
$parcel$export($e0c351cbc3cd5b05$exports, "BinaryStashProvider", () => $e0c351cbc3cd5b05$export$147331c9ecc569c8);


const $e0c351cbc3cd5b05$export$c1cdcc2ef2e85ec2 = /*#__PURE__*/ (0, $8zHUo$react.createContext)({});
const $e0c351cbc3cd5b05$export$147331c9ecc569c8 = ({ children: children , client: client ,  })=>{
    return /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)($e0c351cbc3cd5b05$export$c1cdcc2ef2e85ec2.Provider, {
        value: client,
        children: children
    });
};


$parcel$exportWildcard(module.exports, $3dfd1fda730923b6$exports);
$parcel$exportWildcard(module.exports, $e0c351cbc3cd5b05$exports);


//# sourceMappingURL=index.js.map
