{"version":3,"file":"createStore.cjs","names":["createStore","initialState","state","hasState","name","getState","setState","value","exports"],"sources":["../../../src/tools/createStore.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n/**\n * Creates an internal state and gives access to those values via functions.\n *\n * It can be optionally given an initial state.\n */\nexport const createStore = <State extends object>(initialState?: State) => {\n  const state = initialState || ({} as Partial<State>);\n\n  const hasState = <Name extends keyof State>(name: Name) => name in state;\n\n  const getState = <Name extends keyof State>(name: Name) => state[name];\n\n  const setState = <Name extends keyof State>(\n    name: Name,\n    value: Required<State>[Name],\n  ) => {\n    state[name] = value;\n  };\n\n  return {\n    getState,\n    hasState,\n    setState,\n  };\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAOO,MAAMA,WAAW,GAA0BC,YAAoB,IAAK;EACzE,MAAMC,KAAK,GAAGD,YAAY,IAAK,CAAC,CAAoB;EAEpD,MAAME,QAAQ,GAA8BC,IAAU,IAAKA,IAAI,IAAIF,KAAK;EAExE,MAAMG,QAAQ,GAA8BD,IAAU,IAAKF,KAAK,CAACE,IAAI,CAAC;EAEtE,MAAME,QAAQ,GAAGA,CACfF,IAAU,EACVG,KAA4B,KACzB;IACHL,KAAK,CAACE,IAAI,CAAC,GAAGG,KAAK;EACrB,CAAC;EAED,OAAO;IACLF,QAAQ;IACRF,QAAQ;IACRG;EACF,CAAC;AACH,CAAC;AAACE,OAAA,CAAAR,WAAA,GAAAA,WAAA","ignoreList":[]}