import{r as o}from"./index-BP8_t0zE.js";import{u as m}from"./Button-C3j8Wgdd.js";import{t as b}from"./colorManipulator-DXmmM2jC.js";import{u as x}from"./useResourceContext-BI9mATY-.js";var s=o.createContext(void 0),g={getSource:function(e){return e},getLabel:function(e){return e}},E=s.Provider,R=function(){var e=o.useContext(s);return e||g},C=function(){return o.useContext(s)},h=function(){var e=m(),t=x(),r=C();return o.useCallback(function(a){var n=a.source,u=a.label,i=a.resource;return u===!1||u===""?null:u&&typeof u!="string"?u:e.apply(void 0,L({label:u,defaultLabel:n?r==null?void 0:r.getLabel(n):void 0,resource:i,resourceFromContext:t,source:n}))},[t,e,r])},d=function(e){var t=e.source,r=e.label,a=e.resource,n=e.isRequired,u=h();if(r===!0)throw new Error("Label parameter must be a string, a ReactElement or false");return r===!1||r===""?null:r&&typeof r!="string"?r:o.createElement("span",null,u({label:r,resource:a,source:t}),n&&o.createElement("span",{"aria-hidden":"true"}," *"))};d.displayName="FieldTitle";const W=o.memo(d);var L=function(e){if(!e)return[""];var t=e.label,r=e.defaultLabel,a=e.resource,n=e.resourceFromContext,u=e.source;if(typeof t<"u")return[t,{_:t}];if(typeof u>"u")return[""];var i=S(u),c=i.sourceWithoutDigits,v=i.sourceSuffix,l=b(v.replace(/\./g," "),["underscore","humanize"]);return a?[f(a,c),{_:l}]:r?[r,{_:l}]:[f(n||"undefined",c),{_:l}]},f=function(e,t){return"resources.".concat(e,".fields.").concat(t)},S=function(e){var t=e.replace(/\.\d+\./g,"."),r=e.split("."),a;r.forEach(function(u,i){p(u)&&(a=i)});var n=a!=null?r.slice(a+1).join("."):e;return{sourceWithoutDigits:t,sourceSuffix:n}},p=function(e){for(var t=e.length-1;t>=0;t--){var r=e.charCodeAt(t);if(r<48||r>57)return!1}return!0};export{W as F,E as S,R as a,h as u};
