import {
  flap
} from "./chunk-WKK6AYQI.mjs";
import {
  identity,
  pipe
} from "./chunk-ZI34HWXZ.mjs";
import {
  __export
} from "./chunk-QK4PKNB3.mjs";

// src/Store.ts
var Store_exports = {};
__export(Store_exports, {
  Comonad: () => Comonad,
  Functor: () => Functor,
  URI: () => URI,
  duplicate: () => duplicate,
  experiment: () => experiment,
  extend: () => extend,
  extract: () => extract,
  flap: () => flap2,
  map: () => map,
  peeks: () => peeks,
  seek: () => seek,
  seeks: () => seeks,
  store: () => store
});
function seek(s) {
  return (wa) => ({ peek: wa.peek, pos: s });
}
function seeks(f) {
  return (wa) => ({ peek: wa.peek, pos: f(wa.pos) });
}
function peeks(f) {
  return (wa) => wa.peek(f(wa.pos));
}
function experiment(F) {
  return (f) => (wa) => F.map(f(wa.pos), (s) => wa.peek(s));
}
var _map = (fa, f) => pipe(fa, map(f));
var _extend = (wa, f) => pipe(wa, extend(f));
var extend = (f) => (wa) => ({
  peek: (s) => f({ peek: wa.peek, pos: s }),
  pos: wa.pos
});
var extract = (wa) => wa.peek(wa.pos);
var duplicate = /* @__PURE__ */ extend(identity);
var map = (f) => (fa) => ({
  peek: (s) => f(fa.peek(s)),
  pos: fa.pos
});
var URI = "Store";
var Functor = {
  URI,
  map: _map
};
var flap2 = /* @__PURE__ */ flap(Functor);
var Comonad = {
  URI,
  map: _map,
  extend: _extend,
  extract
};
var store = Comonad;

export {
  seek,
  seeks,
  peeks,
  experiment,
  extend,
  extract,
  duplicate,
  map,
  URI,
  Functor,
  flap2 as flap,
  Comonad,
  store,
  Store_exports
};
